@@ -128,29 +128,49 @@ Let's focus on writing an action server that computes the Fibonacci sequence usi
128128
129129Open up ``action_tutorials_cpp/src/fibonacci_action_server.cpp ``, and put the following code in:
130130
131- .. literalinclude :: server.cpp
132- :language: c++
133- :linenos:
131+ .. tabs ::
132+
133+ .. group-tab :: Eloquent and newer
134+
135+ .. literalinclude :: server-eloquent-and-newer.cpp
136+ :language: c++
137+ :linenos:
138+
139+ .. group-tab :: Dashing
140+
141+ .. literalinclude :: server-dashing.cpp
142+ :language: c++
143+ :linenos:
134144
135145The first few lines include all of the headers we need to compile.
136146
137147Next we create a class that is a derived class of ``rclcpp::Node ``:
138148
139- .. literalinclude :: server.cpp
149+ .. literalinclude :: server-eloquent-and-newer .cpp
140150 :language: c++
141151 :lines: 14
142152
143153The constructor for the ``FibonacciActionServer `` class initializes the node name as ``fibonacci_action_server ``:
144154
145- .. literalinclude :: server.cpp
155+ .. literalinclude :: server-eloquent-and-newer .cpp
146156 :language: c++
147157 :lines: 21-22
148158
149159The constructor also instantiates a new action server:
150160
151- .. literalinclude :: server.cpp
152- :language: c++
153- :lines: 26-31
161+ .. tabs ::
162+
163+ .. group-tab :: Eloquent and newer
164+
165+ .. literalinclude :: server-eloquent-and-newer.cpp
166+ :language: c++
167+ :lines: 26-31
168+
169+ .. group-tab :: Dashing
170+
171+ .. literalinclude :: server-dashing.cpp
172+ :language: c++
173+ :lines: 26-34
154174
155175An action server requires 6 things:
156176
@@ -166,31 +186,31 @@ Note that all of the callbacks need to return quickly, otherwise we risk starvin
166186
167187We start with the callback for handling new goals:
168188
169- .. literalinclude :: server.cpp
189+ .. literalinclude :: server-eloquent-and-newer .cpp
170190 :language: c++
171191 :lines: 37-44
172192
173193This implementation just accepts all goals.
174194
175195Next up is the callback for dealing with cancellation:
176196
177- .. literalinclude :: server.cpp
197+ .. literalinclude :: server-eloquent-and-newer .cpp
178198 :language: c++
179199 :lines: 46-52
180200
181201This implementation just tells the client that it accepted the cancellation.
182202
183203The last of the callbacks accepts a new goal and starts processing it:
184204
185- .. literalinclude :: server.cpp
205+ .. literalinclude :: server-eloquent-and-newer .cpp
186206 :language: c++
187207 :lines: 54-59
188208
189209Since the execution is a long-running operation, we spawn off a thread to do the actual work and return from ``handle_accepted `` quickly.
190210
191211All further processing and updates are done in the ``execute `` method in the new thread:
192212
193- .. literalinclude :: server.cpp
213+ .. literalinclude :: server-eloquent-and-newer .cpp
194214 :language: c++
195215 :lines: 61-95
196216
@@ -255,29 +275,49 @@ Source the workspace we just built (``action_ws``), and try to run the action se
255275
256276Open up ``action_tutorials_cpp/src/fibonacci_action_client.cpp ``, and put the following code in:
257277
258- .. literalinclude :: client.cpp
259- :language: c++
260- :linenos:
278+ .. tabs ::
279+
280+ .. group-tab :: Eloquent and newer
281+
282+ .. literalinclude :: client-eloquent-and-newer.cpp
283+ :language: c++
284+ :linenos:
285+
286+ .. group-tab :: Dashing
287+
288+ .. literalinclude :: client-dashing.cpp
289+ :language: c++
290+ :linenos:
261291
262292The first few lines include all of the headers we need to compile.
263293
264294Next we create a class that is a derived class of ``rclcpp::Node ``:
265295
266- .. literalinclude :: client.cpp
296+ .. literalinclude :: client-eloquent-and-newer .cpp
267297 :language: c++
268298 :lines: 15
269299
270300The constructor for the ``FibonacciActionClient `` class initializes the node name as ``fibonacci_action_client ``:
271301
272- .. literalinclude :: client.cpp
302+ .. literalinclude :: client-eloquent-and-newer .cpp
273303 :language: c++
274304 :lines: 20-22
275305
276306The constructor also instantiates a new action client:
277307
278- .. literalinclude :: client.cpp
279- :language: c++
280- :lines: 24-26
308+ .. tabs ::
309+
310+ .. group-tab :: Eloquent and newer
311+
312+ .. literalinclude :: client-eloquent-and-newer.cpp
313+ :language: c++
314+ :lines: 24-26
315+
316+ .. group-tab :: Dashing
317+
318+ .. literalinclude :: client-dashing.cpp
319+ :language: c++
320+ :lines: 24-29
281321
282322An action client requires 3 things:
283323
@@ -287,13 +327,13 @@ An action client requires 3 things:
287327
288328We also instantiate a ROS timer that will kick off the one and only call to ``send_goal ``:
289329
290- .. literalinclude :: client.cpp
330+ .. literalinclude :: client-eloquent-and-newer .cpp
291331 :language: c++
292332 :lines: 27-30
293333
294334When the timer expires, it will call ``send_goal ``:
295335
296- .. literalinclude :: client.cpp
336+ .. literalinclude :: client-eloquent-and-newer .cpp
297337 :language: c++
298338 :lines: 32-57
299339
@@ -308,21 +348,21 @@ This function does the following:
308348When the server receives and accepts the goal, it will send a response to the client.
309349That response is handled by ``goal_response_callback ``:
310350
311- .. literalinclude :: client.cpp
351+ .. literalinclude :: client-eloquent-and-newer .cpp
312352 :language: c++
313353 :lines: 62-71
314354
315355Assuming the goal was accepted by the server, it will start processing.
316356Any feedback to the client will be handled by the ``feedback_callback ``:
317357
318- .. literalinclude :: client.cpp
358+ .. literalinclude :: client-eloquent-and-newer .cpp
319359 :language: c++
320360 :lines: 72-83
321361
322362When the server is finished processing, it will return a result to the client.
323363The result is handled by the ``result_callback ``:
324364
325- .. literalinclude :: client.cpp
365+ .. literalinclude :: client-eloquent-and-newer .cpp
326366 :language: c++
327367 :lines: 84-107
328368
0 commit comments