debugging

This commit is contained in:
Niko Feith 2024-04-11 18:42:12 +02:00
parent 719502e631
commit 7858d6ef12
4 changed files with 10 additions and 6 deletions

View File

@ -8,6 +8,8 @@
#include <atomic> #include <atomic>
#include <tuple> #include <tuple>
#include "robotiq_2f_interface/SocketAdapterBase.hpp"
namespace robotiq{ namespace robotiq{
class MockRobotiq2fSocketAdapter : public SocketAdapterBase { class MockRobotiq2fSocketAdapter : public SocketAdapterBase {
public: public:

View File

@ -25,6 +25,8 @@
#include <cerrno> // For errno #include <cerrno> // For errno
#include <iostream> #include <iostream>
#include "robotiq_2f_interface/SocketAdapterBase.hpp"
namespace robotiq{ namespace robotiq{
// Enum for Gripper Status // Enum for Gripper Status
enum class GripperStatus { 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 * @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. * active state, or if the calibration sequence fails.
*/ */
void auto_calibrate(bool log=true) override; void auto_calibrate(bool log=true);
/** /**
* Deactivates the gripper. * Deactivates the gripper.

View File

@ -1,4 +1,4 @@
// IGripperAdapter.hpp // SocketAdapterBase.hpp
#ifndef SOCKET_ADAPTER_BASE_HPP #ifndef SOCKET_ADAPTER_BASE_HPP
#define SOCKET_ADAPTER_BASE_HPP #define SOCKET_ADAPTER_BASE_HPP

View File

@ -37,7 +37,7 @@ bool Robotiq2fSocketAdapter::connect(const std::string& hostname, int port) {
return false; 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"; std::cerr << "Connection to " << hostname << ":" << port << " failed: " << strerror(errno) << "\n";
close(*sockfd_); close(*sockfd_);
*sockfd_ = -1; *sockfd_ = -1;
@ -344,20 +344,20 @@ std::tuple<int, ObjectStatus> Robotiq2fSocketAdapter::move_and_wait_for_pos(int
void Robotiq2fSocketAdapter::auto_calibrate(bool log=true) { void Robotiq2fSocketAdapter::auto_calibrate(bool log=true) {
// Open in case we are holding an object // Open in case we are holding an object
std::tuple<int, ObjectStatus> result = move_and_wait_for_pos(open_position, 64, 1); std::tuple<int, ObjectStatus> result = move_and_wait_for_pos(open_position_, 64, 1);
if (std::get<1>(result) != ObjectStatus::AT_DEST) { if (std::get<1>(result) != ObjectStatus::AT_DEST) {
throw std::runtime_error("Calibration failed opening to start."); throw std::runtime_error("Calibration failed opening to start.");
} }
// Close as far as possible // 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) { if (std::get<1>(result) != ObjectStatus::AT_DEST) {
throw std::runtime_error("Calibration failed because of an object."); throw std::runtime_error("Calibration failed because of an object.");
} }
max_position_ = std::get<0>(result); // Update max position max_position_ = std::get<0>(result); // Update max position
// Open as far as possible // 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) { if (std::get<1>(result) != ObjectStatus::AT_DEST) {
throw std::runtime_error("Calibration failed because of an object."); throw std::runtime_error("Calibration failed because of an object.");
} }