mia_hand_driver  rel 1.0.0
mia_hand::CppDriver Class Reference

#include <cpp_driver.h>

Collaboration diagram for mia_hand::CppDriver:

Public Member Functions

 CppDriver ()
 Class constructor. More...
 
 ~CppDriver ()
 Class destructor. More...
 
bool connectToPort (uint16_t port_num)
 Open serial port used to plug Mia hand. More...
 
bool disconnect ()
 Disconnect the Mia hand closing the serial port. More...
 
bool isConnected ()
 Function returning the connection status of the Mia hand. More...
 
void setMotorPos (uint8_t fin_id, int16_t mot_pos)
 Set the target position of a specific motor of the Mia hand. More...
 
void setMotorSpe (uint8_t fin_id, int16_t mot_spe)
 Set the target velocity of a specific motor of the Mia hand. More...
 
void setFingerFor (uint8_t fin_id, int16_t fin_for)
 Set the target force of a specific motor of the Mia hand. More...
 
int16_t getMotorPos (uint8_t fin_id)
 Get the current position of a specific motor of the Mia hand. More...
 
int16_t getMotorSpe (uint8_t fin_id)
 Get the current velocity of a specific motor of the Mia hand. More...
 
int16_t getMotorCur (uint8_t fin_id)
 Get the current currently absorbed by a specific motor of the Mia hand. More...
 
void getFingerSgRaw (uint8_t fin_id, int16_t &nor_for, int16_t &tan_for)
 Get the current output of the force sensor of a specific finger of the Mia hand. More...
 
void openGrasp (char grasp_id)
 Go to rest pose of a grasp type Move all the Mia hand fingers to the rest pose of a specific grasp type. More...
 
void closeGrasp (char grasp_id)
 Go to closed pose of a grasp type Move all the Mia hand fingers to the closed pose of a specific grasp type. More...
 
void closeGrasp (char grasp_id, int16_t close_percent)
 Go to intermediate pose of a grasp type Move all the Mia hand fingers to a specific intermediate pose of a specific grasp type. More...
 
void setThuGraspRef (char grasp_id, int16_t rest, int16_t pos, int16_t delay)
 Set grasp parameter for thumb flexion motor. More...
 
void setIndGraspRef (char grasp_id, int16_t rest, int16_t pos, int16_t delay)
 Set grasp parameter for Index flexion + thumb abduction motor. More...
 
void setMrlGraspRef (char grasp_id, int16_t rest, int16_t pos, int16_t delay)
 Set grasp parameter for MRL flexion motor. More...
 
void switchPosStream (bool b_on_off)
 Manage the streaming of the motors position data. More...
 
void switchSpeStream (bool b_on_off)
 Manage the streaming of the motors velocity data. More...
 
void switchAnaStream (bool b_on_off)
 Manage the streaming of analog input data (as the straing gauge force sensors). More...
 
void switchCurStream (bool b_on_off)
 Manage the streaming of the current absorbed by Mi hand motors. More...
 

Private Member Functions

std::string numToStr (int16_t num, int8_t n_digits)
 Convert integer number into string. More...
 
void pollSerialPort ()
 Function of the serial_poll_trd_ thread. More...
 
void checkConnection ()
 Function of the check_connection_trd_ thread. More...
 

Private Attributes

SerialPort serial_port_
 Hanlder of the serial port_num. More...
 
std::thread serial_poll_trd_
 Thread to execute the parse of the data received by the Mia hand. More...
 
bool serial_trd_on_
 True if serial_poll_trd_ thread is running. More...
 
std::mutex finger_data_mtx_
 Mutex to handle the reading of the motors finger data. More...
 
std::thread check_connection_trd_
 Thread to execute the check of the Mia hand connection. More...
 
bool connection_trd_on_
 True if check_connection_trd_ thread is running. More...
 
bool is_checking_on_
 
std::mutex reply_mtx_
 
std::mutex connection_mtx_
 
FingerSerialInfo thumb_info_
 Info about the thumb flexion motor. More...
 
FingerSerialInfo index_info_
 Info about the index flexion motor. More...
 
FingerSerialInfo mrl_info_
 Info about the mrl flexion motor. More...
 
