DYNAMIXEL Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Public Member Functions | List of all members
dynamixel::DYNAMIXEL< Port, FrameBytes > Class Template Reference

Master of one DYNAMIXEL bus on a platform port. More...

#include <dynamixel.hpp>

Public Member Functions

 DYNAMIXEL (Port &port, const Config &config={}) noexcept
 Bind the driver to a port and store the configuration. No I/O, cannot fail.
 
 DYNAMIXEL (const DYNAMIXEL &)=delete
 One driver object per bus.
 
DYNAMIXEL & operator= (const DYNAMIXEL &)=delete
 One driver object per bus.
 
Lifecycle
Result< void > EnsureInitialized () noexcept
 Start the driver, once: validate the configuration, bring the port up and set its rate.
 
bool IsInitialized () const noexcept
 
Result< void > Deinitialize () noexcept
 Mark the driver uninitialised. No bus traffic: the servos keep their state (torque stays on; call DisableTorqueAll() first when the servos must stop).
 
Result< void > Resync () noexcept
 Resynchronise: drop everything received and wait until the line has been quiet for one reply timeout, so that a late status packet cannot be taken for the answer to the next instruction.
 
Result< void > ApplyConfig (const Config &config) noexcept
 Change the whole configuration; the UART rate follows through SetBaudRate() when the port has it.
 
const Config & GetConfig () const &noexcept
 
void GetConfig () const &&=delete
 Not on a temporary driver: the reference would dangle (KB-CPP20-044).
 
Discovery
Result< PingInfo > Ping (uint8_t id) noexcept
 Ping one servo (always answered, whatever the Status Return Level).
 
Result< PingInfo > Identify (uint8_t id) noexcept
 Ping and learn the model: protocol 2.0 is one ping, protocol 1.0 a ping and a read of the Model Number and Firmware Version registers.
 
Result< uint32_t > BroadcastPing (std::span< PingInfo > found) noexcept
 Ping the broadcast ID and collect the answers (protocol 2.0): every servo answers, in ID order.
 
Result< uint32_t > ScanIds (uint8_t first, uint8_t last, std::span< PingInfo > found) noexcept
 Ping every ID from first to last one after another.
 
Raw control-table access
Result< void > Read (uint8_t id, uint16_t address, std::span< uint8_t > out) noexcept
 Read bytes of one servo's control table.
 
Result< void > Write (uint8_t id, uint16_t address, std::span< const uint8_t > data) noexcept
 Write bytes to the control table.
 
Result< void > RegWrite (uint8_t id, uint16_t address, std::span< const uint8_t > data) noexcept
 Store a write to be executed by the next Action instruction (Reg Write).
 
Result< void > Action (uint8_t id) noexcept
 Execute the stored Reg Write (all servos at once with the broadcast ID).
 
Reset, reboot, clear, backup
Result< void > FactoryReset (uint8_t id, ResetOption option) noexcept
 Reset a servo's control table to the factory values.
 
Result< void > Reboot (uint8_t id) noexcept
 Reboot a servo; waits Config::reboot_wait_us after the reply. Sent like the stop: it needs no EnsureInitialized() and is written even when the input flush fails (the call then returns Bus after the write).
 
Result< void > Clear (uint8_t id, ClearOption option) noexcept
 Clear the multi-turn count or registered errors (protocol 2.0). Needs Config::allow_destructive.
 
Result< void > Backup (uint8_t id, BackupOption option) noexcept
 Store the control table in the backup area, or restore the EEPROM from it (protocol 2.0).
 
Sync and bulk instructions
Result< void > SyncWrite (uint16_t address, uint16_t length, std::span< const uint8_t > ids, std::span< const uint8_t > data) noexcept
 Write the same address and length to several servos with one packet (both protocols). No answer.
 
Result< void > BulkWrite (std::span< const BulkWriteItem > items) noexcept
 Write different addresses and lengths to several servos with one packet (protocol 2.0). No answer.
 
Result< void > SyncRead (uint16_t address, uint16_t length, std::span< const uint8_t > ids, std::span< uint8_t > out, std::span< DeviceReply > replies) noexcept
 Read the same address and length from several servos (protocol 2.0): each one answers with its own packet, in the order of ids.
 
