HerkuleXLib
1.2
Arduino library to drive HerkuleX DRS-0101 and DRS-0201
|
Class to drive one servo in continuous rotation mode. More...
#include <HkxContRotation.h>
Public Member Functions | |
HkxContRotation (uint8_t ID, HkxCommunication &herkXCom, HkxPrint &print) | |
Constructor. More... | |
uint8_t | getID () const |
Get the ID. More... | |
hkxTorqueControl | getTorqueControl () const |
Get torque control. More... | |
hkxLEDControl | getLEDControl () const |
Get LED control. More... | |
boolean | isStopped () |
Check if the servo stopped. More... | |
uint8_t | getStatus (HkxStatus &statusED, boolean update) |
Get the status. More... | |
uint8_t | clearStatus () |
Clear the status. More... | |
uint8_t | setTorqueLEDControl (HkxMaybe< hkxTorqueControl > newTorqueControl, HkxMaybe< hkxLEDControl > newLEDControl) |
Set torque actuation and LED colour. More... | |
uint8_t | moveRotation (int16_t pwm, HkxMaybe< uint16_t > playTime, HkxMaybe< hkxLEDControl > LEDControl) |
Move continuous rotation. More... | |
uint8_t | getBehaviour (HkxMaybe< uint16_t > inputVoltage, HkxMaybe< uint16_t > temperature, HkxMaybe< int16_t > velocity, HkxMaybe< int16_t > PWM) |
Get the servo behaviour. More... | |
uint8_t | reboot () |
Reboot servo. More... | |
Private Attributes | |
HkxCommunication & | _herkXCom |
HkxPrint & | _print |
boolean | _connected |
uint8_t | _id |
hkxTorqueControl | _torqueControl |
hkxLEDControl | _ledControl |
HkxStatus | _statusED |
Class to drive one servo in continuous rotation mode.
This class allows to drive one servo in continuous rotation mode.
HkxContRotation::HkxContRotation | ( | uint8_t | ID, |
HkxCommunication & | herkXCom, | ||
HkxPrint & | |||
) |
Constructor.
The constructor of HkxContRotation.
[in] | ID | : id of the servo to drive. The value shall be [0 ; 253]. |
[in] | herkXCom | : Communication with the servos. |
[in] | : Communication to print messages. |
Example:
uint8_t HkxContRotation::clearStatus | ( | ) |
Clear the status.
Clear the status of the servo to leave the "error state" and stop the LED blink and torque deactivation (see p.33 of the user manual for more details about LED and torque policies).
Example:
uint8_t HkxContRotation::getBehaviour | ( | HkxMaybe< uint16_t > | inputVoltage, |
HkxMaybe< uint16_t > | temperature, | ||
HkxMaybe< int16_t > | velocity, | ||
HkxMaybe< int16_t > | PWM | ||
) |
Get the servo behaviour.
Get the current servo behaviour. See the user manual for more details about the parameters.
[out] | inputVoltage | : Current servo input voltage. Its value is given in millivolts. This parameter is optional, either set the address of a uint16_t (or unsigned int ) variable to return the value, or set HKX_NO_VALUE to ignore it. |
[out] | temperature | : Current temperature of the servo. Its value is given in 10^-2 °C (degree Celsius). This parameter is optional, either set the address of a uint16_t (or unsigned int ) variable to return the value, or set HKX_NO_VALUE to ignore it. |
[out] | velocity | : Current angle velocity of the servo. Its value is given in degree / second. This parameter is optional, either set the address of a uint16_t (or unsigned int ) variable to return the value, or set HKX_NO_VALUE to ignore it. |
[out] | PWM | : Current PWM (load) of the servo. Its value is given in PWM (raw). This parameter is optional, either set the address of a int16_t (or int ) variable to return the value, or set HKX_NO_VALUE to ignore it. |
Example 1: How to get all the values.
Example 2: How to get the current velocity only.
|
inline |
Get the ID.
Get the ID of the driven servo.
Example:
|
inline |
Get LED control.
Get the current LED control (colour) of the driven servo (see hkxLEDControl for more details about the options).
Example:
uint8_t HkxContRotation::getStatus | ( | HkxStatus & | statusED, |
boolean | update | ||
) |
Get the status.
Get the last received status from the servo.
[out] | statusED | : Last received status of the servo. |
[out] | update | :
|
Example:
|
inline |
Get torque control.
Get the current torque control of the driven servo (see hkxTorqueControl for more details about the options).
Example:
|
inline |
Check if the servo stopped.
Check if the servo is stopped.
true
if the servo is stopped.false
if the servo is still moving.Example:
uint8_t HkxContRotation::moveRotation | ( | int16_t | pwm, |
HkxMaybe< uint16_t > | playTime, | ||
HkxMaybe< hkxLEDControl > | LEDControl | ||
) |
Move continuous rotation.
Move the servo in continuous rotation.
[in] | pwm | : Torque power to apply. Its value shall be set in PWM within the range [-1023 ; 1023]. |
[in] | playTime | : Time of the action. Its value shall be set in milliseconds. This parameter is optional, either set a uint16_t (or unsigned int ) variable, or set HKX_NO_VALUE to ignore it. |
[in] | LEDControl | : LED control to apply. This parameter is optional, either set a hkxLEDControl variable, the value (list below), or set HKX_NO_VALUE to ignore it.
|
Example:
uint8_t HkxContRotation::reboot | ( | ) |
Reboot servo.
Reboot the servo. This action will erase the ram, then reinitialize the parameters with the EEP (ROM) values. Wait some time (> 500 ms) before asking any action from the servo.
Example:
uint8_t HkxContRotation::setTorqueLEDControl | ( | HkxMaybe< hkxTorqueControl > | newTorqueControl, |
HkxMaybe< hkxLEDControl > | newLEDControl | ||
) |
Set torque actuation and LED colour.
Set the torque actuation (hkxTorqueControl for more details) and the LED colour (hkxLEDControl for more details).
[in] | newTorqueControl | : Torque control to apply. This parameter is optional, either set a hkxTorqueControl variable, the value (list below), or set HKX_NO_VALUE to ignore it.
|
[in] | newLEDControl | : LED control to apply. This parameter is optional, either set a hkxLEDControl variable, the value (list below), or set HKX_NO_VALUE to ignore it.
|
Example:
|
private |
Connexion with the servo to drive
|
private |
Communication with servos
|
private |
ID of the servo
|
private |
Current RAM value of the LED of the servo
|
private |
Communication to print messages
|
private |
Last status received from the servo
|
private |
Current RAM value of the torque control of the servo