9#include "dynamixel_sdk/dynamixel_sdk.h" 
   14#include "fingermotor.hpp" 
   15#include "wristmotor.hpp" 
   17namespace uclv::dynamixel_utils
 
   26        std::string serial_port_; 
 
   28        float protocol_version_;  
 
   30        dynamixel::PortHandler *portHandler_;     
 
   31        dynamixel::PacketHandler *packetHandler_; 
 
   33        std::vector<std::shared_ptr<FingerMotor>> fingerMotors_; 
 
   34        std::vector<std::shared_ptr<WristMotor>> wristMotors_;   
 
   36        std::unique_ptr<dynamixel::GroupSyncWrite> groupSyncWrite_ = 
nullptr; 
 
   37        std::unique_ptr<dynamixel::GroupSyncRead> groupSyncRead_ = 
nullptr;   
 
   38        std::unique_ptr<dynamixel::GroupBulkRead> groupBulkRead_ = 
nullptr;   
 
   39        std::unique_ptr<dynamixel::GroupBulkWrite> groupBulkWrite_ = 
nullptr; 
 
   51        Hand(
const std::string &serial_port, 
int baudrate, 
float protocol_version,
 
   52             dynamixel::PortHandler *
const &portHandler, dynamixel::PacketHandler *
const &packetHandler);
 
   61        Hand(
const std::string &serial_port, 
int baudrate, 
float protocol_version);
 
  163        const std::vector<std::shared_ptr<FingerMotor>> &
addFingerMotor(uint8_t 
id);
 
  171        const std::vector<std::shared_ptr<WristMotor>> &
addWristMotor(uint8_t 
id);
 
  249        void moveMotors(
const std::vector<uint8_t> &ids, 
const std::vector<float> &positions);
 
 
The Hand class represents a robotic hand with multiple motors.
Definition hand.hpp:24
std::vector< uint32_t > readMotorsPositions(const std::vector< uint8_t > &ids)
Reads the positions of multiple motors using bulk read.
Definition hand.cpp:576
void setSerialPort(const std::string &serial_port)
Sets the serial port.
Definition hand.cpp:96
bool initialize()
Initializes the hand.
Definition hand.cpp:63
std::vector< std::shared_ptr< WristMotor > > getWristMotors()
Gets the wrist motors.
Definition hand.cpp:200
void moveFingerMotor(const uint8_t &id, const float &position)
Moves a finger motor to a specified position.
Definition hand.cpp:384
uint16_t readWristMotorPosition(const uint8_t &id)
Reads the position of a wrist motor.
Definition hand.cpp:471
void removeFingerMotor(uint8_t id)
Removes a finger motor from the hand.
Definition hand.cpp:336
void moveMotors(const std::vector< uint8_t > &ids, const std::vector< float > &positions)
Moves multiple motors using bulk write.
Definition hand.cpp:501
void moveWristMotor(const uint8_t &id, const float &position)
Moves a wrist motor to a specified position.
Definition hand.cpp:413
void printFingerMotors() const
Prints the finger motors.
Definition hand.cpp:286
float getProtocolVersion()
Gets the protocol version.
Definition hand.cpp:146
~Hand()
Destructor.
Definition hand.cpp:54
void setProtocolVersion(float protocol_version)
Sets the protocol version.
Definition hand.cpp:116
void printWristMotors() const
Prints the wrist motors.
Definition hand.cpp:310
void setPortHandler(dynamixel::PortHandler *portHandler)
Sets the port handler.
Definition hand.cpp:156
std::shared_ptr< WristMotor > createWristMotor(uint8_t id)
Creates a wrist motor.
Definition hand.cpp:222
Hand()
Default constructor.
Definition hand.cpp:44
void setBaudrate(int baudrate)
Sets the baudrate.
Definition hand.cpp:106
std::string getSerialPort()
Gets the serial port.
Definition hand.cpp:126
int getBaudrate()
Gets the baudrate.
Definition hand.cpp:136
const std::vector< std::shared_ptr< FingerMotor > > & addFingerMotor(uint8_t id)
Adds a finger motor to the hand.
Definition hand.cpp:236
const std::vector< std::shared_ptr< WristMotor > > & addWristMotor(uint8_t id)
Adds a wrist motor to the hand.
Definition hand.cpp:263
void setSerialPortLowLatency(const std::string &serial_port)
Sets the serial port to low latency mode.
Definition hand.cpp:176
std::shared_ptr< FingerMotor > createFingerMotor(uint8_t id)
Creates a finger motor.
Definition hand.cpp:211
void setPacketHandler(dynamixel::PacketHandler *packetHandler)
Sets the packet handler.
Definition hand.cpp:166
uint16_t readFingerMotorPosition(const uint8_t &id)
Reads the position of a finger motor.
Definition hand.cpp:441
void removeWristMotor(uint8_t id)
Removes a wrist motor from the hand.
Definition hand.cpp:359
std::vector< std::shared_ptr< FingerMotor > > getFingerMotors()
Gets the finger motors.
Definition hand.cpp:190