Result< void > FastSyncRead (uint16_t address, uint16_t length, std::span< const uint8_t > ids, std::span< uint8_t > out, std::span< DeviceReply > replies) noexcept
 Sync Read with one combined answer packet (Fast Sync Read, protocol 2.0): the servos answer back to back inside one packet, every part with its own error byte, ID and CRC.
 
Result< void > BulkRead (std::span< const BulkReadItem > items, std::span< uint8_t > out, std::span< DeviceReply > replies) noexcept
 Read different addresses and lengths from several servos (protocol 1.0 for MX and X servos, and 2.0).
 
Result< void > FastBulkRead (std::span< const BulkReadItem > items, std::span< uint8_t > out, std::span< DeviceReply > replies) noexcept
 Bulk Read with one combined answer packet (Fast Bulk Read, protocol 2.0).
 
Typed register access
Result< int32_t > ReadRegister (ServoRef servo, Reg reg) noexcept
 Read one register by its family-neutral name and decode it.
 
Result< void > WriteRegister (ServoRef servo, Reg reg, int32_t value) noexcept
 Encode and write one register.
 
Result< void > SetTorque (ServoRef servo, bool enable) noexcept
 Turn the torque on or off. Use DisableTorque() to stop: it is never refused.
 
Result< void > DisableTorque (ServoRef servo) noexcept
 Turn one servo's torque off. Never refused for the driver's state: it needs no EnsureInitialized() (it starts the port and sets the bus baud rate), ignores any earlier failure and asks for no consent, and writes even when the input flush fails. The write is idempotent: it is repeated (up to three times) until a trusted answer confirms it, and sent all three times when no answer can (status return level below 2, or a broadcast).
 
Result< void > DisableTorqueAll (Family family) noexcept
 Turn the torque of every servo of a family off with one broadcast. Never refused for the driver's state. Nothing is answered, so the broadcast is sent three times and Ok means sent.
 
Result< void > DisableTorqueAt (uint8_t id, uint16_t torque_address) noexcept
 Turn the torque off at an explicit address: the stop for a servo whose family is Generic (a model the catalogue does not list) or one that has no Reg::TorqueEnable. It shares the stop path of DisableTorque(): never refused for the driver's state, written even when the input flush fails, up to three attempts. The caller supplies the address from the servo's own control table (64 on the X series in protocol 2.0, 24 on AX/RX/DX).
 
Result< void > DisableTorqueEach (std::span< const ServoRef > servos) noexcept
 DisableTorque() for each servo of a list, whatever one of them does.
 
Result< Feedback > ReadFeedback (ServoRef servo) noexcept
 Read position, velocity, load or current, voltage and temperature in one transfer.
 
Result< void > SetGoalPosition (ServoRef servo, int32_t counts) noexcept
 Write the Goal Position.
 
Result< void > SetId (ServoRef servo, uint8_t new_id) noexcept
 Change a servo's ID. Needs Config::allow_destructive when servo.id is the broadcast ID.
 
Result< void > SetServoBaudRate (ServoRef servo, uint32_t bits_per_second) noexcept
 Write a servo's Baud Rate register; the new rate applies after the reply. The port keeps its rate: follow with ChangeBusBaud().
 
Result< void > ChangeBusBaud (uint32_t bits_per_second) noexcept
 Change the UART rate of the port (after SetServoBaudRate()), wait Config::baud_change_wait_us and resynchronise.
 
Result< void > SetStatusReturnLevel (ServoRef servo, StatusReturn level) noexcept
 Write the Status Return Level and adopt it as the bus's expectation. A write that lowers the level may go unanswered: silence is then accepted as success and the level is adopted, with a warning in the log. A lost write and a lost answer look the same: when it matters, read the register back (at the old level, with Read()) to verify.
 
Diagnostics
const ReplyInfo & GetLastReply () const &noexcept
 
void GetLastReply () const &&=delete
 Not on a temporary driver (KB-CPP20-044).
 
const ReplyInfo & GetLatchedAlert () const &noexcept
 
void GetLatchedAlert () const &&=delete
 Not on a temporary driver (KB-CPP20-044).
 
void ClearLatchedAlert () noexcept
 Forget the latched alert. No I/O.
 
const Stats & GetStats () const &noexcept
 
