Class blmc_drivers::BlmcJointModules

template<int COUNT>
class BlmcJointModules

This class defines an interface to a collection of BLMC joints.

It creates a BLMCJointModule for every blmc_driver::MotorInterface provided.

Template Parameters:

COUNT

Public Types

typedef Eigen::Matrix<double, COUNT, 1> Vector

Defines a static Eigen vector type in order to define the interface.

typedef Eigen::Matrix<double, COUNT, 1> Vector

Defines a static Eigen vector type in order to define the interface.

Public Functions

inline BlmcJointModules(const std::array<std::shared_ptr<blmc_drivers::MotorInterface>, COUNT> &motors, const Vector &motor_constants, const Vector &gear_ratios, const Vector &zero_angles, const Vector &max_currents)

Construct a new BlmcJointModules object.

Parameters:
  • motors

  • motor_constants

  • gear_ratios

  • zero_angles

inline BlmcJointModules()

Construct a new BlmcJointModules object.

inline void set_motor_array(const std::array<std::shared_ptr<blmc_drivers::MotorInterface>, COUNT> &motors, const Vector &motor_constants, const Vector &gear_ratios, const Vector &zero_angles, const Vector &max_currents)

Set the motor array, by creating the corresponding modules.

Parameters:
  • motors

  • motor_constants

  • gear_ratios

  • zero_angles

inline void send_torques()

Send the registered torques to all modules.

inline void set_joint_polarities(std::array<bool, COUNT> reverse_polarities)

Set the polarities of the joints (see BlmcJointModule::set_joint_polarity)

Parameters:

reverse_polarity

inline void set_torques(const Vector &desired_torques)

Register the joint torques to be sent for all modules.

Parameters:

desired_torques – (Nm)

inline Vector get_max_torques()

Get the maximum admissible joint torque that can be applied.

Returns:

Vector (N/m)

inline Vector get_sent_torques() const

Get the previously sent torques.

Returns:

Vector (Nm)

inline Vector get_measured_torques() const

Get the measured joint torques.

Returns:

Vector (Nm)

inline Vector get_measured_angles() const

Get the measured joint angles.

Returns:

Vector (rad)

inline Vector get_measured_velocities() const

Get the measured joint velocities.

Returns:

Vector (rad/s)

inline void set_zero_angles(const Vector &zero_angles)

Set the zero_angles.

These are the joint angles between the starting pose and the zero theoretical pose of the urdf.

Parameters:

zero_angles – (rad)

inline Vector get_zero_angles() const

Get the zero_angles.

These are the joint angles between the starting pose and the zero theoretical pose of the urdf.

Returns:

Vector (rad)

inline Vector get_measured_index_angles() const

Get the index_angles.

There is one index per motor rotation so there are gear_ratio indexes per joint rotation.

Returns:

Vector (rad)

inline void set_position_control_gains(size_t joint_id, double kp, double kd)

Set position control gains for the specified joint.

Parameters:
  • joint_id – ID of the joint (in range [0, COUNT)).

  • kp – P gain.

  • kd – D gain.

inline void set_position_control_gains(Vector kp, Vector kd)

Set position control gains for all joints.

Parameters:
  • kp – P gains.

  • kd – D gains.

inline HomingReturnCode execute_homing_at_current_position(Vector home_offset_rad)

Perform homing for all joints at endstops.

See BlmcJointModule::homing_at_current_position for description of the arguments.

Returns:

Final status of the homing procedure (since homing happens at current,position, procedure always returns success).

inline HomingReturnCode execute_homing(double search_distance_limit_rad, Vector home_offset_rad, Vector profile_step_size_rad = Vector::Constant(0.001))

Perform homing for all joints.

If one of the joints fails, the complete homing fails. Otherwise it loops until all joints finished. If a joint is finished while others are still running, it is held at the home position.

See BlmcJointModule::update_homing for details on the homing procedure.

See BlmcJointModule::init_homing for description of the arguments.

Returns:

Final status of the homing procedure (either SUCCESS if all joints succeeded or the return code of the first joint that failed).

inline Vector get_distance_travelled_during_homing() const

See also

BlmcJointModule::get_distance_travelled_during_homing

inline GoToReturnCode go_to(Vector angle_to_reach_rad, double average_speed_rad_per_sec = 1.0)