bool is_connected_
 True if the Mia hand is conncted, False otherwise. More...
 

Detailed Description

Definition at line 24 of file cpp_driver.h.

Constructor & Destructor Documentation

◆ CppDriver()

mia_hand::CppDriver::CppDriver ( )

Class constructor.

Definition at line 5 of file cpp_driver.cpp.

◆ ~CppDriver()

mia_hand::CppDriver::~CppDriver ( )

Class destructor.

Definition at line 22 of file cpp_driver.cpp.

Member Function Documentation

◆ checkConnection()

void mia_hand::CppDriver::checkConnection ( )
private

Function of the check_connection_trd_ thread.

While the check_connection_trd_ thread is active, check if the Mia hand is connected.

See also
check_connection_trd_

Definition at line 479 of file cpp_driver.cpp.

◆ closeGrasp() [1/2]

void mia_hand::CppDriver::closeGrasp ( char  grasp_id)

Go to closed pose of a grasp type Move all the Mia hand fingers to the closed pose of a specific grasp type.

Parameters
grasp_idType of grasp: 'C' cylindical, 'L' lateral, 'P' pinch, 'S' spherical, 'T' tridigital grasp.

Definition at line 284 of file cpp_driver.cpp.

◆ closeGrasp() [2/2]

void mia_hand::CppDriver::closeGrasp ( char  grasp_id,
int16_t  close_percent 
)

Go to intermediate pose of a grasp type Move all the Mia hand fingers to a specific intermediate pose of a specific grasp type.

Parameters
grasp_idType of grasp: 'C' cylindical, 'L' lateral, 'P' pinch, 'S' spherical, 'T' tridigital grasp.
close_percentPercentage of closure [0, 100].

Definition at line 292 of file cpp_driver.cpp.

◆ connectToPort()

bool mia_hand::CppDriver::connectToPort ( uint16_t  port_num)

Open serial port used to plug Mia hand.

Parameters
port_numnumber of the serial port to open.
Returns
True if the port has been opened, False otherwise.

Definition at line 30 of file cpp_driver.cpp.

◆ disconnect()

bool mia_hand::CppDriver::disconnect ( )

Disconnect the Mia hand closing the serial port.

Returns
True if the serial port has been closed, False otherwise.

Definition at line 37 of file cpp_driver.cpp.

◆ getFingerSgRaw()

void mia_hand::CppDriver::getFingerSgRaw ( uint8_t  fin_id,
int16_t &  nor_for,
int16_t &  tan_for 
)

Get the current output of the force sensor of a specific finger of the Mia hand.

Get the normal and tangential force signal output of the strain gauge included in the finger of the Mia hand

Parameters
fin_idMia hand finger id. 1 for thumb flexion, 2 for MRL flexion, 3 for index flexion + thumb abduction.
nor_forsensor output describing the normal force applied on the finger.
tan_forsensor output describing the tangential force applied on the finger.

Definition at line 238 of file cpp_driver.cpp.

◆ getMotorCur()

int16_t mia_hand::CppDriver::getMotorCur ( uint8_t  fin_id)

Get the current currently absorbed by a specific motor of the Mia hand.

Parameters
fin_idMia hand finger id. 1 for thumb flexion, 2 for MRL flexion, 3 for index flexion + thumb abduction.
Returns
position of the target motor as [0, +1024].

Definition at line 202 of file cpp_driver.cpp.

◆ getMotorPos()

int16_t mia_hand::CppDriver::getMotorPos ( uint8_t  fin_id)

Get the current position of a specific motor of the Mia hand.

Parameters
fin_idMia hand finger id. 1 for thumb flexion, 2 for MRL flexion, 3 for index flexion + thumb abduction.
Returns
position of the target motor as [-255, +255] for index motor and [0, 255] otherwise.

Definition at line 130 of file cpp_driver.cpp.

◆ getMotorSpe()

int16_t mia_hand::CppDriver::getMotorSpe ( uint8_t  fin_id)

Get the current velocity of a specific motor of the Mia hand.

Parameters
fin_idMia hand finger id. 1 for thumb flexion, 2 for MRL flexion, 3 for index flexion + thumb abduction.
Returns
position of the target motor as [-90, +90].

