Skip to content

Commit cf50251

Browse files
committed
Fixed format from merge and removed old version
1 parent b1b35b0 commit cf50251

File tree

1 file changed

+30
-71
lines changed

1 file changed

+30
-71
lines changed

ur_robot_driver/src/hardware_interface.cpp

Lines changed: 30 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ std::vector<hardware_interface::CommandInterface> URPositionHardwareInterface::e
348348

349349
command_interfaces.emplace_back(hardware_interface::CommandInterface(
350350
tf_prefix + FREEDRIVE_MODE, "abort", &freedrive_mode_abort_));
351+
351352
command_interfaces.emplace_back(hardware_interface::CommandInterface(tf_prefix + PASSTHROUGH_GPIO, "transfer_state",
352353
&passthrough_trajectory_transfer_state_));
353354

@@ -849,52 +850,52 @@ void URPositionHardwareInterface::checkAsyncIO()
849850

850851
void URPositionHardwareInterface::updateNonDoubleValues()
851852
{
852-
for (size_t i = 0; i < 18; ++i) {
853-
actual_dig_out_bits_copy_[i] = static_cast<double>(actual_dig_out_bits_[i]);
854-
actual_dig_in_bits_copy_[i] = static_cast<double>(actual_dig_in_bits_[i]);
855-
}
853+
for (size_t i = 0; i < 18; ++i) {
854+
actual_dig_out_bits_copy_[i] = static_cast<double>(actual_dig_out_bits_[i]);
855+
actual_dig_in_bits_copy_[i] = static_cast<double>(actual_dig_in_bits_[i]);
856+
}
856857

857-
for (size_t i = 0; i < 11; ++i) {
858-
safety_status_bits_copy_[i] = static_cast<double>(safety_status_bits_[i]);
859-
}
858+
for (size_t i = 0; i < 11; ++i) {
859+
safety_status_bits_copy_[i] = static_cast<double>(safety_status_bits_[i]);
860+
}
860861

861-
for (size_t i = 0; i < 4; ++i) {
862-
analog_io_types_copy_[i] = static_cast<double>(analog_io_types_[i]);
863-
robot_status_bits_copy_[i] = static_cast<double>(robot_status_bits_[i]);
864-
}
862+
for (size_t i = 0; i < 4; ++i) {
863+
analog_io_types_copy_[i] = static_cast<double>(analog_io_types_[i]);
864+
robot_status_bits_copy_[i] = static_cast<double>(robot_status_bits_[i]);
865+
}
865866

866-
for (size_t i = 0; i < 2; ++i) {
867-
tool_analog_input_types_copy_[i] = static_cast<double>(tool_analog_input_types_[i]);
868-
}
867+
for (size_t i = 0; i < 2; ++i) {
868+
tool_analog_input_types_copy_[i] = static_cast<double>(tool_analog_input_types_[i]);
869+
}
869870

870-
tool_output_voltage_copy_ = static_cast<double>(tool_output_voltage_);
871-
robot_mode_copy_ = static_cast<double>(robot_mode_);
872-
safety_mode_copy_ = static_cast<double>(safety_mode_);
873-
tool_mode_copy_ = static_cast<double>(tool_mode_);
874-
system_interface_initialized_ = initialized_ ? 1.0 : 0.0;
875-
robot_program_running_copy_ = robot_program_running_ ? 1.0 : 0.0;
871+
tool_output_voltage_copy_ = static_cast<double>(tool_output_voltage_);
872+
robot_mode_copy_ = static_cast<double>(robot_mode_);
873+
safety_mode_copy_ = static_cast<double>(safety_mode_);
874+
tool_mode_copy_ = static_cast<double>(tool_mode_);
875+
system_interface_initialized_ = initialized_ ? 1.0 : 0.0;
876+
robot_program_running_copy_ = robot_program_running_ ? 1.0 : 0.0;
876877
}
877878

