Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: HerkuleX-HelloWorld
Herkulex Class Reference
herkulex Servo control class, based packet protocol on a serial More...
#include <herkulex.h>
Public Member Functions | |
| Herkulex (PinName tx, PinName rx, uint32_t baudRate) | |
| Create an Herkulex servo object connected to the serial pins and baudrate. | |
| ~Herkulex () | |
| Destroy an Herkulex servo object. | |
| void | txPacket (uint8_t packetSize, uint8_t *data) |
| Transmit packet datas. | |
| void | rxPacket (uint8_t packetSize, uint8_t *data) |
| Receive packet datas. | |
| void | clear (uint8_t id) |
| Clear error status. | |
| void | setTorque (uint8_t id, uint8_t cmdTorue) |
| Set torque setting. | |
| void | positionControl (uint8_t id, uint16_t position, uint8_t playtime, uint8_t setLED) |
| Position Control. | |
| void | velocityControl (uint8_t id, int16_t speed, uint8_t setLED) |
| Velocity Control. | |
| int8_t | getStatus (uint8_t id) |
| Get Status. | |
| int16_t | getPos (uint8_t id) |
| Get Position. | |
Detailed Description
herkulex Servo control class, based packet protocol on a serial
Example:
#include "mbed.h" #include "herkulex.h" Herkulex sv(p9, p10, 115200); DigitalOut led(LED1); int main() { wait(1); sv.setTorque(0xFD, TORQUE_ON); while(1) { led=1; sv.movePos(0xFD, 1002, 100, SET_MODE_POS, SET_LED_GREEN_ON); wait(3); led=0; sv.movePos(0xFD, 21, 100, SET_MODE_POS, SET_LED_BLUE_ON); wait(3); } }
Definition at line 245 of file herkulex.h.
Constructor & Destructor Documentation
| Herkulex | ( | PinName | tx, |
| PinName | rx, | ||
| uint32_t | baudRate | ||
| ) |
Create an Herkulex servo object connected to the serial pins and baudrate.
- Parameters:
-
tx Transmit pin. rx Receive pin. baudRate The serial tx/rx speed.
Definition at line 26 of file herkulex.cpp.
| ~Herkulex | ( | ) |
Destroy an Herkulex servo object.
Definition at line 42 of file herkulex.cpp.
Member Function Documentation
| void clear | ( | uint8_t | id ) |
Clear error status.
- Parameters:
-
id The herkulex servo ID.
Definition at line 98 of file herkulex.cpp.
| int16_t getPos | ( | uint8_t | id ) |
Get Position.
- Parameters:
-
id The herkulex servo ID.
- Returns:
- -1 is getPos failed. other is servo's current position.
Definition at line 262 of file herkulex.cpp.
| int8_t getStatus | ( | uint8_t | id ) |
Get Status.
- Parameters:
-
id The herkulex servo ID.
- Returns:
- -1 is getStatus failed. other is servo`s status error value.
Definition at line 208 of file herkulex.cpp.
| void positionControl | ( | uint8_t | id, |
| uint16_t | position, | ||
| uint8_t | playtime, | ||
| uint8_t | setLED | ||
| ) |
Position Control.
- Parameters:
-
id The herkulex servo ID. position The goal position of herkulex servo. playtime Time to target position. setLED Select LED and on/off controll (GLED_ON 0x00,BLED_ON 0x08, RLED_ON 0x10)
Definition at line 149 of file herkulex.cpp.
| void rxPacket | ( | uint8_t | packetSize, |
| uint8_t * | data | ||
| ) |
Receive packet datas.
- Parameters:
-
packetSize The packet size. data The receive packet data array.
Definition at line 77 of file herkulex.cpp.
| void setTorque | ( | uint8_t | id, |
| uint8_t | cmdTorue | ||
| ) |
Set torque setting.
- Parameters:
-
id The herkulex servo ID. cmdTorue The Command for setting of torque (TORQUE_FREE 0x00, BREAK_ON 0x40, TORQUE_ON 0x60)
Definition at line 124 of file herkulex.cpp.
| void txPacket | ( | uint8_t | packetSize, |
| uint8_t * | data | ||
| ) |
Transmit packet datas.
- Parameters:
-
packetSize The packet size. data The transmit packet data array.
Definition at line 56 of file herkulex.cpp.
| void velocityControl | ( | uint8_t | id, |
| int16_t | speed, | ||
| uint8_t | setLED | ||
| ) |
Velocity Control.
- Parameters:
-
id The herkulex servo ID. speed The goal position of herkulex servo. setLED Select LED and on/off controll (GLED_ON 0x00,BLED_ON 0x08, RLED_ON 0x10)
Definition at line 179 of file herkulex.cpp.
Generated on Tue Jul 12 2022 23:24:58 by
1.7.2
HerkuleX