void GetStats () const &&=delete
 Not on a temporary driver (KB-CPP20-044).
 
void ResetStats () noexcept
 Zero the counters. No I/O.
 
std::span< const uint8_t > GetLastRequest () const &noexcept
 
void GetLastRequest () const &&=delete
 Not on a temporary driver (KB-CPP20-044).
 

Detailed Description

template<UartPort Port, std::size_t FrameBytes = 512>
class dynamixel::DYNAMIXEL< Port, FrameBytes >

Master of one DYNAMIXEL bus on a platform port.

Lifecycle: construct with the configuration (no I/O), then EnsureInitialized(), use, optionally Deinitialize(). Every call that touches the bus returns Error::NotInitialized until EnsureInitialized() has succeeded, with one exception: the torque-off calls (DisableTorque(), DisableTorqueAll(), DisableTorqueEach(), DisableTorqueAt()) and Reboot() are never refused for the driver's state; they bring the port up themselves (and set the bus baud rate) and write even when the input flush fails.

Optional port hooks, found at compile time:

Hook Used for Without it
bool SetBaudRate(uint32_t baud) noexcept EnsureInitialized(), ApplyConfig() and ChangeBusBaud() set the UART rate The port's own rate stays; ChangeBusBaud() returns Unsupported
void Log(LogLevel, const char* message) noexcept One line per lifecycle event or failure Nothing is logged

A hook declared with the wrong signature is a compile error.

Template Parameters
PortYour class derived from UartInterface<Port>.
FrameBytesSize of the transmit and of the receive buffer, 64 to 4096 bytes (default 512). A transfer that does not fit returns InvalidArgument before anything is sent.

Constructor & Destructor Documentation

◆ DYNAMIXEL()

template<UartPort Port, std::size_t FrameBytes = 512>
dynamixel::DYNAMIXEL< Port, FrameBytes >::DYNAMIXEL ( Port &  port,
const Config &  config = {} 
)
inlineexplicitnoexcept

Bind the driver to a port and store the configuration. No I/O, cannot fail.

Parameters
portThe port; it must outlive the driver.
configWhat EnsureInitialized() will apply; checked there, before any I/O.

Member Function Documentation

◆ Action()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::Action ( uint8_t  id)
noexcept

Execute the stored Reg Write (all servos at once with the broadcast ID).

Parameters
idThe servo ID or 254.
Returns
As Write().

◆ ApplyConfig()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::ApplyConfig ( const Config &  config)
noexcept

Change the whole configuration; the UART rate follows through SetBaudRate() when the port has it.

Parameters
configChecked with Validate() before any I/O.
Returns
Ok, InvalidArgument or Bus.

◆ Backup()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::Backup ( uint8_t  id,
BackupOption  option 
)
noexcept

Store the control table in the backup area, or restore the EEPROM from it (protocol 2.0).

Restore needs Config::allow_destructive, makes the servo reboot and waits Config::reboot_wait_us. Torque must be off or the servo answers with a result fail error. Store is not behind allow_destructive, although it overwrites the previous backup in the servo's backup area: it changes nothing the servo runs on, and a restore still needs consent.

Parameters
idThe servo ID or 254.
optionStore or restore.
Returns
NotPermitted, Unsupported (protocol 1.0), InvalidArgument or the errors of Write().

◆ BroadcastPing()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< uint32_t > dynamixel::DYNAMIXEL< Port, FrameBytes >::BroadcastPing ( std::span< PingInfo >  found)
noexcept

Ping the broadcast ID and collect the answers (protocol 2.0): every servo answers, in ID order.