Definition at line 166 of file cpp_driver.cpp.

◆ isConnected()

bool mia_hand::CppDriver::isConnected ( )

Function returning the connection status of the Mia hand.

Returns
True if the Mia hand is attached to the sertial port, False otherwise.

Definition at line 51 of file cpp_driver.cpp.

◆ numToStr()

std::string mia_hand::CppDriver::numToStr ( int16_t  num,
int8_t  n_digits 
)
private

Convert integer number into string.

Parameters
numInteger number to be converted.
n_digitsNumber of digits of the integer to be converted.
Returns
string of the input integer.

Definition at line 453 of file cpp_driver.cpp.

◆ openGrasp()

void mia_hand::CppDriver::openGrasp ( char  grasp_id)

Go to rest pose of a grasp type Move all the Mia hand fingers to the rest pose of a specific grasp type.

Parameters
grasp_idType of grasp: 'C' cylindical, 'L' lateral, 'P' pinch, 'S' spherical, 'T' tridigital grasp.

Definition at line 276 of file cpp_driver.cpp.

◆ pollSerialPort()

void mia_hand::CppDriver::pollSerialPort ( )
private

Function of the serial_poll_trd_ thread.

While the serial_poll_trd_ thread is active, parse the data received from the Mia hand.

See also
serial_poll_trd_

Definition at line 468 of file cpp_driver.cpp.

◆ setFingerFor()

void mia_hand::CppDriver::setFingerFor ( uint8_t  fin_id,
int16_t  fin_for 
)

Set the target force of a specific motor of the Mia hand.

This function can be used to move specific Mia hand finger with force control.

Parameters
fin_idMia hand finger id. 1 for thumb flexion, 2 for MRL flexion, 3 for index flexion + thumb abduction.
fin_fortarget finger velocity [0, +1024]

Definition at line 108 of file cpp_driver.cpp.

◆ setIndGraspRef()

void mia_hand::CppDriver::setIndGraspRef ( char  grasp_id,
int16_t  rest,
int16_t  pos,
int16_t  delay 
)

Set grasp parameter for Index flexion + thumb abduction motor.

Parameters
grasp_idType of grasp to set: 'C' cylindical, 'L' lateral, 'P' pinch, 'S' spherical, 'T' tridigital grasp.
restRest reference position [0, 255].
posClosure reference position [0, 255].
delayTime delay in milliseconds. Used to delay the movement of the target motor of a percentage of the total time needed to perform the grasp.

Definition at line 347 of file cpp_driver.cpp.

◆ setMotorPos()

void mia_hand::CppDriver::setMotorPos ( uint8_t  fin_id,
int16_t  mot_pos 
)

Set the target position of a specific motor of the Mia hand.

This function can be used to move specific Mia hand finger in position.

Parameters
fin_idMia hand finger id. 1 for thumb flexion, 2 for MRL flexion, 3 for index flexion + thumb abduction.
mot_postarget finger position [-255, +255] for index and [0, +255] otherwise.

Definition at line 60 of file cpp_driver.cpp.

◆ setMotorSpe()

void mia_hand::CppDriver::setMotorSpe ( uint8_t  fin_id,
int16_t  mot_spe 
)

Set the target velocity of a specific motor of the Mia hand.

This function can be used to move a specific Mia hand finger in velocity.

Parameters
fin_idMia hand finger id. 1 for thumb flexion, 2 for MRL flexion, 3 for index flexion + thumb abduction.
mot_spetarget finger velocity [-90, +90].

Definition at line 84 of file cpp_driver.cpp.

◆ setMrlGraspRef()

void mia_hand::CppDriver::setMrlGraspRef ( char  grasp_id,
int16_t  rest,
int16_t  pos,
int16_t  delay 
)

Set grasp parameter for MRL flexion motor.

Parameters
grasp_idType of grasp to set: 'C' cylindical, 'L' lateral, 'P' pinch, 'S' spherical, 'T' tridigital grasp.
restRest reference position [0, 255].
posClosure reference position [0, 255].
delayTime delay in milliseconds. Used to delay the movement of the target motor of a percentage of the total time needed to perform the grasp.

Definition at line 380 of file cpp_driver.cpp.

◆ setThuGraspRef()

