HerkuleXLib
1.1
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... | |
boolean | tryConnect () |
Try connect servo. More... | |
uint8_t | getID () const |
Get the ID. More... | |
hkxTorqueControl | getTorqueControl () const |
Get torque control. More... | |
hkxLEDControl | getLEDControl () const |
Get LED control. More... | |
HkxCommunication & | getCommunication () const |
Get servo communication. More... | |
boolean | isConnected () const |
Is the servo connected. More... | |
void | setLEDControlVariable (hkxLEDControl newLEDControl) |
Set the LED variable. 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 Member Functions | |
uint8_t | updateStatus () |
Update the status. More... | |
void | errorPrint (const String &message) |
Print error. More... | |
void | warningPrint (const String &message) |
Print warning. More... | |
void | infoPrint (const String &message) |
Print info. More... | |
Private Attributes | |
HkxCommunication & | _herkXCom |
HkxPrint & | _print |
boolean | _connected |
const String | _className |
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:
|
inlineprivate |
Print error.
Print an error message if setup.
[in] | message | : content to print as an error. |
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 uint16_t (or unsigned 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 servo communication.
Get the communication of the servo.
|
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:
|
inlineprivate |
Print info.
Print an info message if setup.
[in] | message | : content to print as an info. |
|
inline |
Is the servo connected.
Return if the servo is connected.
true:
if the servo is connected (last communication worked), false:
if the servo is NOT connected (last communication failed).
|
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:
|
inline |
Set the LED variable.
Set the LED variable in the class without applying.
[in] | newLEDControl | : Colour of the led (see hkxLEDControl for more details). |
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:
boolean HkxContRotation::tryConnect | ( | ) |
Try connect servo.
Try to connect to the servo.
true:
if the servo is connected, false:
if the servo is NOT connected.
|
private |
Update the status.
Perform a status request to update the stored status _statusED.
|
inlineprivate |
Print warning.
Print a warning message if setup.
[in] | message | : content to print as a warning. |
|
private |
Class name to print the messages
|
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