High level API¶
Controllers¶
-
class
dynamixel::controllers::Usb2Dynamixel¶ Public Functions
-
Usb2Dynamixel(const std::string &name, int baudrate = B115200, double recv_timeout = 0.1)¶ With this constructor a serial connection is opened or it throws an exception
- See
- open_serial
- Parameters
name-see open_serial
baudrate-see open_serial
recv_timeout-timeout (in seconds) for the recv method
- Exceptions
errors::Error-see open_serial
-
Usb2Dynamixel()¶
-
~Usb2Dynamixel()¶
-
void
open_serial(const std::string &name, int baudrate = B115200)¶ Open the serial port for communication with the servos
- Parameters
name-path to the UNIX serial port, usually ends like “ttyUSBx” or “ttyACMx” where x is an integer
baudrate-represent the communication speed; it is defined by the operating system. the standard values are:
- B0
- B50
- B75
- B110
- B134
- B150
- B200
- B300
- B600
- B1200
- B1800
- B2400
- B4800
- B9600
- B19200
- B38400
- B57600
- B76800
- B115200
B1000000 corresponds to \(10^6\) bauds. It is not a standard POSIX value but is accepted on GNU/Linux.
- Exceptions
errors::Error-either if the connection is already open or if we fail to open it; the exception message gives more details on the cause
-
void
close_serial()¶ Close the serial port
-
bool
is_open()¶
-
void
flush()¶
-
double
recv_timeout()¶
-
void
set_recv_timeout(double recv_timeout)¶
- template <typename T>
-
void
send(const InstructionPacket<T> &packet) const¶
- template <typename T>
-
bool
recv(StatusPacket<T> &status) const¶
-
void
set_report_bad_packet(bool report_bad_packet)¶ Enable error reporting for packet issues
If report_bad_packet is set to true, invalid packet headers and errors in packet size are reported through exceptions.
-
bool
report_bad_packet()¶
-
Auto-detection of servos¶
There are two versions of the auto detection, one that returns a vector and one that returns a map.
- template <typename Protocol, typename Controller>
-
std::vector<std::shared_ptr<servos::BaseServo<Protocol>>>
dynamixel::auto_detect(const Controller &controller)¶ Auto-detect all connected actuators using a given protocol.
The template parameter Controller is inferred from the function’s parameter. Conversely, it is compulsory to specify the protocol version: either dynamixel::protocols::Protocol1 or dynamixel::protocols::Protocol2.
The returned vector contains objects corresponding to the actuators that were found. You can use these objects to do all actions that are possible with the Dynamixel actuators.
- Return
- vector of actuators
- Parameters
controller-object handling the USB to dynamixel interface, instance of the dynamixel::controllers::Usb2Dynamixel class
- template <typename Protocol, typename Controller>
-
std::map<typename Protocol::id_t, std::shared_ptr<servos::BaseServo<Protocol>>>
dynamixel::auto_detect_map(const Controller &controller)¶ Auto-detect all connected actuators using a given protocol.
This function does the same as auto_detect but instead of returning a vector, it gives a map from ID to object.
- See
- auto_detect
- Return
- vector of actuators
- Parameters
controller-object handling the USB to dynamixel interface, instance of the dynamixel::controllers::Usb2Dynamixel class
- Exceptions
dynamixel::errors::Errors-if there is a problem during send
dynamixel::errors::UnpackError-if the size of received packet is not correct
Servo object (ServoBase)¶
The auto-detection will return ServoBase objects (that is, objects of sub-classes of ServoBase)
- template <typename Protocol>
-
class
dynamixel::servos::BaseServo¶ Public Types
-
typedef Protocol
protocol_t¶ type of the protocol (Protocol1 or Protocol2)
Public Functions
-
virtual long long int
id() const¶ ID of the servo.
-
virtual void
id(long long int id)¶ ??
-
virtual std::string
model_name() const¶ Name of the model (e.g. Mx12, Mx28, etc.)
-
virtual InstructionPacket<protocol_t>
ping() const¶ Ping the servo.
-
typedef Protocol