878879
void URPositionHardwareInterface::transformForceTorque()
879880
{
880-
// imported from ROS1 driver - hardware_interface.cpp#L867-L876
881-
tcp_force_.setValue(urcl_ft_sensor_measurements_[0], urcl_ft_sensor_measurements_[1],
882-
urcl_ft_sensor_measurements_[2]);
883-
tcp_torque_.setValue(urcl_ft_sensor_measurements_[3], urcl_ft_sensor_measurements_[4],
884-
urcl_ft_sensor_measurements_[5]);
881+
// imported from ROS1 driver - hardware_interface.cpp#L867-L876
882+
tcp_force_.setValue(urcl_ft_sensor_measurements_[0], urcl_ft_sensor_measurements_[1],
883+
urcl_ft_sensor_measurements_[2]);
884+
tcp_torque_.setValue(urcl_ft_sensor_measurements_[3], urcl_ft_sensor_measurements_[4],
885+
urcl_ft_sensor_measurements_[5]);
885886

886887
tcp_force_ = tf2::quatRotate(tcp_rotation_quat_.inverse(), tcp_force_);
887888
tcp_torque_ = tf2::quatRotate(tcp_rotation_quat_.inverse(), tcp_torque_);
888889

889-
urcl_ft_sensor_measurements_ = { tcp_force_.x(), tcp_force_.y(), tcp_force_.z(),
890+
urcl_ft_sensor_measurements_ = { tcp_force_.x(), tcp_force_.y(), tcp_force_.z(),
890891
tcp_torque_.x(), tcp_torque_.y(), tcp_torque_.z() };
891892
}
892893

893894
void URPositionHardwareInterface::extractToolPose()
894895
{
895-
// imported from ROS1 driver hardware_interface.cpp#L911-L928
896-
double tcp_angle =
897-
std::sqrt(std::pow(urcl_tcp_pose_[3], 2) + std::pow(urcl_tcp_pose_[4], 2) + std::pow(urcl_tcp_pose_[5], 2));
896+
// imported from ROS1 driver hardware_interface.cpp#L911-L928
897+
double tcp_angle =
898+
std::sqrt(std::pow(urcl_tcp_pose_[3], 2) + std::pow(urcl_tcp_pose_[4], 2) + std::pow(urcl_tcp_pose_[5], 2));
898899

899900
tf2::Vector3 rotation_vec(urcl_tcp_pose_[3], urcl_tcp_pose_[4], urcl_tcp_pose_[5]);
900901
if (tcp_angle > 1e-16) {
@@ -960,48 +961,6 @@ hardware_interface::return_type URPositionHardwareInterface::prepare_command_mod
960961
}
961962
}
962963
}
963-
// set new mode to all interfaces at the same time
964-
if (start_modes_.size() != 0 && start_modes_.size() != 6) {
965-
ret_val = hardware_interface::return_type::ERROR;
966-
}
967-
968-
if (position_controller_running_ &&
969-
std::none_of(stop_modes_.begin(), stop_modes_.end(),
970-
[](auto item) { return item == StoppingInterface::STOP_POSITION; }) &&
971-
std::any_of(start_modes_.begin(), start_modes_.end(), [this](auto& item) {
972-
return (item == hardware_interface::HW_IF_VELOCITY || item == FREEDRIVE_MODE);
973-
})) {
974-
RCLCPP_ERROR(get_logger(), "Start of velocity interface or freedrive mode requested while there is the position "
975-
"interface running.");
976-
ret_val = hardware_interface::return_type::ERROR;
977-
}
978-
979-
if (velocity_controller_running_ &&
980-
std::none_of(stop_modes_.begin(), stop_modes_.end(),
981-
[](auto item) { return item == StoppingInterface::STOP_VELOCITY; }) &&
982-
std::any_of(start_modes_.begin(), start_modes_.end(), [this](auto& item) {
983-
return (item == hardware_interface::HW_IF_POSITION || item == FREEDRIVE_MODE);
984-
})) {
985-
RCLCPP_ERROR(get_logger(), "Start of position interface or freedrive mode requested while there is the velocity "
986-
"interface running.");
987-
ret_val = hardware_interface::return_type::ERROR;
988-
}
989-
990-
if (freedrive_mode_controller_running_ &&
991-
std::none_of(stop_modes_.begin(), stop_modes_.end(),
992-
[](auto item) { return item == StoppingInterface::STOP_FREEDRIVE; }) &&
993-
std::any_of(start_modes_.begin(), start_modes_.end(), [](auto& item) {
994-
return (item == hardware_interface::HW_IF_VELOCITY || item == hardware_interface::HW_IF_POSITION);
995-
})) {
996-
RCLCPP_ERROR(get_logger(), "Start of position or velocity interface requested while the freedrive controller "
997-
"is running.");
998-
ret_val = hardware_interface::return_type::ERROR;
999-
}
1000-
1001-
// all start interfaces must be the same - can't mix position and velocity control
1002-
if (start_modes_.size() != 0 && !std::equal(start_modes_.begin() + 1, start_modes_.end(), start_modes_.begin())) {
1003-
ret_val = hardware_interface::return_type::ERROR;
1004-
}
1005964

1006965
// Stopping interfaces
1007966
// add stop interface per joint in tmp var for later check

0 commit comments

Comments
 (0)