void mia_hand::CppDriver::setThuGraspRef ( char  grasp_id,
int16_t  rest,
int16_t  pos,
int16_t  delay 
)

Set grasp parameter for thumb flexion motor.

Parameters
grasp_idType of grasp to set: 'C' cylindical, 'L' lateral, 'P' pinch, 'S' spherical, 'T' tridigital grasp.
restRest reference position [0, 255].
posClosure reference position [0, 255].
delayTime delay in milliseconds. Used to delay the movement of the target motor of a percentage of the total time needed to perform the grasp.

Definition at line 314 of file cpp_driver.cpp.

◆ switchAnaStream()

void mia_hand::CppDriver::switchAnaStream ( bool  b_on_off)

Manage the streaming of analog input data (as the straing gauge force sensors).

Parameters
b_on_offTrue to enable the streaming, False to disable it.

Definition at line 433 of file cpp_driver.cpp.

◆ switchCurStream()

void mia_hand::CppDriver::switchCurStream ( bool  b_on_off)

Manage the streaming of the current absorbed by Mi hand motors.

Parameters
b_on_offTrue to enable the streaming, False to disable it.

Definition at line 443 of file cpp_driver.cpp.

◆ switchPosStream()

void mia_hand::CppDriver::switchPosStream ( bool  b_on_off)

Manage the streaming of the motors position data.

Parameters
b_on_offTrue to enable the streaming of the motors position data, False to disable it.

Definition at line 413 of file cpp_driver.cpp.

◆ switchSpeStream()

void mia_hand::CppDriver::switchSpeStream ( bool  b_on_off)

Manage the streaming of the motors velocity data.

Parameters
b_on_offTrue to enable the streaming, False to disable it.

Definition at line 423 of file cpp_driver.cpp.

Member Data Documentation

◆ check_connection_trd_

std::thread mia_hand::CppDriver::check_connection_trd_
private

Thread to execute the check of the Mia hand connection.

See also
checkConnection()

Definition at line 232 of file cpp_driver.h.

◆ connection_mtx_

std::mutex mia_hand::CppDriver::connection_mtx_
private

Definition at line 238 of file cpp_driver.h.

◆ connection_trd_on_

bool mia_hand::CppDriver::connection_trd_on_
private

True if check_connection_trd_ thread is running.

Definition at line 234 of file cpp_driver.h.

◆ finger_data_mtx_

std::mutex mia_hand::CppDriver::finger_data_mtx_
private

Mutex to handle the reading of the motors finger data.

Definition at line 225 of file cpp_driver.h.

◆ index_info_

FingerSerialInfo mia_hand::CppDriver::index_info_
private

Info about the index flexion motor.

Definition at line 241 of file cpp_driver.h.

◆ is_checking_on_

bool mia_hand::CppDriver::is_checking_on_
private

Definition at line 235 of file cpp_driver.h.

◆ is_connected_

bool mia_hand::CppDriver::is_connected_
private

True if the Mia hand is conncted, False otherwise.

Definition at line 244 of file cpp_driver.h.

◆ mrl_info_

FingerSerialInfo mia_hand::CppDriver::mrl_info_
private

Info about the mrl flexion motor.

Definition at line 242 of file cpp_driver.h.

◆ reply_mtx_

std::mutex mia_hand::CppDriver::reply_mtx_
private

Definition at line 237 of file cpp_driver.h.

◆ serial_poll_trd_

std::thread mia_hand::CppDriver::serial_poll_trd_
private

Thread to execute the parse of the data received by the Mia hand.

See also
pollSerialPort()

Definition at line 222 of file cpp_driver.h.

◆ serial_port_

SerialPort mia_hand::CppDriver::serial_port_
private

Hanlder of the serial port_num.

Definition at line 193 of file cpp_driver.h.

◆ serial_trd_on_

bool mia_hand::CppDriver::serial_trd_on_
private

True if serial_poll_trd_ thread is running.

Definition at line 224 of file cpp_driver.h.

◆ thumb_info_

FingerSerialInfo mia_hand::CppDriver::thumb_info_
private

Info about the thumb flexion motor.

Definition at line 240 of file cpp_driver.h.


The documentation for this class was generated from the following files: