Class blmc_drivers::BlmcJointModule¶
-
class BlmcJointModule¶
The BlmcJointModule class is containing the joint information.
It is here to help converting the data from the motor side to the joint side. It also allows the calibration of the joint position during initialization.
Public Functions
Construct a new BlmcJointModule object.
- Parameters:
motor – is the C++ object allowing us to send commands and receive sensor data.
motor_constant – ( \( k \)) is the torque constant of the motor \( \tau_{motor} = k * i_{motor} \)
gear_ratio – is the gear ratio between the motor and the joint.
zero_angle – is the angle between the closest positive motor index and the zero configuration.
reverse_polarity –
max_current –
-
void set_torque(const double &desired_torque)¶
Set the joint torque to be sent.
- Parameters:
desired_torque – (Nm)
-
void set_zero_angle(const double &zero_angle)¶
Set the zero_angle.
The zero_angle is the angle between the closest positive motor index and the zero configuration.
- Parameters:
zero_angle – (rad)
-
void set_joint_polarity(const bool &reverse_polarity)¶
Define if the motor should turn clock-wize or counter clock-wize.
- Parameters:
reverse_polarity – true:reverse rotation axis, false:do nothing.
-
void send_torque()¶
send the joint torque to the motor.
The conversion between joint torque and motor current is done automatically.
-
double get_max_torque() const¶
Get the maximum admissible joint torque that can be applied.
- Returns:
double
-
double get_sent_torque() const¶
Get the sent joint torque.
- Returns:
double (Nm).
-
double get_measured_torque() const¶
Get the measured joint torque.
- Returns:
double (Nm).
-
double get_measured_angle() const¶
Get the measured angle of the joint.
- Returns:
double (rad).
-
double get_measured_velocity() const¶
Get the measured velocity of the joint.
This data is computed on board of the control card.
- Returns:
double (rad/s).
-
double get_measured_index_angle() const¶
Get the measured index angle.
There is one index per motor rotation so there are gear_ratio indexes per joint rotation.
- Returns:
double (rad).
-
double get_zero_angle() const¶
Get the zero_angle_.
These are the angle between the starting pose and the theoretical zero pose.
- Returns:
double (rad).
-
void set_position_control_gains(double kp, double kd)¶
Set control gains for PD position controller.
- Parameters:
kp – P gain ( (Nm) / rad ).
kd – D gain ( (Nm) / (rad/s) ).
-
double execute_position_controller(double target_position_rad) const¶
Execute one iteration of the position controller.
- Parameters:
target_position_rad – Target position (rad).
- Returns:
Torque command (Nm).
-
bool calibrate(double &angle_zero_to_index, double &index_angle, bool mechanical_calibration = false)¶
This method calibrate the joint position knowing the angle between the closest (in positive torque) motor index and the theoretical zero pose.
- Deprecated:
!!!!!!!
- Param :
-
void homing_at_current_position(double home_offset_rad)¶
Set zero position relative to current position.
- Parameters:
home_offset_rad – Offset from home position to zero position. Unit: radian.
-
void init_homing(int joint_id, double search_distance_limit_rad, double home_offset_rad, double profile_step_size_rad = 0.001)¶
Initialize the homing procedure.
This has to be called before update_homing().
- Parameters:
joint_id – ID of the joint. This is only used for debug prints.
search_distance_limit_rad – Maximum distance the motor moves while searching for the encoder index. Unit: radian.
home_offset_rad – Offset from home position to zero position. Unit: radian.
profile_step_size_rad – Distance by which the target position of the position profile is changed in each step. Set to a negative value to search for the next encoder index in negative direction. Unit: radian.
-
HomingReturnCode update_homing()¶
Perform one step of homing on encoder index.
Searches for the next encoder index in positive direction and, when found, sets it as home position.
Only performs one step, so this method needs to be called in a loop. This method only set the control, one MUST send the control for the motor after calling this method.
The motor is moved with a position profile until either the encoder index is reached or the search distance limit is exceeded. The position is controlled with a simple PD controller.
If the encoder index is found, its position is used as home position. The zero position is offset from the home position by adding the “home
offset” to it (i.e. zero = home pos. + home offset). If the search distance limit is reached before the encoder index occurs, the homing fails.
- Returns:
Status of the homing procedure.
-
double get_distance_travelled_during_homing() const¶
Get distance between start and end position of homing.
Compute the distance that the joint moved between initialization of homing and reaching the home position.
This can be used to determine the home offset by first moving the joint to the desired zero position, then executing the homing and finally calling this function which will provide the desired home offset.
- Returns:
Distance between start and end position of homing.
-
BlmcJointModule(std::shared_ptr<blmc_drivers::MotorInterface> motor, const double &motor_constant, const double &gear_ratio, const double &zero_angle, const bool &reverse_polarity = false, const double &max_current = 2.1)
Construct a new BlmcJointModule object.
- Parameters:
motor – is the C++ object allowing us to send commands and receive sensor data.
motor_constant – ( \( k \)) is the torque constant of the motor \( \tau_{motor} = k * i_{motor} \)
gear_ratio – is the gear ratio between the motor and the joint.
zero_angle – is the angle between the closest positive motor index and the zero configuration.
reverse_polarity –
max_current –
-
void set_torque(const double &desired_torque)
Set the joint torque to be sent.
- Parameters:
desired_torque – (Nm)
-
void set_zero_angle(const double &zero_angle)
Set the zero_angle.
The zero_angle is the angle between the closest positive motor index and the zero configuration.
- Parameters:
zero_angle – (rad)
-
void set_joint_polarity(const bool &reverse_polarity)
Define if the motor should turn clock-wize or counter clock-wize.
- Parameters:
reverse_polarity – true:reverse rotation axis, false:do nothing.
-
void send_torque()
send the joint torque to the motor.
The conversion between joint torque and motor current is done automatically.
-
double get_max_torque() const
Get the maximum admissible joint torque that can be applied.
- Returns:
double
-
double get_sent_torque() const
Get the sent joint torque.
- Returns:
double (Nm).
-
double get_measured_torque() const
Get the measured joint torque.
- Returns:
double (Nm).
-
double get_measured_angle() const
Get the measured angle of the joint.
- Returns:
double (rad).
-
double get_measured_velocity() const
Get the measured velocity of the joint.
This data is computed on board of the control card.
- Returns:
double (rad/s).
-
double get_measured_index_angle() const
Get the measured index angle.
There is one index per motor rotation so there are gear_ratio indexes per joint rotation.
- Returns:
double (rad).
-
double get_zero_angle() const
Get the zero_angle_.
These are the angle between the starting pose and the theoretical zero pose.
- Returns:
double (rad).
-
void set_position_control_gains(double kp, double kd)
Set control gains for PD position controller.
- Parameters:
kp – P gain ( (Nm) / rad ).
kd – D gain ( (Nm) / (rad/s) ).
-
double execute_position_controller(double target_position_rad) const
Execute one iteration of the position controller.
- Parameters:
target_position_rad – Target position (rad).
- Returns:
Torque command (Nm).
-
bool calibrate(double &angle_zero_to_index, double &index_angle, bool mechanical_calibration = false)
This method calibrate the joint position knowing the angle between the closest (in positive torque) motor index and the theoretical zero pose.
- Deprecated:
!!!!!!!
- Param :
-
void homing_at_current_position(double home_offset_rad)
Set zero position relative to current position.
- Parameters:
home_offset_rad – Offset from home position to zero position. Unit: radian.
-
void init_homing(int joint_id, double search_distance_limit_rad, double home_offset_rad, double profile_step_size_rad = 0.001)
Initialize the homing procedure.
This has to be called before update_homing().
- Parameters:
joint_id – ID of the joint. This is only used for debug prints.
search_distance_limit_rad – Maximum distance the motor moves while searching for the encoder index. Unit: radian.
home_offset_rad – Offset from home position to zero position. Unit: radian.
profile_step_size_rad – Distance by which the target position of the position profile is changed in each step. Set to a negative value to search for the next encoder index in negative direction. Unit: radian.
-
HomingReturnCode update_homing()
Perform one step of homing on encoder index.
Searches for the next encoder index in positive direction and, when found, sets it as home position.
Only performs one step, so this method needs to be called in a loop. This method only set the control, one MUST send the control for the motor after calling this method.
The motor is moved with a position profile until either the encoder index is reached or the search distance limit is exceeded. The position is controlled with a simple PD controller.
If the encoder index is found, its position is used as home position. The zero position is offset from the home position by adding the “home
offset” to it (i.e. zero = home pos. + home offset). If the search distance limit is reached before the encoder index occurs, the homing fails.
- Returns:
Status of the homing procedure.
-
double get_distance_travelled_during_homing() const
Get distance between start and end position of homing.
Compute the distance that the joint moved between initialization of homing and reaching the home position.
This can be used to determine the home offset by first moving the joint to the desired zero position, then executing the homing and finally calling this function which will provide the desired home offset.
- Returns:
Distance between start and end position of homing.