Skip to content

Commit 7695453

Browse files
committed
Make sure we acknowledge a new trajectory before sending points
If we miss the new trajectory, wen cannot resize the vectors appropriately.
1 parent 76078b6 commit 7695453

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

ur_controllers/include/ur_controllers/passthrough_trajectory_controller.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ namespace ur_controllers
8181
* 5.0: The robot finished executing the trajectory.
8282
*/
8383
const double TRANSFER_STATE_IDLE = 0.0;
84+
const double TRANSFER_STATE_NEW_TRAJECTORY = 6.0;
8485
const double TRANSFER_STATE_WAITING_FOR_POINT = 1.0;
8586
const double TRANSFER_STATE_TRANSFERRING = 2.0;
8687
const double TRANSFER_STATE_TRANSFER_DONE = 3.0;

ur_controllers/src/passthrough_trajectory_controller.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ controller_interface::return_type PassthroughTrajectoryController::update(const
268268
active_trajectory_elapsed_time_ = rclcpp::Duration(0, 0);
269269
max_trajectory_time_ =
270270
rclcpp::Duration::from_seconds(duration_to_double(active_joint_traj_.points.back().time_from_start));
271-
write_success &= transfer_command_interface_->get().set_value(TRANSFER_STATE_WAITING_FOR_POINT);
271+
write_success &= transfer_command_interface_->get().set_value(TRANSFER_STATE_NEW_TRAJECTORY);
272272
write_success &=
273273
trajectory_size_command_interface_->get().set_value(static_cast<double>(active_joint_traj_.points.size()));
274274
}

ur_robot_driver/src/hardware_interface.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,7 @@ void URPositionHardwareInterface::check_passthrough_trajectory_controller()
13401340
// We should abort and are not in state IDLE
13411341
if (passthrough_trajectory_abort_ == 1.0 && passthrough_trajectory_transfer_state_ != 0.0) {
13421342
ur_driver_->writeTrajectoryControlMessage(urcl::control::TrajectoryControlMessage::TRAJECTORY_CANCEL);
1343-
} else if (passthrough_trajectory_transfer_state_ == 1.0) {
1343+
} else if (passthrough_trajectory_transfer_state_ == 6.0) {
13441344
if (passthrough_trajectory_size_ != trajectory_joint_positions_.size()) {
13451345
RCLCPP_INFO(get_logger(), "Got a new trajectory with %lu points.",
13461346
static_cast<size_t>(passthrough_trajectory_size_));
@@ -1352,6 +1352,7 @@ void URPositionHardwareInterface::check_passthrough_trajectory_controller()
13521352
point_index_sent = 0;
13531353
trajectory_started = false;
13541354
last_time = 0.0;
1355+
passthrough_trajectory_transfer_state_ = 1.0;
13551356
}
13561357
} else if (passthrough_trajectory_transfer_state_ == 2.0) {
13571358
passthrough_trajectory_abort_ = 0.0;

0 commit comments

Comments
 (0)