diff --git a/abb_hardware_interface/src/abb_hardware_interface.cpp b/abb_hardware_interface/src/abb_hardware_interface.cpp index 43ef979..8ca7870 100644 --- a/abb_hardware_interface/src/abb_hardware_interface.cpp +++ b/abb_hardware_interface/src/abb_hardware_interface.cpp @@ -46,6 +46,7 @@ CallbackReturn ABBSystemHardware::on_init(const hardware_interface::HardwareInfo RCLCPP_INFO_STREAM(LOGGER, "Robot controller description:\n" << abb::robot::summaryText(robot_controller_description_)); + std::vector initial_joint_values = {}; for (const hardware_interface::ComponentInfo& joint : info_.joints) { if (joint.command_interfaces.size() != 2) @@ -89,6 +90,27 @@ CallbackReturn ABBSystemHardware::on_init(const hardware_interface::HardwareInfo joint.name.c_str(), joint.state_interfaces[1].name.c_str(), hardware_interface::HW_IF_VELOCITY); return CallbackReturn::ERROR; } + // Set the initial values for state and position interfaces. + auto get_value_from_info = + [](const std::string& info_value) -> double + { + if (info_value.empty()) + return 0.0; + try + { + return std::stod(info_value); + } + catch(const std::exception& e) + { + return 0.0; + } + }; + abb::robot::InitialJointValue initial_value; + initial_value.position_state = get_value_from_info(joint.state_interfaces[0].initial_value); + initial_value.velocity_state = get_value_from_info(joint.state_interfaces[1].initial_value); + initial_value.position_command = get_value_from_info(joint.command_interfaces[0].initial_value); + initial_value.velocity_command = get_value_from_info(joint.command_interfaces[1].initial_value); + initial_joint_values.push_back(std::move(initial_value)); } // Configure EGM @@ -97,7 +119,7 @@ CallbackReturn ABBSystemHardware::on_init(const hardware_interface::HardwareInfo // Initialize motion data from robot controller description try { - abb::robot::initializeMotionData(motion_data_, robot_controller_description_); + abb::robot::initializeMotionData(motion_data_, robot_controller_description_, initial_joint_values); } catch (...) { diff --git a/robot_specific_config/abb_irb1200_support/urdf/irb1200.ros2_control.xacro b/robot_specific_config/abb_irb1200_support/urdf/irb1200.ros2_control.xacro index d9f9938..80eb429 100644 --- a/robot_specific_config/abb_irb1200_support/urdf/irb1200.ros2_control.xacro +++ b/robot_specific_config/abb_irb1200_support/urdf/irb1200.ros2_control.xacro @@ -26,23 +26,33 @@ {-2*pi} {2*pi} + 0.0 + + + 0.0 - 0.0 - + + 0.0 + -2.41 2.41 + 0.0 + + + 0.0 - 0.0 - + + 0.0 + @@ -59,34 +69,49 @@ -2.66 2.66 + 0.0 + + + 0.0 - 0.0 - + + 0.0 + {-2*pi} {2*pi} + 0.0 + + + 0.0 - 0.0 - + + 0.0 + -2.23 2.23 + 0.0 + + + 0.0 - 0.0 - + + 0.0 +