Waits Config::broadcast_timeout_us for each answer and stops at the first silence, at a damaged answer or when found is full (the remaining answers are dropped by the next call's flush).

Parameters
foundReceives one entry per distinct ID that answered validly.
Returns
The number of entries, or NotInitialized, InvalidArgument (empty found), Unsupported (protocol 1.0 has no broadcast ping answers), Bus, or the error of the first answer when none was valid.

◆ BulkRead()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::BulkRead ( std::span< const BulkReadItem >  items,
std::span< uint8_t >  out,
std::span< DeviceReply >  replies 
)
noexcept

Read different addresses and lengths from several servos (protocol 1.0 for MX and X servos, and 2.0).

Parameters
itemsOne entry per servo, each ID once.
outThe sum of all lengths in bytes; the data of servo k follows that of servo k - 1.
repliesOne entry per item.
Returns
As SyncRead().

◆ BulkWrite()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::BulkWrite ( std::span< const BulkWriteItem >  items)
noexcept

Write different addresses and lengths to several servos with one packet (protocol 2.0). No answer.

Parameters
itemsOne entry per servo, each ID once, each with at least one byte.
Returns
Ok, NotInitialized, Unsupported (protocol 1.0), InvalidArgument or Bus.

◆ ChangeBusBaud()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::ChangeBusBaud ( uint32_t  bits_per_second)
noexcept

Change the UART rate of the port (after SetServoBaudRate()), wait Config::baud_change_wait_us and resynchronise.

Parameters
bits_per_secondThe new rate, kMinBaud to kMaxBaud.
Returns
NotInitialized, InvalidArgument, Unsupported (the port has no SetBaudRate()), Bus.

◆ Clear()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::Clear ( uint8_t  id,
ClearOption  option 
)
noexcept

Clear the multi-turn count or registered errors (protocol 2.0). Needs Config::allow_destructive.

Parameters
idThe servo ID or 254.
optionWhat to clear.
Returns
NotPermitted, Unsupported (protocol 1.0), InvalidArgument or the errors of Write().

◆ Deinitialize()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::Deinitialize ( )
noexcept

Mark the driver uninitialised. No bus traffic: the servos keep their state (torque stays on; call DisableTorqueAll() first when the servos must stop).

Returns
Ok.

◆ DisableTorque()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::DisableTorque ( ServoRef  servo)
noexcept

Turn one servo's torque off. Never refused for the driver's state: it needs no EnsureInitialized() (it starts the port and sets the bus baud rate), ignores any earlier failure and asks for no consent, and writes even when the input flush fails. The write is idempotent: it is repeated (up to three times) until a trusted answer confirms it, and sent all three times when no answer can (status return level below 2, or a broadcast).

Parameters
servoThe servo; its family must have a torque register and speak the bus protocol (not Generic: use DisableTorqueAt()).
Returns
Ok when confirmed (or sent, without answers), InvalidArgument (the ID, or a family with no torque register on this protocol; nothing is sent), Bus (the port did not start, or the flush failed: the packets were sent all the same), or the last error of the attempts.

◆ DisableTorqueAll()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::DisableTorqueAll ( Family  family)
noexcept

Turn the torque of every servo of a family off with one broadcast. Never refused for the driver's state. Nothing is answered, so the broadcast is sent three times and Ok means sent.

Parameters
familyThe family whose torque register is written.
Returns
Ok (sent), InvalidArgument (Generic, or a family that does not speak the bus protocol) or Bus.

◆ DisableTorqueAt()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::DisableTorqueAt ( uint8_t  id,
uint16_t  torque_address 
)
noexcept

Turn the torque off at an explicit address: the stop for a servo whose family is Generic (a model the catalogue does not list) or one that has no Reg::TorqueEnable. It shares the stop path of DisableTorque(): never refused for the driver's state, written even when the input flush fails, up to three attempts. The caller supplies the address from the servo's own control table (64 on the X series in protocol 2.0, 24 on AX/RX/DX).

Parameters
idThe servo ID, or 254 for every servo.
torque_addressThe Torque Enable address (at most 255 in protocol 1.0).
Returns
As DisableTorque(); InvalidArgument for an ID or address the protocol does not have (nothing is sent).

Warning: this writes one byte 0 at the address given, with ID 254 to every servo. A wrong address can set IDs to 0, change the baud rate or silence the servos. Take the address from the e-Manual's control table for the exact model and firmware (64 on the X series, 24 on AX/RX/DX, MX 1.0 and XL-320; the Pro series differ).

◆ DisableTorqueEach()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::DisableTorqueEach ( std::span< const ServoRef >  servos)
noexcept

DisableTorque() for each servo of a list, whatever one of them does.

Parameters
servosThe servos.
Returns
Ok, or only the first error after all of them were tried: to know which servo failed, call DisableTorque() for each one.

◆ EnsureInitialized()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::EnsureInitialized ( )
noexcept

Start the driver, once: validate the configuration, bring the port up and set its rate.

After it succeeds, later calls return Ok at once with no I/O. After it fails, the driver stays uninitialised and the next call starts again. No servo is addressed.

Returns
Ok, InvalidArgument (the stored configuration fails Validate(); no I/O) or Bus.

◆ FactoryReset()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::FactoryReset ( uint8_t  id,
ResetOption  option 
)
noexcept

Reset a servo's control table to the factory values.

Needs Config::allow_destructive. Reset all (ResetOption::All) also resets the ID to 1 and the baud rate to 57 600 bit/s: the servo then answers at another ID and rate than the bus uses. Protocol 1.0 has no option byte (it resets everything: only ResetOption::All is accepted) and cannot use the broadcast ID; protocol 2.0 refuses reset all on the broadcast ID (the firmware does too). Waits Config::reboot_wait_us afterwards.

Parameters
idThe servo ID (broadcast only protocol 2.0 with a keep option).
optionWhat to keep.
Returns
NotPermitted, InvalidArgument or the errors of Write().

◆ FastBulkRead()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::FastBulkRead ( std::span< const BulkReadItem >  items,
std::span< uint8_t >  out,
std::span< DeviceReply >  replies 
)
noexcept

Bulk Read with one combined answer packet (Fast Bulk Read, protocol 2.0).

Parameters
itemsOne entry per servo, each ID once.
outThe sum of all lengths in bytes.
repliesOne entry per item.
Returns
As FastSyncRead().

◆ FastSyncRead()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::FastSyncRead ( uint16_t  address,
uint16_t  length,
std::span< const uint8_t >  ids,
std::span< uint8_t >  out,
std::span< DeviceReply >  replies 
)
noexcept

Sync Read with one combined answer packet (Fast Sync Read, protocol 2.0): the servos answer back to back inside one packet, every part with its own error byte, ID and CRC.

Parameters
addressFirst address.
lengthBytes per servo.
idsThe servo IDs.
outids.size() * length bytes.
repliesOne entry per ID. A packet that ends early still delivers the parts that arrived whole and checked; the rest is Timeout.
Returns
As SyncRead(). The combined packet must fit the receive buffer (InvalidArgument otherwise).

◆ GetConfig()

template<UartPort Port, std::size_t FrameBytes = 512>
const Config & dynamixel::DYNAMIXEL< Port, FrameBytes >::GetConfig ( ) const &
inlinenoexcept
Returns
The configuration last applied or stored. No I/O.

◆ GetLastReply()

template<UartPort Port, std::size_t FrameBytes = 512>
const ReplyInfo & dynamixel::DYNAMIXEL< Port, FrameBytes >::GetLastReply ( ) const &
inlinenoexcept
Returns
The decoded error byte of the last status packet received. No I/O.

◆ GetLastRequest()

template<UartPort Port, std::size_t FrameBytes = 512>
std::span< const uint8_t > dynamixel::DYNAMIXEL< Port, FrameBytes >::GetLastRequest ( ) const &
inlinenoexcept
Returns
The bytes of the last instruction packet sent, as put on the line (stuffed, with CRC); empty before the first. No I/O (handbook KB-CPP-129).

◆ GetLatchedAlert()

template<UartPort Port, std::size_t FrameBytes = 512>
const ReplyInfo & dynamixel::DYNAMIXEL< Port, FrameBytes >::GetLatchedAlert ( ) const &
inlinenoexcept
Returns
The first alert or condition flag seen since ClearLatchedAlert(); all zero when none. No I/O.

◆ GetStats()

template<UartPort Port, std::size_t FrameBytes = 512>
const Stats & dynamixel::DYNAMIXEL< Port, FrameBytes >::GetStats ( ) const &
inlinenoexcept
Returns
The counters since ResetStats(). No I/O.

◆ Identify()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< PingInfo > dynamixel::DYNAMIXEL< Port, FrameBytes >::Identify ( uint8_t  id)
noexcept

Ping and learn the model: protocol 2.0 is one ping, protocol 1.0 a ping and a read of the Model Number and Firmware Version registers.

Parameters
idThe servo ID.
Returns
The identity, or the errors of Ping() and Read() (Unsupported when the servos answer pings only on protocol 1.0).

◆ IsInitialized()

template<UartPort Port, std::size_t FrameBytes = 512>
bool dynamixel::DYNAMIXEL< Port, FrameBytes >::IsInitialized ( ) const
inlinenoexcept
Returns
true after a successful EnsureInitialized() and before Deinitialize(). No I/O.

◆ Ping()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< PingInfo > dynamixel::DYNAMIXEL< Port, FrameBytes >::Ping ( uint8_t  id)
noexcept

Ping one servo (always answered, whatever the Status Return Level).

Parameters
id0 to 252 (protocol 2.0) or 253 (protocol 1.0); not the broadcast ID.
Returns
Protocol 2.0: ID, model number, firmware version and family. Protocol 1.0: the ping carries no data, so only id is set (Identify() reads the rest). Errors: NotInitialized, InvalidArgument, Bus, Timeout, Crc, InvalidReply, LineFault, EchoMismatch, DeviceIdMismatch, DeviceError, DeviceFault.

◆ Read()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::Read ( uint8_t  id,
uint16_t  address,
std::span< uint8_t >  out 
)
noexcept

Read bytes of one servo's control table.

Parameters
idThe servo ID (not the broadcast ID: reads are not executed on it).
addressFirst address (0 to 255 in protocol 1.0).
outReceives out.size() bytes, 1 or more; the reply must fit the receive buffer even with byte stuffing.
Returns
Ok, NotInitialized, InvalidArgument (nothing sent), Unsupported (the status return level is ping only), Bus, Timeout, Crc, InvalidReply, LineFault, EchoMismatch, DeviceIdMismatch, DeviceError (the servo's error number is in GetLastReply()) or DeviceFault. Retried Config::retries times.

◆ ReadFeedback()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< Feedback > dynamixel::DYNAMIXEL< Port, FrameBytes >::ReadFeedback ( ServoRef  servo)
noexcept

Read position, velocity, load or current, voltage and temperature in one transfer.

Parameters
servoThe servo; its family needs these registers (not Generic).
Returns
The feedback, or the errors of Read() and Unsupported.

◆ ReadRegister()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< int32_t > dynamixel::DYNAMIXEL< Port, FrameBytes >::ReadRegister ( ServoRef  servo,
Reg  reg 
)
noexcept

Read one register by its family-neutral name and decode it.

Parameters
servoThe servo: ID and family (FamilyOf() of a ping's model number).
regThe register.
Returns
The decoded value, Unsupported (the family has no such register, or does not speak the bus protocol: nothing is sent), or the errors of Read().

◆ Reboot()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::Reboot ( uint8_t  id)
noexcept

Reboot a servo; waits Config::reboot_wait_us after the reply. Sent like the stop: it needs no EnsureInitialized() and is written even when the input flush fails (the call then returns Bus after the write).

Parameters
idThe servo ID or 254.
Returns
InvalidArgument, Bus, or as Write().

◆ RegWrite()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::RegWrite ( uint8_t  id,
uint16_t  address,
std::span< const uint8_t >  data 
)
noexcept

Store a write to be executed by the next Action instruction (Reg Write).

Parameters
idThe servo ID or 254.
addressFirst address.
dataThe bytes, 1 or more.
Returns
As Write().

◆ Resync()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::Resync ( )
noexcept

Resynchronise: drop everything received and wait until the line has been quiet for one reply timeout, so that a late status packet cannot be taken for the answer to the next instruction.

Returns
Ok, NotInitialized, Bus, or LineFault when the line never went quiet.

◆ ScanIds()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< uint32_t > dynamixel::DYNAMIXEL< Port, FrameBytes >::ScanIds ( uint8_t  first,
uint8_t  last,
std::span< PingInfo >  found 
)
noexcept

Ping every ID from first to last one after another.

Parameters
firstFirst ID.
lastLast ID, not below first, within the protocol's ID range.
foundReceives the IDs that answered; InvalidArgument when it is empty.
Returns
The number of entries (silent IDs are skipped, so is a damaged answer), or NotInitialized, InvalidArgument or Bus. A full found stops the scan.

◆ SetGoalPosition()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::SetGoalPosition ( ServoRef  servo,
int32_t  counts 
)
noexcept

Write the Goal Position.

Parameters
servoThe servo.
countsPosition in counts.
Returns
As WriteRegister().

◆ SetId()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::SetId ( ServoRef  servo,
uint8_t  new_id 
)
noexcept

Change a servo's ID. Needs Config::allow_destructive when servo.id is the broadcast ID.

Parameters
servoThe servo (current ID).
new_id0 to 252 (253 in protocol 1.0).
Returns
NotPermitted, InvalidArgument or the errors of WriteRegister().

◆ SetServoBaudRate()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::SetServoBaudRate ( ServoRef  servo,
uint32_t  bits_per_second 
)
noexcept

Write a servo's Baud Rate register; the new rate applies after the reply. The port keeps its rate: follow with ChangeBusBaud().

Parameters
servoThe servo.
bits_per_secondA rate the family's baud scheme offers.
Returns
InvalidArgument (not offered) or the errors of WriteRegister().

◆ SetStatusReturnLevel()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::SetStatusReturnLevel ( ServoRef  servo,
StatusReturn  level 
)
noexcept

Write the Status Return Level and adopt it as the bus's expectation. A write that lowers the level may go unanswered: silence is then accepted as success and the level is adopted, with a warning in the log. A lost write and a lost answer look the same: when it matters, read the register back (at the old level, with Read()) to verify.

Parameters
servoThe servo (or {254, family}).
levelThe new level.
Returns
InvalidArgument or the errors of WriteRegister().

◆ SetTorque()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::SetTorque ( ServoRef  servo,
bool  enable 
)
noexcept

Turn the torque on or off. Use DisableTorque() to stop: it is never refused.

Parameters
servoThe servo.
enabletrue to enable.
Returns
As WriteRegister().

◆ SyncRead()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::SyncRead ( uint16_t  address,
uint16_t  length,
std::span< const uint8_t >  ids,
std::span< uint8_t >  out,
std::span< DeviceReply >  replies 
)
noexcept

Read the same address and length from several servos (protocol 2.0): each one answers with its own packet, in the order of ids.

Parameters
addressFirst address.
lengthBytes per servo, 1 or more.
idsThe servo IDs, 1 to many, none the broadcast ID.
outids.size() * length bytes; entry k holds servo k's data when replies[k].result is Ok.
repliesOne entry per ID: its outcome.
Returns
Ok when every servo answered validly, else the first failing outcome; NotInitialized, Unsupported (protocol 1.0, or the status return level is ping only), InvalidArgument or Bus. Not retried as a whole: re-read the failed servos.

◆ SyncWrite()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::SyncWrite ( uint16_t  address,
uint16_t  length,
std::span< const uint8_t >  ids,
std::span< const uint8_t >  data 
)
noexcept

Write the same address and length to several servos with one packet (both protocols). No answer.

Parameters
addressFirst address (0 to 255 in protocol 1.0).
lengthBytes per servo, 1 or more.
idsThe servo IDs (1 to many, not 254).
dataids.size() * length bytes, the bytes of the first servo first.
Returns
Ok (sent), NotInitialized, InvalidArgument (nothing sent, also when the packet does not fit the transmit buffer) or Bus.

◆ Write()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::Write ( uint8_t  id,
uint16_t  address,
std::span< const uint8_t >  data 
)
noexcept

Write bytes to the control table.

Not retried: a lost reply does not tell whether the servo applied the write. With the broadcast ID nothing is answered and Ok only means "sent".

Parameters
idThe servo ID or 254 (every servo).
addressFirst address.
dataThe bytes, 1 or more.
Returns
As Read(), plus Ok for a sent broadcast.

◆ WriteRegister()

template<UartPort Port, std::size_t FrameBytes = 512>
Result< void > dynamixel::DYNAMIXEL< Port, FrameBytes >::WriteRegister ( ServoRef  servo,
Reg  reg,
int32_t  value 
)
noexcept

Encode and write one register.

Parameters
servoThe servo (or {254, family} for every servo of a family).
regThe register.
valueThe value in the register's unit.
Returns
InvalidArgument (the register is read-only, or the value does not fit its size; nothing sent), Unsupported (the family has no such register, or does not speak the bus protocol) or the errors of Write().

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