@@ -54,14 +54,20 @@ Package-related sources
54
54
.. admonition :: In this step, we'll work on these.
55
55
56
56
.. code-block :: console
57
- :emphasize-lines: 2,6
57
+ :emphasize-lines: 2,8
58
+
59
+ └── sas_robot_driver_myrobot
60
+ ├── CMakeLists.txt
61
+ ├── include
62
+ │ └── sas_robot_driver_myrobot
63
+ │ └── sas_robot_driver_myrobot.hpp
64
+ ├── launch
65
+ │ └── real_robot_launch.py
66
+ ├── package.xml
67
+ └── src
68
+ ├── sas_robot_driver_myrobot.cpp
69
+ └── sas_robot_driver_myrobot_node.cpp
58
70
59
- └── sas_robot_driver_myrobot
60
- ├── CMakeLists.txt
61
- ├── include
62
- │ └── sas_robot_driver_myrobot
63
- ├── package.xml
64
- └── src
65
71
66
72
The files already exist, we just need to modify them as follows
67
73
@@ -110,6 +116,102 @@ Create all relevant files
110
116
mkdir -p launch
111
117
touch launch/real_robot_launch.py
112
118
113
- Contents of the header file
119
+ The robot driver class
120
+ ----------------------
121
+
122
+ .. admonition :: In this step, we'll work on these.
123
+
124
+ .. code-block :: console
125
+ :emphasize-lines: 5,10
126
+
127
+ └── sas_robot_driver_myrobot
128
+ ├── CMakeLists.txt
129
+ ├── include
130
+ │ └── sas_robot_driver_myrobot
131
+ │ └── sas_robot_driver_myrobot.hpp
132
+ ├── launch
133
+ │ └── real_robot_launch.py
134
+ ├── package.xml
135
+ └── src
136
+ ├── sas_robot_driver_myrobot.cpp
137
+ └── sas_robot_driver_myrobot_node.cpp
138
+
139
+ The example class file has two important design choices to note.
140
+
141
+ First, we rely on the struct ``RobotDriverMyrobotConfiguration ``
142
+ to simplify interaction with the constructor. This reduces the amount of code that needs to be changed if a parameter is
143
+ added or removed.
144
+
145
+ Second, we rely on the `PIMPL idiom <https://en.cppreference.com/w/cpp/language/pimpl >`_. This idiom is important to
146
+ prevent driver internals to pollute the exported header. This is a very important step to guarantee that your users
147
+ don't have to worry about source files specific to the robot and that your package is correctly self-contained.
148
+
149
+ .. tab-set ::
150
+
151
+ .. tab-item :: sas_robot_driver_myrobot.hpp
152
+
153
+ :download: `sas_robot_driver_myrobot.hpp <../../../sas_tutorial_workspace/src/sas_robot_driver_myrobot/include/sas_robot_driver_myrobot/sas_robot_driver_myrobot.hpp >`
154
+
155
+ .. literalinclude :: ../../../sas_tutorial_workspace/src/sas_robot_driver_myrobot/include/sas_robot_driver_myrobot/sas_robot_driver_myrobot.hpp
156
+ :language: cpp
157
+ :linenos:
158
+ :lines: 26-
159
+
160
+ .. tab-item :: sas_robot_driver_myrobot.cpp
161
+
162
+ :download: `sas_robot_driver_myrobot.cpp <../../../sas_tutorial_workspace/src/sas_robot_driver_myrobot/src/sas_robot_driver_myrobot.cpp `
163
+
164
+ .. literalinclude :: ../../../sas_tutorial_workspace/src/sas_robot_driver_myrobot/src/sas_robot_driver_myrobot.cpp
165
+ :language: cpp
166
+ :linenos:
167
+ :lines: 25-
168
+
169
+ Contents of the launch file
114
170
---------------------------
115
171
172
+ .. admonition :: In this step, we'll work on this.
173
+
174
+ .. code-block :: console
175
+ :emphasize-lines: 7
176
+
177
+ └── sas_robot_driver_myrobot
178
+ ├── CMakeLists.txt
179
+ ├── include
180
+ │ └── sas_robot_driver_myrobot
181
+ │ └── sas_robot_driver_myrobot.hpp
182
+ ├── launch
183
+ │ └── real_robot_launch.py
184
+ ├── package.xml
185
+ └── src
186
+ ├── sas_robot_driver_myrobot.cpp
187
+ └── sas_robot_driver_myrobot_node.cpp
188
+
189
+ Running the launch file
190
+ -----------------------
191
+
192
+ .. code-block :: console
193
+
194
+ ros2 launch sas_robot_driver_myrobot real_robot_launch.py
195
+
196
+ In another terminal
197
+
198
+ .. code-block :: console
199
+
200
+ ros2 topic list
201
+
202
+ will show all the available topics that were created for you, freely. Notice that in none of the source files
203
+ we created so far had any mention to topics or subscribers. All are created by :program: `sas `.
204
+
205
+ .. code-block :: console
206
+
207
+ /myrobot_1/get/home_states
208
+ /myrobot_1/get/joint_positions_max
209
+ /myrobot_1/get/joint_positions_min
210
+ /myrobot_1/get/joint_states
211
+ /myrobot_1/set/clear_positions
212
+ /myrobot_1/set/homing_signal
213
+ /myrobot_1/set/target_joint_forces
214
+ /myrobot_1/set/target_joint_positions
215
+ /myrobot_1/set/target_joint_velocities
216
+ /parameter_events
217
+ /rosout
0 commit comments