HerkuleXLib  1.1
Arduino library to drive HerkuleX DRS-0101 and DRS-0201
Public Member Functions | Private Attributes | List of all members
HkxGroupPosControl Class Reference

Class to drive a group of servos in position control mode. More...

#include <HkxGroupPosControl.h>

Public Member Functions

 HkxGroupPosControl (uint8_t length, HkxPosControl *arrayServos[], HkxPrint &print)
 Constructor. More...
 
HkxPosControlgetServo (uint8_t number)
 Get the nth servo. More...
 
uint8_t getNbServos ()
 Get number of servos. More...
 
uint8_t setAllLoad (uint16_t newDeadZone, uint8_t newSaturatorOffset, const uint32_t &newSaturatorSlope, int8_t newPWMOffset, uint8_t newMinPWM, uint16_t newMaxPWM)
 Set load control parameters. More...
 
uint8_t setAllTorqueLEDControl (HkxMaybe< hkxTorqueControl > newTorqueControl, HkxMaybe< hkxLEDControl > newLEDControl)
 Set torque actuation and LED colour. More...
 
uint8_t moveSyncAllPosition (int16_t destinationAngle[], uint16_t playTime, HkxMaybe< hkxLEDControl > LEDControl[], bool waitStop)
 Synchronous move position. More...
 
uint8_t moveAsyncAllPosition (int16_t destinationAngle[], uint16_t playTime[], HkxMaybe< hkxLEDControl > LEDControl[], bool waitStop)
 Asynchronous move position. More...
 
void rebootAll ()
 Reboot. More...
 

Private Attributes

HkxPosControl ** _servos
 
const uint8_t _length
 
HkxCommunication_herkXCom
 
HkxPrint_print
 

Detailed Description

Class to drive a group of servos in position control mode.

This class allows to drive a group of servos in position control mode.

Constructor & Destructor Documentation

HkxGroupPosControl::HkxGroupPosControl ( uint8_t  length,
HkxPosControl arrayServos[],
HkxPrint print 
)

Constructor.

The constructor of HkxGroupPosControl.

Warning
HkxCommunication shall be the same for all the servos of the group. If not, an error will be returned and the instance will be corrupted.
Parameters
[in]length: Number of servos in the table _servos.
Warning
It shall not exceed 53 servos, otherwise it cannot execute moveSyncAllPosition() and moveAsyncAllPosition().
If it exceeds 43 servos then it cannot execute moveAsyncAllPosition().
Parameters
[in]arrayServos[]: Array of pointers to the servos.
[in]print: Communication to print messages.

Member Function Documentation

uint8_t HkxGroupPosControl::getNbServos ( )
inline

Get number of servos.

Get the number of servos manage by the instance.

Returns
Return the number of servos.
HkxPosControl& HkxGroupPosControl::getServo ( uint8_t  number)
inline

Get the nth servo.

Get the nth servo.

Parameters
[in]number: number of servo to get (from the table _servos).
Warning
number < _ref _length otherwise return void.
Returns
Return a reference to the nth servo.
uint8_t HkxGroupPosControl::moveAsyncAllPosition ( int16_t  destinationAngle[],
uint16_t  playTime[],
HkxMaybe< hkxLEDControl LEDControl[],
bool  waitStop 
)

Asynchronous move position.

Move the servo asynchronous (with different playTime).

Parameters
[in]destinationAngle[]: Array of relative position to reach. Its value shall be set in 10^-1 degrees. Its range depends for each servo on HkxPosControl::_zeroPosition, HkxPosControl::_minPosition and HkxPosControl::_maxPosition.
[in]playTime: Array of time of the action trajectory for the move. Its value shall be set in milliseconds within the range [0 ; 2845ms].
[in]LEDControl[]: Array of 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.
  • HKX_LED_OFF,
  • HKX_LED_GREEN,
  • HKX_LED_BLUE,
  • HKX_LED_RED,
  • HKX_LED_CYAN,
  • HKX_LED_YELLOW,
  • HKX_LED_PINK,
  • HKX_LED_WHITE,
[in]waitStop:
  • true to wait all the servos reach its goal position destinationAngle (HkxPosControl::isInPosition()).
  • false to continue running the programme during the move. This could same computation time but the user shall check with HkxPosControl::isInPosition() that all the servos reached their goal before setting the next move.
Returns
0 = OK
1 = Input not correct
2 = Servo not connected
uint8_t HkxGroupPosControl::moveSyncAllPosition ( int16_t  destinationAngle[],
uint16_t  playTime,
HkxMaybe< hkxLEDControl LEDControl[],
bool  waitStop 
)

Synchronous move position.

Perform a synchronous (with the same playTime) move of all the servos.

