33
44#include < chrono>
55#include < hardware_interface/types/hardware_interface_type_values.hpp>
6+ #include < stdexcept>
67#include < thread>
78
89namespace robotiq_hande_driver {
@@ -32,8 +33,6 @@ HWI::CallbackReturn RobotiqHandeHardwareInterface::on_init(const HWI::HardwareIn
3233 log_parsed_urdf_config ();
3334
3435 th_comm_enabled_.store (false );
35- state_velocity_ = 0.0 ;
36- cmd_force_ = 1.0 ;
3736 gripper_position_min_ = std::stod (info_.hardware_parameters [" grip_pos_min" ]);
3837 gripper_position_max_ = std::stod (info_.hardware_parameters [" grip_pos_max" ]);
3938
@@ -55,6 +54,7 @@ HWI::CallbackReturn RobotiqHandeHardwareInterface::on_init(const HWI::HardwareIn
5554 color::RESET);
5655 socat_.emplace (SocatManager (ip_addr, std::stoi (port), tty_port));
5756 socat_->start ();
57+ std::this_thread::sleep_for (WAIT_FOR_SOCAT_CONNECTION);
5858
5959 RCLCPP_INFO (
6060 get_logger (),
@@ -66,8 +66,15 @@ HWI::CallbackReturn RobotiqHandeHardwareInterface::on_init(const HWI::HardwareIn
6666
6767 initalize_gripper_driver ();
6868
69- cmd_position_ = gripper_position_max_;
7069 state_position_ = gripper_position_max_;
70+ state_velocity_ = 0.0 ;
71+ read_position_.store (state_position_);
72+ read_velocity_.store (state_velocity_);
73+
74+ cmd_force_ = 1.0 ;
75+ cmd_position_ = gripper_position_max_;
76+ write_position_.store (cmd_position_);
77+ write_force_.store (cmd_force_);
7178
7279 return HWI::CallbackReturn::SUCCESS;
7380}
@@ -127,7 +134,6 @@ HWI::CallbackReturn RobotiqHandeHardwareInterface::on_configure(
127134 RCLCPP_INFO (get_logger (), " %sConnected%s" , color::BGREEN, color::RESET);
128135 return HWI::CallbackReturn::SUCCESS;
129136 } catch (const std::exception& e) {
130- // TODO check if RCLCPP_WARN_STREAM exists
131137 RCLCPP_WARN (get_logger (), " %s%s%s" , color::BYELLOW, e.what (), color::RESET);
132138 }
133139 wait_100ms ();
0 commit comments