Skip to content

Commit c36e961

Browse files
committed
Allow starting and stopping multiple interfaces at once
Compatibility has been checked in prepare already, so we can potentially start all in perform.
1 parent de7c107 commit c36e961

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

ur_robot_driver/src/hardware_interface.cpp

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,28 +1302,34 @@ hardware_interface::return_type URPositionHardwareInterface::perform_command_mod
13021302
StoppingInterface::STOP_POSITION) != stop_modes_[0].end()) {
13031303
position_controller_running_ = false;
13041304
urcl_position_commands_ = urcl_position_commands_old_ = urcl_joint_positions_;
1305-
} else if (stop_modes_[0].size() != 0 && std::find(stop_modes_[0].begin(), stop_modes_[0].end(),
1306-
StoppingInterface::STOP_VELOCITY) != stop_modes_[0].end()) {
1305+
}
1306+
if (stop_modes_[0].size() != 0 && std::find(stop_modes_[0].begin(), stop_modes_[0].end(),
1307+
StoppingInterface::STOP_VELOCITY) != stop_modes_[0].end()) {
13071308
velocity_controller_running_ = false;
13081309
urcl_velocity_commands_ = { { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 } };
1309-
} else if (stop_modes_[0].size() != 0 && std::find(stop_modes_[0].begin(), stop_modes_[0].end(),
1310-
StoppingInterface::STOP_FORCE_MODE) != stop_modes_[0].end()) {
1310+
}
1311+
if (stop_modes_[0].size() != 0 && std::find(stop_modes_[0].begin(), stop_modes_[0].end(),
1312+
StoppingInterface::STOP_FORCE_MODE) != stop_modes_[0].end()) {
13111313
force_mode_controller_running_ = false;
13121314
stop_force_mode();
1313-
} else if (stop_modes_[0].size() != 0 && std::find(stop_modes_[0].begin(), stop_modes_[0].end(),
1314-
StoppingInterface::STOP_PASSTHROUGH) != stop_modes_[0].end()) {
1315+
}
1316+
if (stop_modes_[0].size() != 0 && std::find(stop_modes_[0].begin(), stop_modes_[0].end(),
1317+
StoppingInterface::STOP_PASSTHROUGH) != stop_modes_[0].end()) {
1318+
RCLCPP_WARN(get_logger(), "Stopping passthrough trajectory controller.");
13151319
passthrough_trajectory_controller_running_ = false;
13161320
passthrough_trajectory_abort_ = 1.0;
13171321
trajectory_joint_positions_.clear();
13181322
trajectory_joint_accelerations_.clear();
13191323
trajectory_joint_velocities_.clear();
1320-
} else if (stop_modes_.size() != 0 && std::find(stop_modes_[0].begin(), stop_modes_[0].end(),
1321-
StoppingInterface::STOP_FREEDRIVE) != stop_modes_[0].end()) {
1324+
}
1325+
if (stop_modes_.size() != 0 && std::find(stop_modes_[0].begin(), stop_modes_[0].end(),
1326+
StoppingInterface::STOP_FREEDRIVE) != stop_modes_[0].end()) {
13221327
freedrive_mode_controller_running_ = false;
13231328
freedrive_activated_ = false;
13241329
freedrive_mode_abort_ = 1.0;
1325-
} else if (stop_modes_.size() != 0 && std::find(stop_modes_[0].begin(), stop_modes_[0].end(),
1326-
StoppingInterface::STOP_TOOL_CONTACT) != stop_modes_[0].end()) {
1330+
}
1331+
if (stop_modes_.size() != 0 && std::find(stop_modes_[0].begin(), stop_modes_[0].end(),
1332+
StoppingInterface::STOP_TOOL_CONTACT) != stop_modes_[0].end()) {
13271333
tool_contact_controller_running_ = false;
13281334
tool_contact_result_ = 3.0;
13291335
}
@@ -1341,17 +1347,20 @@ hardware_interface::return_type URPositionHardwareInterface::perform_command_mod
13411347
passthrough_trajectory_controller_running_ = false;
13421348
urcl_velocity_commands_ = { { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 } };
13431349
velocity_controller_running_ = true;
1344-
} else if (start_modes_[0].size() != 0 &&
1345-
std::find(start_modes_[0].begin(), start_modes_[0].end(), FORCE_MODE_GPIO) != start_modes_[0].end()) {
1350+
}
1351+
if (start_modes_[0].size() != 0 &&
1352+
std::find(start_modes_[0].begin(), start_modes_[0].end(), FORCE_MODE_GPIO) != start_modes_[0].end()) {
13461353
force_mode_controller_running_ = true;
1347-
} else if (start_modes_[0].size() != 0 &&
1348-
std::find(start_modes_[0].begin(), start_modes_[0].end(), PASSTHROUGH_GPIO) != start_modes_[0].end()) {
1354+
}
1355+
if (start_modes_[0].size() != 0 &&
1356+
std::find(start_modes_[0].begin(), start_modes_[0].end(), PASSTHROUGH_GPIO) != start_modes_[0].end()) {
13491357
velocity_controller_running_ = false;
13501358
position_controller_running_ = false;
13511359
passthrough_trajectory_controller_running_ = true;
13521360
passthrough_trajectory_abort_ = 0.0;
1353-
} else if (start_modes_[0].size() != 0 &&
1354-
std::find(start_modes_[0].begin(), start_modes_[0].end(), FREEDRIVE_MODE_GPIO) != start_modes_[0].end()) {
1361+
}
1362+
if (start_modes_[0].size() != 0 &&
1363+
std::find(start_modes_[0].begin(), start_modes_[0].end(), FREEDRIVE_MODE_GPIO) != start_modes_[0].end()) {
13551364
velocity_controller_running_ = false;
13561365
position_controller_running_ = false;
13571366
freedrive_mode_controller_running_ = true;

0 commit comments

Comments
 (0)