Parameters
[in]destinationAngle[]: Array of relative position to reach. Its value shall be set in 10^-1 degrees. Its range depends for each servo on HkxPosControl::_zeroPosition, HkxPosControl::_minPosition and HkxPosControl::_maxPosition.
[in]playTime: Time of the action trajectory for the move. Its value shall be set in milliseconds within the range [0 ; 2845ms].
[in]LEDControl[]: Array of 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.
  • HKX_LED_OFF,
  • HKX_LED_GREEN,
  • HKX_LED_BLUE,
  • HKX_LED_RED,
  • HKX_LED_CYAN,
  • HKX_LED_YELLOW,
  • HKX_LED_PINK,
  • HKX_LED_WHITE,
[in]waitStop:
  • true to wait all the servos reach its goal position destinationAngle (HkxPosControl::isInPosition()).
  • false to continue running the programme during the move. This could same computation time but the user shall check with HkxPosControl::isInPosition() that all the servos reached their goal before setting the next move.
Returns
0 = OK
1 = Input not correct
2 = Servo not connected
void HkxGroupPosControl::rebootAll ( )
inline

Reboot.

Reboot all the servos.

uint8_t HkxGroupPosControl::setAllLoad ( uint16_t  newDeadZone,
uint8_t  newSaturatorOffset,
const uint32_t &  newSaturatorSlope,
int8_t  newPWMOffset,
uint8_t  newMinPWM,
uint16_t  newMaxPWM 
)

Set load control parameters.

Set to all the servos the same load control parameters on their RAM (not kept after servo reboot).

         PWM+
          |  ___________........................................ PWM max
          |             \
          |              \ Saturator slope
          |               \..................................... Saturator offset
          |                |<dead zone> <dead zone>
          |                |___________ ........................ PWM min
          |                            |
          |  --------------------------|------------------------ PWM offset
          |                            |__________
Position- |____________________________*__________|_____________ Position+
          |                          goal         |
          |                        position        \
          |                                         \__________
          |
         PWM- 
Parameters
[in]newDeadZone: The dead zone is the angle error before the servo applies a load compensation to maintain its position (see the above figure). Its value shall be set in 10^-1 degrees within the range [0 ; 82.8°].
[in]newSaturatorOffset: The saturator offset is the step PWM value of the saturator once deadzone the position goes out of the deadzone (see the above figure). Its value shall be set in PWM within the range [0 ; 254].
[in]newSaturatorSlope: The saturator slop is a gradient of the saturator, going from the saturator offset and increasing gradually the PWM with the error position to the goal (see the above figure). It provides a flexible and elastic response of the servo to external forces. Its value shall be set in 10^-2 PWM / degree within the range [0 ; 393 PWM/degree].
[in]newPWMOffset: The PWM offset allows compensating permanent load (e.g. gravity) by shifting the saturator by the same value (see the above figure). Its value shall be set in PWM within the range [-128 ; 127].
[in]newMinPWM: The min PWM is the minimum PWM that is applied by the servo (see the above figure). As specified in the user manual p.37, this may lead to unstable system. Use 0 as default value. The value shall be set in PWM within the range [0 ; 254].
[in]newMaxPWM: The max PWM is the maximum PWM that is applied by the servo (see the above figure). It could be used to limit the load of the servo, to avoid damages or injuries or instance. The value shall be set in PWM within the range [0 ; 1023].
Returns
0 = OK
1 = Input not correct
2 = Servo not connected
uint8_t HkxGroupPosControl::setAllTorqueLEDControl ( HkxMaybe< hkxTorqueControl newTorqueControl,
HkxMaybe< hkxLEDControl newLEDControl 
)

Set torque actuation and LED colour.

Set the same torque actuation (hkxTorqueControl for more details) and the LED colour (hkxLEDControl for more details) to all the servos.

Parameters
[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.
  • HKX_TORQUE_FREE: no resistance to the movements (or let say mechanical resistance only)
  • HKX_TORQUE_BREAK: the motor resists but allows the movements
  • HKX_TORQUE_ON: the motor maintain its position (don't allow movements)
[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.
  • HKX_LED_OFF,
  • HKX_LED_GREEN,
  • HKX_LED_BLUE,
  • HKX_LED_RED,
  • HKX_LED_CYAN,
  • HKX_LED_YELLOW,
  • HKX_LED_PINK,
  • HKX_LED_WHITE,
Returns
0 = OK
1 = Input not correct
2 = Servo not connected

Member Data Documentation

HkxCommunication& HkxGroupPosControl::_herkXCom
private

Communication with servos

const uint8_t HkxGroupPosControl::_length
private

Number of servos in the table _servos

HkxPrint& HkxGroupPosControl::_print
private

Communication to print messages

HkxPosControl** HkxGroupPosControl::_servos
private

Array of pointers to HkxPosControl instances


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