Allow the robot to go to a desired pose.

Once the control done 0 torques is sent.

Parameters:
  • angle_to_reach_rad – (rad)

  • average_speed_rad_per_sec – (rad/sec)

Returns:

GoToReturnCode

inline BlmcJointModules(const std::array<std::shared_ptr<blmc_drivers::MotorInterface>, COUNT> &motors, const Vector &motor_constants, const Vector &gear_ratios, const Vector &zero_angles, const Vector &max_currents)

Construct a new BlmcJointModules object.

Parameters:
  • motors

  • motor_constants

  • gear_ratios

  • zero_angles

inline BlmcJointModules()

Construct a new BlmcJointModules object.

inline void set_motor_array(const std::array<std::shared_ptr<blmc_drivers::MotorInterface>, COUNT> &motors, const Vector &motor_constants, const Vector &gear_ratios, const Vector &zero_angles, const Vector &max_currents)

Set the motor array, by creating the corresponding modules.

Parameters:
  • motors

  • motor_constants

  • gear_ratios

  • zero_angles

inline void send_torques()

Send the registered torques to all modules.

inline void set_joint_polarities(std::array<bool, COUNT> reverse_polarities)

Set the polarities of the joints (see BlmcJointModule::set_joint_polarity)

Parameters:

reverse_polarity

inline void set_torques(const Vector &desired_torques)

Register the joint torques to be sent for all modules.

Parameters:

desired_torques – (Nm)

inline Vector get_max_torques()

Get the maximum admissible joint torque that can be applied.

Returns:

Vector (N/m)

inline Vector get_sent_torques() const

Get the previously sent torques.

Returns:

Vector (Nm)

inline Vector get_measured_torques() const

Get the measured joint torques.

Returns:

Vector (Nm)

inline Vector get_measured_angles() const

Get the measured joint angles.

Returns:

Vector (rad)

inline Vector get_measured_velocities() const

Get the measured joint velocities.

Returns:

Vector (rad/s)

inline void set_zero_angles(const Vector &zero_angles)

Set the zero_angles.

These are the joint angles between the starting pose and the zero theoretical pose of the urdf.

Parameters:

zero_angles – (rad)

inline Vector get_zero_angles() const

Get the zero_angles.

These are the joint angles between the starting pose and the zero theoretical pose of the urdf.

Returns:

Vector (rad)

inline Vector get_measured_index_angles() const

Get the index_angles.

There is one index per motor rotation so there are gear_ratio indexes per joint rotation.

Returns:

Vector (rad)

inline void set_position_control_gains(size_t joint_id, double kp, double kd)

Set position control gains for the specified joint.

Parameters:
  • joint_id – ID of the joint (in range [0, COUNT)).

  • kp – P gain.

  • kd – D gain.

inline void set_position_control_gains(Vector kp, Vector kd)

Set position control gains for all joints.

Parameters:
  • kp – P gains.

  • kd – D gains.

inline HomingReturnCode execute_homing_at_current_position(Vector home_offset_rad)

Perform homing for all joints at endstops.

See BlmcJointModule::homing_at_current_position for description of the arguments.

Returns:

Final status of the homing procedure (since homing happens at current,position, procedure always returns success).

inline HomingReturnCode execute_homing(double search_distance_limit_rad, Vector home_offset_rad, Vector profile_step_size_rad = Vector::Constant(0.001))

Perform homing for all joints.

If one of the joints fails, the complete homing fails. Otherwise it loops until all joints finished. If a joint is finished while others are still running, it is held at the home position.

See BlmcJointModule::update_homing for details on the homing procedure.

See BlmcJointModule::init_homing for description of the arguments.

Returns:

Final status of the homing procedure (either SUCCESS if all joints succeeded or the return code of the first joint that failed).

inline Vector get_distance_travelled_during_homing() const

See also

BlmcJointModule::get_distance_travelled_during_homing

inline GoToReturnCode go_to(Vector angle_to_reach_rad, double average_speed_rad_per_sec = 1.0)

Allow the robot to go to a desired pose.

Once the control done 0 torques is sent.

Parameters:
  • angle_to_reach_rad – (rad)

  • average_speed_rad_per_sec – (rad/sec)

Returns:

GoToReturnCode