@@ -241,57 +241,6 @@ controller_interface::return_type JointTrajectoryController::update(
241
241
}
242
242
}
243
243
244
- // set values for next hardware write() if tolerance is met
245
- if (!tolerance_violated_while_moving && within_goal_time)
246
- {
247
- if (use_closed_loop_pid_adapter_)
248
- {
249
- // Update PIDs
250
- for (auto i = 0ul ; i < dof_; ++i)
251
- {
252
- tmp_command_[i] = (state_desired_.velocities [i] * ff_velocity_scale_[i]) +
253
- pids_[i]->computeCommand (
254
- state_error_.positions [i], state_error_.velocities [i],
255
- (uint64_t )period.nanoseconds ());
256
- }
257
- }
258
-
259
- // set values for next hardware write()
260
- if (has_position_command_interface_)
261
- {
262
- assign_interface_from_point (joint_command_interface_[0 ], state_desired_.positions );
263
- }
264
- if (has_velocity_command_interface_)
265
- {
266
- if (use_closed_loop_pid_adapter_)
267
- {
268
- assign_interface_from_point (joint_command_interface_[1 ], tmp_command_);
269
- }
270
- else
271
- {
272
- assign_interface_from_point (joint_command_interface_[1 ], state_desired_.velocities );
273
- }
274
- }
275
- if (has_acceleration_command_interface_)
276
- {
277
- assign_interface_from_point (joint_command_interface_[2 ], state_desired_.accelerations );
278
- }
279
- if (has_effort_command_interface_)
280
- {
281
- if (use_closed_loop_pid_adapter_)
282
- {
283
- assign_interface_from_point (joint_command_interface_[3 ], tmp_command_);
284
- }
285
- else
286
- {
287
- assign_interface_from_point (joint_command_interface_[3 ], state_desired_.effort );
288
- }
289
- }
290
-
291
- // store the previous command. Used in open-loop control mode
292
- last_commanded_state_ = state_desired_;
293
- }
294
-
295
244
const auto active_goal = *rt_active_goal_.readFromRT ();
296
245
if (active_goal)
297
246
{
@@ -359,6 +308,57 @@ controller_interface::return_type JointTrajectoryController::update(
359
308
set_hold_position ();
360
309
RCLCPP_ERROR (get_node ()->get_logger (), " Holding position due to state tolerance violation" );
361
310
}
311
+
312
+ // set values for next hardware write() if tolerance is met
313
+ if (!tolerance_violated_while_moving && within_goal_time)
314
+ {
315
+ if (use_closed_loop_pid_adapter_)
316
+ {
317
+ // Update PIDs
318
+ for (auto i = 0ul ; i < dof_; ++i)
319
+ {
320
+ tmp_command_[i] = (state_desired_.velocities [i] * ff_velocity_scale_[i]) +
321
+ pids_[i]->computeCommand (
322
+ state_error_.positions [i], state_error_.velocities [i],
323
+ (uint64_t )period.nanoseconds ());
324
+ }
325
+ }
326
+
327
+ // set values for next hardware write()
328
+ if (has_position_command_interface_)
329
+ {
330
+ assign_interface_from_point (joint_command_interface_[0 ], state_desired_.positions );
331
+ }
332
+ if (has_velocity_command_interface_)
333
+ {
334
+ if (traj_point_active_ptr_ && use_closed_loop_pid_adapter_)
335
+ {
336
+ assign_interface_from_point (joint_command_interface_[1 ], tmp_command_);
337
+ }
338
+ else
339
+ {
340
+ assign_interface_from_point (joint_command_interface_[1 ], state_desired_.velocities );
341
+ }
342
+ }
343
+ if (has_acceleration_command_interface_)
344
+ {
345
+ assign_interface_from_point (joint_command_interface_[2 ], state_desired_.accelerations );
346
+ }
347
+ if (has_effort_command_interface_)
348
+ {
349
+ if (traj_point_active_ptr_ && use_closed_loop_pid_adapter_)
350
+ {
351
+ assign_interface_from_point (joint_command_interface_[3 ], tmp_command_);
352
+ }
353
+ else
354
+ {
355
+ assign_interface_from_point (joint_command_interface_[3 ], state_desired_.effort );
356
+ }
357
+ }
358
+
359
+ // store the previous command. Used in open-loop control mode
360
+ last_commanded_state_ = state_desired_;
361
+ }
362
362
}
363
363
}
364
364
0 commit comments