36 #include <visp3/core/vpConfig.h>
38 #ifdef VISP_HAVE_TAKKTILE2
40 #include <reflex_driver2.h>
42 #include <visp3/core/vpMath.h>
43 #include <visp3/robot/vpReflexTakktile2.h>
46 #ifndef DOXYGEN_SHOULD_SKIP_THIS
47 class vpReflexTakktile2::Impl :
public reflex_driver2::ReflexDriver
64 for (
size_t i = 0; i < NUM_FINGERS; i++) {
65 pressure[i].resize(NUM_SENSORS_PER_FINGER);
66 contact[i].resize(NUM_SENSORS_PER_FINGER);
72 load.resize(NUM_DYNAMIXELS);
85 for (
size_t i = 0; i < NUM_FINGERS; i++) {
86 os <<
"Finger " << i + 1 <<
": " << std::endl;
88 os <<
"\tProximal: " << hand.
proximal[i] << std::endl;
89 os <<
"\tDistal Approx: " << hand.
distal_approx[i] << std::endl;
91 os <<
"\tPressures: ";
92 for (
size_t j = 0; j < NUM_SENSORS_PER_FINGER; j++) {
98 for (
size_t j = 0; j < NUM_SENSORS_PER_FINGER; j++) {
99 os << hand.
contact[i][j] <<
", ";
103 os <<
"\tJoint Angle: " << hand.
joint_angle[i] <<
" rad" << std::endl;
105 os <<
"\tVelocity: " << hand.
velocity[i] <<
" rad/s" << std::endl;
106 os <<
"\tVelocity: " <<
vpMath::deg(
static_cast<double>(hand.
velocity[i])) <<
" deg/s" << std::endl;
107 os <<
"\tError State: " << hand.
error_state[i] << std::endl;
110 os <<
"Preshape: " << std::endl;
111 os <<
"\tJoint Angle: " << hand.
joint_angle[3] << std::endl;
112 os <<
"\tVelocity: " << hand.
velocity[3] << std::endl;
113 os <<
"\tError State: " << hand.
error_state[3] << std::endl;
146 for (
size_t i = 0; i < NUM_FINGERS; i++) {
149 for (
size_t j = 0; j < NUM_SENSORS_PER_FINGER; j++) {
154 for (
size_t i = 0; i < NUM_DYNAMIXELS; i++) {
189 for (
unsigned int i = 0; i < NUM_SERVOS; i++) {
190 position[i] =
static_cast<double>(m_impl->hand_info.joint_angle[i]);
202 for (
unsigned int i = 0; i < NUM_SERVOS; i++) {
203 velocity[i] =
static_cast<double>(m_impl->hand_info.velocity[i]);
218 if (targets.
size() != NUM_SERVOS) {
220 targets.
size(), NUM_SERVOS);
222 float targets_[NUM_SERVOS];
223 for (
unsigned int i = 0; i < NUM_SERVOS; i++) {
224 targets_[i] =
static_cast<float>(targets[i]);
226 m_impl->set_angle_position(targets_);
246 if (thresholds.size() != NUM_FINGERS * NUM_SENSORS_PER_FINGER) {
248 thresholds.size(), NUM_FINGERS * NUM_SENSORS_PER_FINGER);
250 int thresholds_[NUM_FINGERS * NUM_SENSORS_PER_FINGER];
251 for (
size_t i = 0; i < NUM_FINGERS * NUM_SENSORS_PER_FINGER; i++) {
252 thresholds_[i] = thresholds[i];
255 m_impl->set_tactile_thresholds(thresholds_);
266 if (targets.
size() != NUM_SERVOS) {
268 targets.
size(), NUM_SERVOS);
270 float targets_[NUM_SERVOS];
271 for (
unsigned int i = 0; i < NUM_SERVOS; i++) {
272 targets_[i] =
static_cast<float>(targets[i]);
274 m_impl->set_motor_speed(targets_);
284 if (targets.
size() != NUM_SERVOS) {
286 targets.
size(), NUM_SERVOS);
288 float targets_[NUM_SERVOS];
289 for (
unsigned int i = 0; i < NUM_SERVOS; i++) {
290 targets_[i] =
static_cast<float>(targets[i]);
292 m_impl->move_until_any_contact(targets_);
302 if (targets.
size() != NUM_SERVOS) {
304 targets.
size(), NUM_SERVOS);
306 float targets_[NUM_SERVOS];
307 for (
unsigned int i = 0; i < NUM_SERVOS; i++) {
308 targets_[i] =
static_cast<float>(targets[i]);
310 m_impl->move_until_each_contact(targets_);
319 reflex_hand2::ReflexHandState *state = &m_impl->rh->rx_state_;
320 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
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)