Visual Servoing Platform
version 3.4.0
|
#include <vpQbSoftHand.h>
Public Member Functions | |
vpQbSoftHand () | |
virtual | ~vpQbSoftHand () |
void | getCurrent (vpColVector ¤t, const int &id=1) |
void | getPosition (vpColVector &position, const int &id=1) |
void | setPosition (const vpColVector &position, const int &id=1) |
void | setPosition (const vpColVector &position, double speed_factor, double stiffness, const int &id=1) |
Inherited public functionalities from vpQbDevice | |
double | getCurrentMax () const |
std::vector< short int > | getPositionLimits () const |
void | setMaxRepeats (const int &max_repeats) |
Protected Member Functions | |
Inherited protected functionalities from vpQbDevice | |
virtual int | activate (const int &id, const bool &command, const int &max_repeats) |
virtual int | activate (const int &id, const int &max_repeats) |
virtual bool | close (const std::string &serial_port) |
virtual int | deactivate (const int &id, const int &max_repeats) |
virtual int | getCurrents (const int &id, const int &max_repeats, std::vector< short int > ¤ts) |
virtual int | getInfo (const int &id, const int &max_repeats, std::string &info) |
virtual int | getMeasurements (const int &id, const int &max_repeats, std::vector< short int > ¤ts, std::vector< short int > &positions) |
virtual int | getParameters (const int &id, std::vector< int > &limits, std::vector< int > &resolutions) |
virtual int | getPositions (const int &id, const int &max_repeats, std::vector< short int > &positions) |
virtual int | getSerialPortsAndDevices (const int &max_repeats) |
virtual bool | init (const int &id) |
virtual int | isActive (const int &id, const int &max_repeats, bool &status) |
int | isConnected (const int &id, const int &max_repeats) |
virtual bool | isInConnectedSet (const int &id) |
virtual bool | isInOpenMap (const std::string &serial_port) |
bool | isReliable (int const &failures, int const &max_repeats) |
virtual int | open (const std::string &serial_port) |
virtual int | setCommandsAndWait (const int &id, const int &max_repeats, std::vector< short int > &commands) |
virtual int | setCommandsAsync (const int &id, std::vector< short int > &commands) |
Protected Attributes | |
int | m_max_repeats |
bool | m_init_done |
Interface for qbSoftHand device.
See https://qbrobotics.com/ for more details.
The following example shows how to close and open the SoftHand with a given speed factor and stiffness used to stop the command applied to the motors when the measured current is larger than the stiffness multiplied by the maximum allowed current that can be applied to the motors.
Definition at line 93 of file vpQbSoftHand.h.
vpQbSoftHand::vpQbSoftHand | ( | ) |
Default constructor that does nothing. To connect to a device call init().
Definition at line 50 of file vpQbSoftHand.cpp.
|
virtual |
Close all the still open serial ports.
Definition at line 59 of file vpQbSoftHand.cpp.
|
protectedvirtualinherited |
Activate (or deactivate, according to the given command) the motors of the given device. Do nothing if the device is not connected in the Communication Handler.
id | The ID of the device to be activated (or deactivated), in range [1 , 128 ]. |
command | true to turn motors on, false to turn them off. |
max_repeats | The maximum number of consecutive repetitions to mark retrieved data as corrupted. |
Definition at line 499 of file vpQbDevice.cpp.
|
protectedvirtualinherited |
Activate the motors of the given device. Do nothing if the device is not connected in the Communication Handler.
id | The ID of the device to be activated, in range [1 , 128 ]. |
max_repeats | The maximum number of consecutive repetitions to mark retrieved data as corrupted. |
Definition at line 510 of file vpQbDevice.cpp.
|
protectedvirtualinherited |
Close the communication with all the devices connected to the given serial port.
serial_port | The serial port which has to be closed, e.g. /dev/ttyUSB* (Unix), /dev/tty .usbserial-* (MacOS) or COM* (Windows). |
Definition at line 521 of file vpQbDevice.cpp.
|
protectedvirtualinherited |
Deactivate the motors of the given device. Do nothing if the device is not connected in the Communication Handler.
id | The ID of the device to be deactivated, in range [1 , 128 ]. |
max_repeats | The maximum number of consecutive repetitions to mark retrieved data as corrupted. |
Definition at line 532 of file vpQbDevice.cpp.
void vpQbSoftHand::getCurrent | ( | vpColVector & | current, |
const int & | id = 1 |
||
) |
Retrieve the motor currents of the given device.
id | The ID of the device of interest, in range [1 , 128 ]. | |
[out] | current | The one-element device motor current vector, expressed in mA. |
Definition at line 68 of file vpQbSoftHand.cpp.
References vpException::fatalError, vpQbDevice::getCurrents(), vpQbDevice::init(), vpQbDevice::isInConnectedSet(), vpQbDevice::isReliable(), vpQbDevice::m_init_done, vpQbDevice::m_max_repeats, and vpColVector::resize().
Referenced by setPosition().
|
inherited |
Return the maximum current supported by the device.
Definition at line 540 of file vpQbDevice.cpp.
Referenced by setPosition().
|
protectedvirtualinherited |
Retrieve the motor currents of the given device.
id | The ID of the device of interest, in range [1 , 128 ]. | |
max_repeats | The maximum number of consecutive repetitions to mark retrieved data as corrupted. | |
[out] | currents | The two-element device motor current vector, expressed in mA: if the device is a qbhand only the first element is filled while the other remains always 0 ; in the case of a qbmove both the elements contain relevant data, i.e. the currents respectively of motor_1 and motor_2 . |
0
on success. Definition at line 555 of file vpQbDevice.cpp.
Referenced by getCurrent().
|
protectedvirtualinherited |
Retrieve the printable configuration setup of the given device.
id | The ID of the device of interest, in range [1 , 128 ]. |
max_repeats | The maximum number of consecutive repetitions to mark retrieved data as corrupted. |
info | The configuration setup formatted as a plain text string (empty string on communication error). |
0
and max_repeats
. Definition at line 568 of file vpQbDevice.cpp.
|
protectedvirtualinherited |
Retrieve the motor currents of the given device.
id | The ID of the device of interest, in range [1 , 128 ]. | |
[out] | currents | The two-element device motor current vector, expressed in mA: if the device is a qbhand only the first element is filled while the other remains always 0 ; in the case of a qbmove both the elements contain relevant data, i.e. the currents respectively of motor_1 and motor_2 . |
[out] | positions | The device position vector, expressed in ticks: if the device is a qbhand only the first element is filled while the others remain always 0 ; in the case of a qbmove all the elements contain relevant data, i.e. the positions respectively of motor_1 , motor_2 and motor_shaft (which is not directly actuated). |
max_repeats | The maximum number of consecutive repetitions to mark retrieved data as corrupted. |
0
and max_repeats
. Definition at line 587 of file vpQbDevice.cpp.
|
protectedvirtualinherited |
Retrieve some of the parameters from the given device.
id | The ID of the device of interest, in range [1 , 128 ]. | |
[out] | limits | The vector of motor position limits expressed in ticks: two values for each motor, respectively [lower_limit , upper_limit ]. |
[out] | resolutions | The vector of encoder resolutions, each in range [0 , 8 ]: one value for each encoder (note: the qbmove has also the shaft encoder even if it is not actuated). The word "resolution" could be misunderstood: taken the resolution r , is the number of turns of the wire inside the device mechanics. It is used essentially to convert the measured position of the motors in ticks to radians or degrees. |
0
on success. Definition at line 604 of file vpQbDevice.cpp.
void vpQbSoftHand::getPosition | ( | vpColVector & | position, |
const int & | id = 1 |
||
) |
Retrieve the motor position of the given device.
id | The ID of the device of interest, in range [1 , 128 ]. | |
[out] | position | The device one-element position vector, expressed in range [0 , 1 ] with 0 corresponding to an opened hand and 1 a closed hand. |
Definition at line 94 of file vpQbSoftHand.cpp.
References vpException::fatalError, vpQbDevice::getPositionLimits(), vpQbDevice::getPositions(), vpQbDevice::init(), vpQbDevice::isInConnectedSet(), vpQbDevice::isReliable(), vpQbDevice::m_init_done, vpQbDevice::m_max_repeats, and vpColVector::resize().
Referenced by setPosition().
|
inherited |
Definition at line 612 of file vpQbDevice.cpp.
Referenced by getPosition(), and setPosition().
|
protectedvirtualinherited |
Retrieve the motor positions of the given device.
id | The ID of the device of interest, in range [1 , 128 ]. | |
[out] | positions | The device position vector, expressed in ticks: if the device is a qbhand only the first element is filled while the others remain always 0 ; in the case of a qbmove all the elements contain relevant data, i.e. the positions respectively of motor_1 , motor_2 and motor_shaft (which is not directly actuated). |
max_repeats | The maximum number of consecutive repetitions to mark retrieved data as corrupted. |
0
and max_repeats
. Definition at line 628 of file vpQbDevice.cpp.
Referenced by getPosition().
|
protectedvirtualinherited |
Scan for all the serial ports of type /dev/ttyUSB*
detected in the system, initialize their mutex protector (each serial port connected to the system has to be accessed in a mutually exclusive fashion), and retrieve all the qbrobotics devices connected to them. For each device, store its ID in the private map m_connected_devices
, i.e. insert a pair [device_id
, serial_port
]. The map m_connected_devices
is constructed from scratch at each call.
max_repeats | The maximum number of consecutive repetitions to mark retrieved data as corrupted. |
Definition at line 643 of file vpQbDevice.cpp.
|
protectedvirtualinherited |
Initialize the device if the relative physical device is connected through any serial port to the system. If the device is found, retrieve some of its parameter and activate its motors, if requested.
id | The ID of the device of interest, in range [1 , 128 ]. |
true
if the call succeed. Definition at line 655 of file vpQbDevice.cpp.
References vpQbDevice::m_init_done.
Referenced by getCurrent(), getPosition(), and setPosition().
|
protectedvirtualinherited |
Check whether the motors of the device specified by the given ID are active.
id | The ID of the device of interest, in range [1 , 128 ]. |
max_repeats | The maximum number of consecutive repetitions to mark retrieved data as corrupted. |
status | true if the device motors are on. |
0
and max_repeats
. Definition at line 672 of file vpQbDevice.cpp.
|
protectedinherited |
Check whether the the device specified by the given ID is connected through the serial port.
id | The ID of the device of interest, in range [1 , 128 ]. |
max_repeats | The maximum number of consecutive repetitions to mark retrieved data as corrupted. |
0
and max_repeats
. Definition at line 683 of file vpQbDevice.cpp.
|
protectedvirtualinherited |
Check whether the physical device specified by the given ID is connected to the Communication Handler.
id | The ID of the device of interest, in range [1 , 128 ]. |
true
if the given device belongs to the connected device vector, i.e. m_connected_devices
. Definition at line 694 of file vpQbDevice.cpp.
Referenced by getCurrent(), getPosition(), and setPosition().
|
protectedvirtualinherited |
Check whether the given serial port is managed by the communication handler, i.e. is open.
serial_port | The name of the serial port of interest, e.g. /dev/ttyUSB0 . |
true
if the given serial port belongs to the open file descriptor map, i.e. m_file_descriptors
. Definition at line 705 of file vpQbDevice.cpp.
|
protectedinherited |
Check whether the reading failures are in the given range.
failures | The current number of communication failures per serial resource reading. |
max_repeats | The maximum number of consecutive repetitions to mark retrieved data as corrupted. |
true
if the failures are less than the given threshold. Definition at line 716 of file vpQbDevice.cpp.
Referenced by getCurrent(), getPosition(), and setPosition().
|
protectedvirtualinherited |
Open the serial communication on the given serial port. On success, store the opened file descriptor in the private map m_file_descriptors
, i.e. insert a pair [serial_port
, file_descriptor
].
serial_port | The serial port which has to be opened, e.g. /dev/ttyUSB0 . |
0
on success. Definition at line 728 of file vpQbDevice.cpp.
|
protectedvirtualinherited |
Send the reference command to the motors of the given device and wait for acknowledge.
id | The ID of the device of interest, in range [1 , 128 ]. |
max_repeats | The maximum number of consecutive repetitions to mark retrieved data as corrupted. |
commands | The reference command vector, expressed in ticks: if the device is a qbhand only the first element is meaningful while the other remains always 0 ; in the case of a qbmove both the elements contain relevant data, i.e. the commands respectively of motor_1 and motor_2 . |
0
on success. Definition at line 742 of file vpQbDevice.cpp.
|
protectedvirtualinherited |
Send the reference command to the motors of the given device in a non-blocking fashion.
id | The ID of the device of interest, in range [1 , 128 ]. |
commands | The reference command vector, expressed in ticks: if the device is a qbhand only the first element is meaningful while the other remains always 0 ; in the case of a qbmove both the elements contain relevant data, i.e. the commands respectively of motor_1 and motor_2 . |
0
(note that this is a non reliable method). Definition at line 755 of file vpQbDevice.cpp.
Referenced by setPosition().
|
inherited |
Set the maximum number of consecutive repetitions to mark retrieved data as corrupted. This value is set by default to 1.
Definition at line 763 of file vpQbDevice.cpp.
References vpQbDevice::m_max_repeats.
Referenced by vpQbDevice::vpQbDevice().
void vpQbSoftHand::setPosition | ( | const vpColVector & | position, |
const int & | id = 1 |
||
) |
Send the reference command to the motors of the device with given id in a non-blocking fashion.
id | The ID of the device of interest, in range [1 , 128 ]. |
position | The one-element position vector in range [0 , 1 ] with 0 corresponding to an opened hand and 1 a closed hand. |
Definition at line 120 of file vpQbSoftHand.cpp.
References vpException::fatalError, vpQbDevice::getPositionLimits(), vpQbDevice::init(), vpQbDevice::isInConnectedSet(), vpQbDevice::isReliable(), vpQbDevice::m_init_done, vpQbDevice::m_max_repeats, vpQbDevice::setCommandsAsync(), and vpArray2D< Type >::size().
Referenced by setPosition().
void vpQbSoftHand::setPosition | ( | const vpColVector & | position, |
double | speed_factor, | ||
double | stiffness, | ||
const int & | id = 1 |
||
) |
Send the reference command to the motors of the device with given id in a blocking fashion.
id | The ID of the device of interest, in range [1 , 128 ]. |
position | The one-element position vector in range [0 , 1 ] with 0 corresponding to an opened hand and 1 a closed hand. |
speed_factor | The speed factor in range [0.01 , 1 ] with 1 corresponding to the fastest mouvement. |
stiffness | Stiffness parameter in range [0 , 1 ] is the scale factor applied to the maximum allowed current in order to limit the current into the motors. When set at zero, you can send any position command to the motors, but he will not move. When set to 1, it means that the maximum current returned by getCurrentMax() could be reached during positionning. |
Definition at line 163 of file vpQbSoftHand.cpp.
References vpMath::equal(), getCurrent(), vpQbDevice::getCurrentMax(), getPosition(), vpQbDevice::getPositionLimits(), vpTime::measureTimeMs(), setPosition(), and vpTime::wait().
|
protectedinherited |
Flag used to indicate if the device is initialized.
Definition at line 115 of file vpQbDevice.h.
Referenced by getCurrent(), getPosition(), vpQbDevice::init(), and setPosition().
|
protectedinherited |
Max number of trials to send a command.
Definition at line 114 of file vpQbDevice.h.
Referenced by getCurrent(), getPosition(), vpQbDevice::setMaxRepeats(), and setPosition().