Changes for page ROS Crash Course
Last modified by Leon Poon on 2021/08/30 23:24
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -1,4 +1,5 @@ 1 -= C++ Crash Crash Course = 1 +(% class="wikigeneratedid" id="HC2B2BCrashCrashCourse" %) 2 +Using C++. 2 2 3 3 == Day 1 == 4 4 ... ... @@ -6,15 +6,15 @@ 6 6 7 7 g++ source1.cpp -o program1 8 8 9 -Paths, . and .. in navigating directories 10 +Paths, "/" and "." and ".." in navigating directories - absolute vs relative 10 10 11 -data type - memory,binary12 +data type - binary itself is meaningless unless you say what information that the binary bits represent 12 12 13 13 declare variables (int, char, string as series of chars) 14 14 15 15 statements end with semicolon 16 16 17 -cstdio library include 18 +cstdio library #include 18 18 19 19 calling a function - printf 20 20 ... ... @@ -32,11 +32,11 @@ 32 32 33 33 While loop = for loop with empty initialiser/advancement statements 34 34 35 -Switch - match expression's result to case label 36 +Switch - match expression's result to case label, execute statements until break. 36 36 37 -Switch vs if-else differences .38 +Switch vs if-else differences - number of times expressions are evaluated 38 38 39 -your own function 40 +write your own function 40 40 41 41 calling with parameters copied as separate set of var values in function 42 42 ... ... @@ -52,18 +52,51 @@ 52 52 53 53 Value overflow because not enough number of bits to represent large numbers. 54 54 56 +Various integer data types - specifier in printf 57 + 55 55 Homework: implement factorial (1 to 20) calculator 56 56 60 +in Linux, most things are case-sensitive. (A not equals a) 61 + 57 57 == Day 3 == 58 58 59 59 factorial printer - 2 approaches: 60 60 61 -1. for-loop that goes 1 to 20 and each loop calls fact(n) function and prints return. 66 +1. for-loop that goes 1 to 20 and each loop calls fact(n ) function and prints return. 62 62 1. for-loop that goes 1 to 20 and multiplies once each time and print. 63 63 64 64 set initial values of vars when declaring otherwise initial values are unpredictable 65 65 71 +factorial function - implemented in recursive way, closer to mathematical definition 66 66 73 +stack memory 67 67 75 +stack frame to store var values in each function call 68 68 69 - 77 +stack overflow/crash (segfault) 78 + 79 +base condition to stop the recursion 80 + 81 +recursive algorithms are common - e.g. when dealing with trees 82 + 83 +spaces in file/directory names and how to navigate - space is special in terminal 84 + 85 +understand names chosen by yourself vs names chosen by other people for your use 86 + 87 +creating ros package - arguments: package name, dependencies 88 + 89 +CMakeLists.txt (.txt file can also be used with other programs) 90 + 91 +cmake = build tool - compile many files in some defined ways 92 + 93 +package.xml - information for ROS 94 + 95 +compiling - carefully read and understand and seek answers to error messages 96 + 97 +msg files - fields declaration with data type 98 + 99 +create cpp file for a node 100 + 101 +quick reading of code for publisher node 102 + 103 +homework: implement message subscriber node according to ROS book