Visual Servoing Platform
version 3.6.1 under development (2024-11-15)
|
#include <visp3/robot/vpQbDevice.h>
Public Member Functions | |
vpQbDevice () | |
virtual | ~vpQbDevice () |
Inherited public functionalities from vpQbDevice | |
double | getCurrentMax () const |
std::vector< short int > | getPositionLimits () const |
void | setMaxRepeats (const int &max_repeats) |
Inherited protected functionalities from vpQbDevice | |
int | m_max_repeats |
bool | m_init_done |
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) |
Interface for qbrobotics devices.
See https://qbrobotics.com/ for more details.
This class was tested with the qbSoftHand.
Definition at line 61 of file vpQbDevice.h.
BEGIN_VISP_NAMESPACE vpQbDevice::vpQbDevice | ( | ) |
Default constructor that does nothing. To connect to a device call init().
Definition at line 481 of file vpQbDevice.cpp.
References setMaxRepeats().
|
virtual |
Close all the still open serial ports.
Definition at line 487 of file vpQbDevice.cpp.
|
protectedvirtual |
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 497 of file vpQbDevice.cpp.
|
protectedvirtual |
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 508 of file vpQbDevice.cpp.
|
protectedvirtual |
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 516 of file vpQbDevice.cpp.
|
protectedvirtual |
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 524 of file vpQbDevice.cpp.
double vpQbDevice::getCurrentMax | ( | ) | const |
Return the maximum current supported by the device.
Definition at line 529 of file vpQbDevice.cpp.
Referenced by vpQbSoftHand::setPosition().
|
protectedvirtual |
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 541 of file vpQbDevice.cpp.
Referenced by vpQbSoftHand::getCurrent().
|
protectedvirtual |
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 554 of file vpQbDevice.cpp.
|
protectedvirtual |
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 573 of file vpQbDevice.cpp.
|
protectedvirtual |
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 591 of file vpQbDevice.cpp.
std::vector< short int > vpQbDevice::getPositionLimits | ( | ) | const |
Definition at line 599 of file vpQbDevice.cpp.
Referenced by vpQbSoftHand::getPosition(), and vpQbSoftHand::setPosition().
|
protectedvirtual |
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 612 of file vpQbDevice.cpp.
Referenced by vpQbSoftHand::getPosition().
|
protectedvirtual |
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 627 of file vpQbDevice.cpp.
|
protectedvirtual |
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 639 of file vpQbDevice.cpp.
References m_init_done.
Referenced by vpQbSoftHand::getCurrent(), vpQbSoftHand::getPosition(), and vpQbSoftHand::setPosition().
|
protectedvirtual |
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 656 of file vpQbDevice.cpp.
|
protected |
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 667 of file vpQbDevice.cpp.
|
protectedvirtual |
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 675 of file vpQbDevice.cpp.
Referenced by vpQbSoftHand::getCurrent(), vpQbSoftHand::getPosition(), and vpQbSoftHand::setPosition().
|
protectedvirtual |
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 683 of file vpQbDevice.cpp.
|
protected |
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 691 of file vpQbDevice.cpp.
Referenced by vpQbSoftHand::getCurrent(), vpQbSoftHand::getPosition(), and vpQbSoftHand::setPosition().
|
protectedvirtual |
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 703 of file vpQbDevice.cpp.
|
protectedvirtual |
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 714 of file vpQbDevice.cpp.
|
protectedvirtual |
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 727 of file vpQbDevice.cpp.
Referenced by vpQbSoftHand::setPosition().
void vpQbDevice::setMaxRepeats | ( | const int & | max_repeats | ) |
Set the maximum number of consecutive repetitions to mark retrieved data as corrupted. This value is set by default to 1.
Definition at line 736 of file vpQbDevice.cpp.
References m_max_repeats.
Referenced by vpQbDevice().
|
protected |
Flag used to indicate if the device is initialized.
Definition at line 114 of file vpQbDevice.h.
Referenced by vpQbSoftHand::getCurrent(), vpQbSoftHand::getPosition(), init(), and vpQbSoftHand::setPosition().
|
protected |
Max number of trials to send a command.
Definition at line 113 of file vpQbDevice.h.
Referenced by vpQbSoftHand::getCurrent(), vpQbSoftHand::getPosition(), setMaxRepeats(), and vpQbSoftHand::setPosition().