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,5 +1,4 @@ 1 -(% class="wikigeneratedid" id="HC2B2BCrashCrashCourse" %) 2 -Using C++. 1 += C++ Crash Crash Course = 3 3 4 4 == Day 1 == 5 5 ... ... @@ -7,15 +7,15 @@ 7 7 8 8 g++ source1.cpp -o program1 9 9 10 -Paths, "/" and "."and".."in navigating directories- absolute vs relative9 +Paths, . and .. in navigating directories 11 11 12 -data type - binary itself ismeaningless unless you saywhat information that thebinarybits represent11 +data type - memory, binary 13 13 14 14 declare variables (int, char, string as series of chars) 15 15 16 16 statements end with semicolon 17 17 18 -cstdio library #include17 +cstdio library include 19 19 20 20 calling a function - printf 21 21 ... ... @@ -33,11 +33,11 @@ 33 33 34 34 While loop = for loop with empty initialiser/advancement statements 35 35 36 -Switch - match expression's result to case label , execute statements until break.35 +Switch - match expression's result to case label 37 37 38 -Switch vs if-else differences - number of times expressions are evaluated37 +Switch vs if-else differences. 39 39 40 - writeyour own function39 +your own function 41 41 42 42 calling with parameters copied as separate set of var values in function 43 43 ... ... @@ -53,82 +53,18 @@ 53 53 54 54 Value overflow because not enough number of bits to represent large numbers. 55 55 56 -Various integer data types - specifier in printf 57 - 58 58 Homework: implement factorial (1 to 20) calculator 59 59 60 -in Linux, most things are case-sensitive. (A not equals a) 61 - 62 62 == Day 3 == 63 63 64 64 factorial printer - 2 approaches: 65 65 66 -1. for-loop that goes 1 to 20 and each loop calls fact(n 61 +1. for-loop that goes 1 to 20 and each loop calls fact(n) function and prints return. 67 67 1. for-loop that goes 1 to 20 and multiplies once each time and print. 68 68 69 69 set initial values of vars when declaring otherwise initial values are unpredictable 70 70 71 -factorial function - implemented in recursive way, closer to mathematical definition 72 72 73 -stack memory 74 74 75 -stack frame to store var values in each function call 76 76 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 104 - 105 -== Day 4 == 106 - 107 -message subscriber. 108 - 109 -argc and agrv 110 - 111 -node name during ros::init 112 - 113 -topic advertise/subscribe explained. 114 - 115 -subscribe() only memorises that this node wants messages and what to do with them. 116 - 117 -subscribe() - providing name of function. not calling. 118 - 119 -publisher while ros::ok() loop. 120 - 121 -subscriber spin() loop - handle events. 122 - 123 -the double-colon operator: (1) namespace (2) static member of class 124 - 125 -pointers are memory addresses 126 - 127 -arrow -> operator 128 - 129 -array are elements in sequence in memory. 130 - 131 -char ~*~* = pointer of pointer of char data. 132 - 133 - 134 134