API

class AllegroHand

Class for interfacing with the Allegro Hand.

This class provides methods to initialize, control, and retrieve data from the Allegro Hand.

Public Functions

AllegroHand()

Construct a new AllegroHand object.

virtual ~AllegroHand()

Destroy the AllegroHand object.

void init(const std::string &port, int id = 0)

Initialize the Allegro Hand.

Parameters:
  • port – The CAN interface name to connect to the hand (e.g., “can0”).

  • id – The device CAN ID (default is 0).

bool get_state(std::vector<double> &measured_position, std::vector<double> &measured_velocity, std::chrono::duration<long double> timeout = std::chrono::seconds(-1))

Get the current state of the hand.

Parameters:
  • measured_position – Vector to store the measured joint positions (rad).

  • measured_velocity – Vector to store the measured joint velocities (rad/s).

  • timeout – Timeout duration for the operation (default is infinite).

Returns:

true if the state was successfully retrieved, false otherwise.

void set_torque(const std::vector<double> &torque)

Set the torque for the joints.

Parameters:

torque – Vector of torque values to apply to the joints (N).

double get_torque_limit(const std::string &joint_name)

Get the torque limit for a specific joint.

Parameters:

joint_name – The name of the joint.

Returns:

The torque limit for the specified joint (N).

void set_torque_limit(const std::string &joint_name, double limit)

Set the torque limit for a specific joint.

Parameters:
  • joint_name – The name of the joint.

  • limit – The new torque limit for the joint (N).

std::vector<std::string> get_joint_names()

Get the names of all joints in the hand.

Returns:

A vector of joint names.

void get_imu(std::vector<double> &quaternion)

Get the IMU data from the hand.

Parameters:

quaternion – Vector to store the IMU quaternion data.

std::string get_serial()

Get the serial number of the hand.

Returns:

The serial number as a string.

std::string get_hand_version()

Get the version of the hand hardware.

Returns:

The hand version as a string.

std::string get_firmware_version()

Get the firmware version of the hand.

Returns:

The firmware version as a string.

std::string get_hand_type()

Get the type of the hand.

Returns:

The hand type as a string.

double get_finger_temperature(int id)

Get the temperature of a specific finger.

Parameters:

id – The ID of the finger.

Returns:

The temperature of the specified finger (°C).

double get_hand_temperature()

Get the overall temperature of the hand.

Returns:

The temperature of the hand (°C).

void set_device_id(uint8_t id)

Set the device CAN ID of the hand.

Parameters:

id – The new device CAN ID.