HerkuleXLib  1.1
Arduino library to drive HerkuleX DRS-0101 and DRS-0201
/home/benoit/sketchbook/libraries/HerkuleXLib/HkxPosControl.h
Go to the documentation of this file.
1 #ifndef _HKXPOSCONTROL_H
2 #define _HKXPOSCONTROL_H
3 
13 #include "Arduino.h"
14 #include "HkxCommunication.h"
15 #include "HkxStatus.h"
16 
23 private:
29  boolean _connected;
32  const String _className;
35  int16_t _zeroPosition;
37  uint8_t _id;
39  uint8_t _deadZone;
43  uint16_t _saturatorSlope;
45  int8_t _pwmOffset;
47  uint8_t _minPWM;
49  uint16_t _maxPWM;
51  uint16_t _minPosition;
53  uint16_t _maxPosition;
60 
71  uint8_t updateStatus();
72 
78  void errorPrint(const String& message){if(_print._errorMessages){_print.errorPrint(_className + message);}};
79 
85  void warningPrint(const String& message){if(_print._errorMessages){_print.warningPrint(_className + message);}};
86 
92  void infoPrint(const String& message){if(_print._errorMessages){_print.infoPrint(_className + message);}};
94 public:
109  HkxPosControl(uint8_t ID, HkxCommunication& herkXCom, HkxPrint& print);
110 
119  boolean tryConnect();
135  uint8_t getID() const {return this->_id;};
136 
150 
163  hkxLEDControl getLEDControl() const {return this->_ledControl;};
164 
171  HkxCommunication& getCommunication() const {return this->_herkXCom;};
172 
180  boolean isConnected() const {return this->_connected;};
181 
187  int16_t positionRelativeToAbsolute(int16_t positionRelative) const {return positionRelative + _zeroPosition;};
188 
194  int16_t positionAbsoluteToRelative(int16_t positionAbsolute) const {return positionAbsolute - _zeroPosition;};
195 
201  uint16_t getMinPosition() const {return _minPosition;};
202 
208  uint16_t getMaxPosition() const {return _maxPosition;};
209 
216  void setLEDControlVariable(hkxLEDControl newLEDControl){this->_ledControl = newLEDControl;};
235  boolean isInPosition(){
236  this->updateStatus();
237  return this->_statusED.isDetail(HKX_STAT_INPOSITION_FLAG);
238  };
239 
264  uint8_t getStatus(HkxStatus& statusED, boolean update);
265 
286  uint8_t clearStatus();
287 
328  uint8_t setLoad(uint16_t newDeadZone, uint8_t newSaturatorOffset, const uint32_t& newSaturatorSlope, int8_t newPWMOffset, uint8_t newMinPWM, uint16_t newMaxPWM);
329 
359  uint8_t setTorqueLEDControl(HkxMaybe<hkxTorqueControl> newTorqueControl, HkxMaybe<hkxLEDControl> newLEDControl);
360 
379  uint8_t setCurrentPositionTo(int16_t currentPosition);
380 
410  uint8_t movePosition(int16_t destinationAngle, uint16_t playTime, HkxMaybe<hkxLEDControl> LEDControl, bool waitStop);
411 
442  uint8_t getBehaviour(HkxMaybe<uint16_t> inputVoltage, HkxMaybe<uint16_t> temperature, HkxMaybe<int16_t> position, HkxMaybe<int16_t> velocity, HkxMaybe<uint16_t> PWM, HkxMaybe<int16_t> goalPosition, HkxMaybe<int16_t> trajectoryPosition, HkxMaybe<int16_t> trajectoryVelocity);
443 
460  uint8_t reboot();
461 };
462 
463 #endif // _HKXPOSCONTROL_H
464 
465 
466 
uint8_t reboot()
Reboot servo.
Definition: HkxPosControl.cpp:361
void setLEDControlVariable(hkxLEDControl newLEDControl)
Set the LED variable.
Definition: HkxPosControl.h:216
uint8_t getBehaviour(HkxMaybe< uint16_t > inputVoltage, HkxMaybe< uint16_t > temperature, HkxMaybe< int16_t > position, HkxMaybe< int16_t > velocity, HkxMaybe< uint16_t > PWM, HkxMaybe< int16_t > goalPosition, HkxMaybe< int16_t > trajectoryPosition, HkxMaybe< int16_t > trajectoryVelocity)
Get the servo behaviour.
Definition: HkxPosControl.cpp:310
uint16_t _saturatorSlope
Definition: HkxPosControl.h:43
const String _className
Definition: HkxPosControl.h:32
void warningPrint(const String &message) const
Print warning.
Definition: HkxCommunication.h:394
uint8_t _id
Definition: HkxPosControl.h:37
uint8_t _saturatorOffset
Definition: HkxPosControl.h:41
void errorPrint(const String &message) const
Print error.
Definition: HkxCommunication.h:381
uint8_t getID() const
Get the ID.
Definition: HkxPosControl.h:135
uint8_t _deadZone
Definition: HkxPosControl.h:39
boolean isInPosition()
Check if the servo arrived.
Definition: HkxPosControl.h:235
Class to manage optional parameters.
Definition: HkxCommunication.h:202
void errorPrint(const String &message)
Print error.
Definition: HkxPosControl.h:78
uint8_t updateStatus()
Update the status.
Definition: HkxPosControl.cpp:73
Status management of the Arduino library for HerkuleX servo (DRS-0101 and DRS-0201 models) ...
uint16_t _minPosition
Definition: HkxPosControl.h:51
hkxTorqueControl
Torque control.
Definition: HkxCommunication.h:127
int16_t positionAbsoluteToRelative(int16_t positionAbsolute) const
Convert absolute to relative position.
Definition: HkxPosControl.h:194
HkxCommunication & getCommunication() const
Get servo communication.
Definition: HkxPosControl.h:171
Class to manage the communication.
Definition: HkxCommunication.h:634
Class to manage the status of the servos.
Definition: HkxStatus.h:55
uint8_t clearStatus()
Clear the status.
Definition: HkxPosControl.cpp:119
hkxTorqueControl getTorqueControl() const
Get torque control.
Definition: HkxPosControl.h:149
hkxLEDControl getLEDControl() const
Get LED control.
Definition: HkxPosControl.h:163
uint8_t setTorqueLEDControl(HkxMaybe< hkxTorqueControl > newTorqueControl, HkxMaybe< hkxLEDControl > newLEDControl)
Set torque actuation and LED colour.
Definition: HkxPosControl.cpp:181
boolean _connected
Definition: HkxPosControl.h:29
HkxCommunication & _herkXCom
Definition: HkxPosControl.h:25
boolean isDetail(uint8_t mask) const
Check for details.
Definition: HkxStatus.h:118
uint8_t setCurrentPositionTo(int16_t currentPosition)
Set current position.
Definition: HkxPosControl.cpp:226
boolean tryConnect()
Try connect servo.
Definition: HkxPosControl.cpp:30
int16_t positionRelativeToAbsolute(int16_t positionRelative) const
Convert relative to absolute position.
Definition: HkxPosControl.h:187
uint16_t _maxPWM
Definition: HkxPosControl.h:49
Class to drive one servo in position control mode.
Definition: HkxPosControl.h:22
hkxTorqueControl _torqueControl
Definition: HkxPosControl.h:55
hkxLEDControl
LED control.
Definition: HkxCommunication.h:146
hkxLEDControl _ledControl
Definition: HkxPosControl.h:57
int16_t _zeroPosition
Definition: HkxPosControl.h:35
uint8_t getStatus(HkxStatus &statusED, boolean update)
Get the status.
Definition: HkxPosControl.cpp:96
uint16_t getMinPosition() const
Get min position.
Definition: HkxPosControl.h:201
HkxPosControl(uint8_t ID, HkxCommunication &herkXCom, HkxPrint &print)
Constructor.
Definition: HkxPosControl.cpp:13
uint16_t _maxPosition
Definition: HkxPosControl.h:53
Class to manage the print of the messages.
Definition: HkxCommunication.h:278
void infoPrint(const String &message) const
Print info.
Definition: HkxCommunication.h:407
uint16_t getMaxPosition() const
Get max position.
Definition: HkxPosControl.h:208
HkxPrint & _print
Definition: HkxPosControl.h:27
void infoPrint(const String &message)
Print info.
Definition: HkxPosControl.h:92
uint8_t setLoad(uint16_t newDeadZone, uint8_t newSaturatorOffset, const uint32_t &newSaturatorSlope, int8_t newPWMOffset, uint8_t newMinPWM, uint16_t newMaxPWM)
Set load control parameters.
Definition: HkxPosControl.cpp:137
const uint8_t HKX_STAT_INPOSITION_FLAG
Definition: HkxStatus.h:35
uint8_t _minPWM
Definition: HkxPosControl.h:47
HkxStatus _statusED
Definition: HkxPosControl.h:59
void warningPrint(const String &message)
Print warning.
Definition: HkxPosControl.h:85
boolean isConnected() const
Is the servo connected.
Definition: HkxPosControl.h:180
const boolean _errorMessages
Definition: HkxCommunication.h:407
Communication management of the Arduino library for HerkuleX servo (DRS-0101 and DRS-0201 models) ...
uint8_t movePosition(int16_t destinationAngle, uint16_t playTime, HkxMaybe< hkxLEDControl > LEDControl, bool waitStop)
Move position.
Definition: HkxPosControl.cpp:260
int8_t _pwmOffset
Definition: HkxPosControl.h:45