pub struct ServoDefinition {
pub name: &'static str,
pub protocol: u8,
pub info: ServoInfo,
pub registers: &'static [RegisterInfo],
pub models: &'static [(&'static str, u16)],
}Expand description
A servo definition as a value: its name, the protocol it speaks, what it states about itself and its registers.
Every servo module has its own as DEFINITION; on Python, the static definition()
of each controller class returns it.
Fields§
§name: &'static str§protocol: u8The Dynamixel protocol version the servo speaks: 1 or 2.
info: ServoInfo§registers: &'static [RegisterInfo]§models: &'static [(&'static str, u16)]The servo models this definition covers, as (name, model number).
Implementations§
Source§impl ServoDefinition
impl ServoDefinition
Sourcepub fn register(&self, name: &str) -> Option<RegisterInfo>
pub fn register(&self, name: &str) -> Option<RegisterInfo>
Look up a register by name, as spelled in registers.
Sourcepub fn read_register(
&self,
dph: &DynamixelProtocolHandler,
port: &mut dyn SerialPort,
id: u8,
name: &str,
) -> Result<i64, Box<dyn Error>>
pub fn read_register( &self, dph: &DynamixelProtocolHandler, port: &mut dyn SerialPort, id: u8, name: &str, ) -> Result<i64, Box<dyn Error>>
Read register name of motor id as an integer, decoded from this definition’s
word order and the register’s sign encoding.
Sourcepub fn read_register_with_error(
&self,
dph: &DynamixelProtocolHandler,
port: &mut dyn SerialPort,
id: u8,
name: &str,
) -> Result<(i64, StatusError), Box<dyn Error>>
pub fn read_register_with_error( &self, dph: &DynamixelProtocolHandler, port: &mut dyn SerialPort, id: u8, name: &str, ) -> Result<(i64, StatusError), Box<dyn Error>>
Same as read_register, plus the status packet’s error
field.
Sourcepub fn write_register(
&self,
dph: &DynamixelProtocolHandler,
port: &mut dyn SerialPort,
id: u8,
name: &str,
value: i64,
) -> Result<(), Box<dyn Error>>
pub fn write_register( &self, dph: &DynamixelProtocolHandler, port: &mut dyn SerialPort, id: u8, name: &str, value: i64, ) -> Result<(), Box<dyn Error>>
Write value to register name of motor id, laid out in this definition’s word
order and the register’s sign encoding. A value that does not fit the register
fails before anything reaches the bus.
Sourcepub fn write_register_with_error(
&self,
dph: &DynamixelProtocolHandler,
port: &mut dyn SerialPort,
id: u8,
name: &str,
value: i64,
) -> Result<StatusError, Box<dyn Error>>
pub fn write_register_with_error( &self, dph: &DynamixelProtocolHandler, port: &mut dyn SerialPort, id: u8, name: &str, value: i64, ) -> Result<StatusError, Box<dyn Error>>
Same as write_register, plus the status packet’s error
field.
Sourcepub fn sync_read_register(
&self,
dph: &DynamixelProtocolHandler,
port: &mut dyn SerialPort,
ids: &[u8],
name: &str,
) -> Result<Vec<i64>, Box<dyn Error>>
pub fn sync_read_register( &self, dph: &DynamixelProtocolHandler, port: &mut dyn SerialPort, ids: &[u8], name: &str, ) -> Result<Vec<i64>, Box<dyn Error>>
Sync read register name from ids, each value decoded like
read_register.
A servo whose firmware has no Sync Read (supports_sync_read false: the Feetech
SCS series) is read one id at a time instead, in the order asked. The values come
back the same way, but from one transaction per id rather than one for the bus.
Sourcepub fn sync_read_register_with_error(
&self,
dph: &DynamixelProtocolHandler,
port: &mut dyn SerialPort,
ids: &[u8],
name: &str,
) -> Result<Vec<(i64, StatusError)>, Box<dyn Error>>
pub fn sync_read_register_with_error( &self, dph: &DynamixelProtocolHandler, port: &mut dyn SerialPort, ids: &[u8], name: &str, ) -> Result<Vec<(i64, StatusError)>, Box<dyn Error>>
Same as sync_read_register, plus each motor’s error
field.
Sourcepub fn sync_write_register(
&self,
dph: &DynamixelProtocolHandler,
port: &mut dyn SerialPort,
ids: &[u8],
name: &str,
values: &[i64],
) -> Result<(), Box<dyn Error>>
pub fn sync_write_register( &self, dph: &DynamixelProtocolHandler, port: &mut dyn SerialPort, ids: &[u8], name: &str, values: &[i64], ) -> Result<(), Box<dyn Error>>
Sync write values to register name of ids, one value per id, each encoded
like write_register.
Sourcepub fn scan(
&self,
dph: &DynamixelProtocolHandler,
port: &mut dyn SerialPort,
ids: &[u8],
) -> Result<BTreeMap<u8, u16>, Box<dyn Error>>
pub fn scan( &self, dph: &DynamixelProtocolHandler, port: &mut dyn SerialPort, ids: &[u8], ) -> Result<BTreeMap<u8, u16>, Box<dyn Error>>
Which of ids answer, with their model number read as this definition lays it
out.
One Model Number read per id, so presence and identity cost a single round trip.
An absent id costs a timeout, so the sweep runs under one sized to the baud rate,
see scan_timeout, and puts the port’s timeout back afterwards. An id that
answers with anything the protocol cannot parse counts as absent.
Sourcepub fn broadcast_scan(
&self,
dph: &DynamixelProtocolHandler,
port: &mut dyn SerialPort,
ids: &[u8],
) -> Result<BTreeMap<u8, u16>, Box<dyn Error>>
pub fn broadcast_scan( &self, dph: &DynamixelProtocolHandler, port: &mut dyn SerialPort, ids: &[u8], ) -> Result<BTreeMap<u8, u16>, Box<dyn Error>>
Which of ids answer, with their model number read as this definition lays it
out: one broadcast ping, then a Model Number read of each id asked that answered,
under the port’s own timeout.
The ping listens for its whole window however few ids are asked
(broadcast_ping_window, about
0.8 s at 1 Mbps), so this pays off over many ids, where scan costs a
timeout per absent id, and behind a USB adapter whose latency timer outlasts the
short timeout scan uses. A servo that does not answer a broadcast ping
(supports_broadcast_ping) is refused before anything is sent.
Sourcepub fn change_id(
&self,
dph: &DynamixelProtocolHandler,
port: &mut dyn SerialPort,
id: u8,
new_id: u8,
) -> Result<(), Box<dyn Error>>
pub fn change_id( &self, dph: &DynamixelProtocolHandler, port: &mut dyn SerialPort, id: u8, new_id: u8, ) -> Result<(), Box<dyn Error>>
Give motor id the id new_id.
The id is kept in EEPROM, which a motor only writes with its torque off, and a
Feetech motor only with its lock open: both are done first, and left that way.
The motor answers the write from its old id; an answer refusing it fails with a
StatusPacketError.
Sourcepub fn change_baudrate(
&self,
dph: &DynamixelProtocolHandler,
port: &mut dyn SerialPort,
id: u8,
baudrate: u32,
) -> Result<(), Box<dyn Error>>
pub fn change_baudrate( &self, dph: &DynamixelProtocolHandler, port: &mut dyn SerialPort, id: u8, baudrate: u32, ) -> Result<(), Box<dyn Error>>
Set motor id to talk at baudrate, one of the rates in this definition’s
baudrates, written as the value its baud rate register takes for it.
The EEPROM is opened first, as for change_id. The motor
answers the write at its old rate, then switches; port stays at the old rate, so
switch it too (set_baud_rate) to keep talking to the motor.
Sourcepub fn refuses(&self, status: StatusError) -> bool
pub fn refuses(&self, status: StatusError) -> bool
Whether status, the error field of an answer, says the servo refused the
instruction: an error number on protocol v2, an instruction, checksum or range error
on protocol v1, never on a servo whose status only reports alarms. The other bits are
conditions the motor reports while it carries the instruction out, as an overload or
the v2 alert bit.