From 7858d6ef12e7419d309d02fb1c48583e4e04f49a Mon Sep 17 00:00:00 2001 From: Niko Date: Thu, 11 Apr 2024 18:42:12 +0200 Subject: [PATCH] debugging --- .../robotiq_2f_interface/MockRobotiq2fSocketAdapter.hpp | 2 ++ .../robotiq_2f_interface/Robotiq2fSocketAdapter.hpp | 4 +++- .../include/robotiq_2f_interface/SocketAdapterBase.hpp | 2 +- .../robotiq_2f_interface/src/Robotiq2fSocketAdapter.cpp | 8 ++++---- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/robotiq_2f/robotiq_2f_interface/include/robotiq_2f_interface/MockRobotiq2fSocketAdapter.hpp b/src/robotiq_2f/robotiq_2f_interface/include/robotiq_2f_interface/MockRobotiq2fSocketAdapter.hpp index 4669e9f..d2b7fe4 100644 --- a/src/robotiq_2f/robotiq_2f_interface/include/robotiq_2f_interface/MockRobotiq2fSocketAdapter.hpp +++ b/src/robotiq_2f/robotiq_2f_interface/include/robotiq_2f_interface/MockRobotiq2fSocketAdapter.hpp @@ -8,6 +8,8 @@ #include #include +#include "robotiq_2f_interface/SocketAdapterBase.hpp" + namespace robotiq{ class MockRobotiq2fSocketAdapter : public SocketAdapterBase { public: diff --git a/src/robotiq_2f/robotiq_2f_interface/include/robotiq_2f_interface/Robotiq2fSocketAdapter.hpp b/src/robotiq_2f/robotiq_2f_interface/include/robotiq_2f_interface/Robotiq2fSocketAdapter.hpp index 5bd482a..394da7b 100644 --- a/src/robotiq_2f/robotiq_2f_interface/include/robotiq_2f_interface/Robotiq2fSocketAdapter.hpp +++ b/src/robotiq_2f/robotiq_2f_interface/include/robotiq_2f_interface/Robotiq2fSocketAdapter.hpp @@ -25,6 +25,8 @@ #include // For errno #include +#include "robotiq_2f_interface/SocketAdapterBase.hpp" + namespace robotiq{ // Enum for Gripper Status enum class GripperStatus { @@ -173,7 +175,7 @@ public: * @throws std::runtime_error if the adapter is not connected to the gripper, if the gripper is not in an * active state, or if the calibration sequence fails. */ - void auto_calibrate(bool log=true) override; + void auto_calibrate(bool log=true); /** * Deactivates the gripper. diff --git a/src/robotiq_2f/robotiq_2f_interface/include/robotiq_2f_interface/SocketAdapterBase.hpp b/src/robotiq_2f/robotiq_2f_interface/include/robotiq_2f_interface/SocketAdapterBase.hpp index 43ea205..b455d2f 100644 --- a/src/robotiq_2f/robotiq_2f_interface/include/robotiq_2f_interface/SocketAdapterBase.hpp +++ b/src/robotiq_2f/robotiq_2f_interface/include/robotiq_2f_interface/SocketAdapterBase.hpp @@ -1,4 +1,4 @@ -// IGripperAdapter.hpp +// SocketAdapterBase.hpp #ifndef SOCKET_ADAPTER_BASE_HPP #define SOCKET_ADAPTER_BASE_HPP diff --git a/src/robotiq_2f/robotiq_2f_interface/src/Robotiq2fSocketAdapter.cpp b/src/robotiq_2f/robotiq_2f_interface/src/Robotiq2fSocketAdapter.cpp index d1144e8..bac9d5e 100644 --- a/src/robotiq_2f/robotiq_2f_interface/src/Robotiq2fSocketAdapter.cpp +++ b/src/robotiq_2f/robotiq_2f_interface/src/Robotiq2fSocketAdapter.cpp @@ -37,7 +37,7 @@ bool Robotiq2fSocketAdapter::connect(const std::string& hostname, int port) { return false; } - if (::connect(sockfd_, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) { + if (::connect(*sockfd_, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) { std::cerr << "Connection to " << hostname << ":" << port << " failed: " << strerror(errno) << "\n"; close(*sockfd_); *sockfd_ = -1; @@ -344,20 +344,20 @@ std::tuple Robotiq2fSocketAdapter::move_and_wait_for_pos(int void Robotiq2fSocketAdapter::auto_calibrate(bool log=true) { // Open in case we are holding an object - std::tuple result = move_and_wait_for_pos(open_position, 64, 1); + std::tuple result = move_and_wait_for_pos(open_position_, 64, 1); if (std::get<1>(result) != ObjectStatus::AT_DEST) { throw std::runtime_error("Calibration failed opening to start."); } // Close as far as possible - result = move_and_wait_for_pos(closed_position, 64, 1); + result = move_and_wait_for_pos(closed_position_, 64, 1); if (std::get<1>(result) != ObjectStatus::AT_DEST) { throw std::runtime_error("Calibration failed because of an object."); } max_position_ = std::get<0>(result); // Update max position // Open as far as possible - result = move_and_wait_for_pos(open_position, 64, 1); + result = move_and_wait_for_pos(open_position_, 64, 1); if (std::get<1>(result) != ObjectStatus::AT_DEST) { throw std::runtime_error("Calibration failed because of an object."); }