34#include <visp3/core/vpConfig.h>
36#ifdef VISP_HAVE_TAKKTILE2
38#include <reflex_driver2.h>
40#include <visp3/core/vpMath.h>
41#include <visp3/robot/vpReflexTakktile2.h>
44#ifndef DOXYGEN_SHOULD_SKIP_THIS
45class vpReflexTakktile2::Impl :
public reflex_driver2::ReflexDriver
62 for (
size_t i = 0; i < NUM_FINGERS; i++) {
63 pressure[i].resize(NUM_SENSORS_PER_FINGER);
64 contact[i].resize(NUM_SENSORS_PER_FINGER);
70 load.resize(NUM_DYNAMIXELS);
83 for (
size_t i = 0; i < NUM_FINGERS; i++) {
84 os <<
"Finger " << i + 1 <<
": " << std::endl;
86 os <<
"\tProximal: " << hand.
proximal[i] << std::endl;
87 os <<
"\tDistal Approx: " << hand.
distal_approx[i] << std::endl;
89 os <<
"\tPressures: ";
90 for (
size_t j = 0; j < NUM_SENSORS_PER_FINGER; j++) {
96 for (
size_t j = 0; j < NUM_SENSORS_PER_FINGER; j++) {
97 os << hand.
contact[i][j] <<
", ";
101 os <<
"\tJoint Angle: " << hand.
joint_angle[i] <<
" rad" << std::endl;
103 os <<
"\tVelocity: " << hand.
velocity[i] <<
" rad/s" << std::endl;
104 os <<
"\tVelocity: " <<
vpMath::deg(
static_cast<double>(hand.
velocity[i])) <<
" deg/s" << std::endl;
105 os <<
"\tError State: " << hand.
error_state[i] << std::endl;
108 os <<
"Preshape: " << std::endl;
109 os <<
"\tJoint Angle: " << hand.
joint_angle[3] << std::endl;
110 os <<
"\tVelocity: " << hand.
velocity[3] << std::endl;
111 os <<
"\tError State: " << hand.
error_state[3] << std::endl;
144 for (
size_t i = 0; i < NUM_FINGERS; i++) {
145 m_hand_info.proximal[i] = m_impl->hand_info.proximal[i];
146 m_hand_info.distal_approx[i] = m_impl->hand_info.distal_approx[i];
147 for (
size_t j = 0; j < NUM_SENSORS_PER_FINGER; j++) {
148 m_hand_info.pressure[i][j] = m_impl->hand_info.pressure[i][j];
149 m_hand_info.contact[i][j] = m_impl->hand_info.contact[i][j];
152 for (
size_t i = 0; i < NUM_DYNAMIXELS; i++) {
153 m_hand_info.joint_angle[i] = m_impl->hand_info.joint_angle[i];
154 m_hand_info.raw_angle[i] = m_impl->hand_info.raw_angle[i];
155 m_hand_info.velocity[i] = m_impl->hand_info.velocity[i];
157 m_hand_info.voltage[i] = m_impl->hand_info.voltage[i];
158 m_hand_info.temperature[i] = m_impl->hand_info.temperature[i];
159 m_hand_info.error_state[i] = m_impl->hand_info.error_state[i];
187 for (
unsigned int i = 0; i < NUM_SERVOS; i++) {
188 position[i] =
static_cast<double>(m_impl->hand_info.joint_angle[i]);
200 for (
unsigned int i = 0; i < NUM_SERVOS; i++) {
201 velocity[i] =
static_cast<double>(m_impl->hand_info.velocity[i]);
216 if (targets.
size() != NUM_SERVOS) {
218 targets.
size(), NUM_SERVOS);
220 float targets_[NUM_SERVOS];
221 for (
unsigned int i = 0; i < NUM_SERVOS; i++) {
222 targets_[i] =
static_cast<float>(targets[i]);
224 m_impl->set_angle_position(targets_);
244 if (thresholds.size() != NUM_FINGERS * NUM_SENSORS_PER_FINGER) {
246 thresholds.size(), NUM_FINGERS * NUM_SENSORS_PER_FINGER);
248 int thresholds_[NUM_FINGERS * NUM_SENSORS_PER_FINGER];
249 for (
size_t i = 0; i < NUM_FINGERS * NUM_SENSORS_PER_FINGER; i++) {
250 thresholds_[i] = thresholds[i];
253 m_impl->set_tactile_thresholds(thresholds_);
264 if (targets.
size() != NUM_SERVOS) {
266 targets.
size(), NUM_SERVOS);
268 float targets_[NUM_SERVOS];
269 for (
unsigned int i = 0; i < NUM_SERVOS; i++) {
270 targets_[i] =
static_cast<float>(targets[i]);
272 m_impl->set_motor_speed(targets_);
282 if (targets.
size() != NUM_SERVOS) {
284 targets.
size(), NUM_SERVOS);
286 float targets_[NUM_SERVOS];
287 for (
unsigned int i = 0; i < NUM_SERVOS; i++) {
288 targets_[i] =
static_cast<float>(targets[i]);
290 m_impl->move_until_any_contact(targets_);
300 if (targets.
size() != NUM_SERVOS) {
302 targets.
size(), NUM_SERVOS);
304 float targets_[NUM_SERVOS];
305 for (
unsigned int i = 0; i < NUM_SERVOS; i++) {
306 targets_[i] =
static_cast<float>(targets[i]);
308 m_impl->move_until_each_contact(targets_);
317 reflex_hand2::ReflexHandState *state = &m_impl->rh->rx_state_;
318 m_impl->rh->setStateCallback(std::bind(&reflex_driver2::ReflexDriver::reflex_hand_state_cb, m_impl, state));
unsigned int size() const
Return the number of elements of the 2D array.
Implementation of column vector and the associated operations.
error that can be emitted by ViSP classes.
@ dimensionError
Bad dimension.
static double deg(double rad)
std::vector< uint32_t > temperature
std::vector< float > joint_angle
std::vector< std::vector< bool > > contact
std::vector< std::vector< int > > pressure
std::vector< std::string > error_state
std::vector< float > load
std::vector< float > raw_angle
std::vector< float > proximal
std::vector< float > voltage
std::vector< float > distal_approx
std::vector< float > velocity
friend VISP_EXPORT std::ostream & operator<<(std::ostream &os, const HandInfo &hand)
void setVelocityUntilAnyContact(const vpColVector &targets)
std::string m_finger_file_name
void setVelocityUntilEachContact(const vpColVector &targets)
std::string m_tactile_file_name
void setTactileThreshold(int threshold)
std::string m_network_interface
vpColVector getVelocity() const
void setPosition(const vpColVector &targets)
int getNumFingers() const
void setPositioningVelocity(const vpColVector &targets)
std::string m_motor_file_name
vpColVector getPosition() const
virtual ~vpReflexTakktile2()
int getNumSensorsPerFinger() const
void wait(int milliseconds)