Skip to content

Commit 45c0a69

Browse files
committed
cleanup & minor fixes
1 parent b04ed2b commit 45c0a69

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

robotiq_hande_driver/hardware/include/robotiq_hande_driver/socat_manager.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace robotiq_hande_driver {
1515

16-
static constexpr auto WAIT_FOR_SOCAT = std::chrono::milliseconds(1000);
16+
static constexpr auto WAIT_FOR_SOCAT_CONNECTION = std::chrono::milliseconds(1000);
1717

1818
class SocatManager {
1919
public:

robotiq_hande_driver/hardware/src/hande_hardware_interface.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <chrono>
55
#include <hardware_interface/types/hardware_interface_type_values.hpp>
6+
#include <stdexcept>
67
#include <thread>
78

89
namespace 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();

robotiq_hande_driver/hardware/src/socat_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "robotiq_hande_driver/socat_manager.hpp"
22

3+
#include <iostream>
34
#include <stdexcept>
45

56
namespace robotiq_hande_driver {
@@ -34,7 +35,6 @@ void SocatManager::start() {
3435

3536
// Parent process code
3637
started_ = true;
37-
std::this_thread::sleep_for(WAIT_FOR_SOCAT);
3838

3939
// Check if process is still alive
4040
int status;

0 commit comments

Comments
 (0)