Skip to content

Commit

Permalink
feat: Add method for torque control using torque constant
Browse files Browse the repository at this point in the history
  • Loading branch information
2b-t committed Nov 19, 2023
1 parent dbae6b4 commit 4e73165
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
1 change: 1 addition & 0 deletions bindings/myactuator_rmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ PYBIND11_MODULE(myactuator_rmd, m) {
.def("lockBrake", &myactuator_rmd::Driver::lockBrake)
.def("releaseBrake", &myactuator_rmd::Driver::releaseBrake)
.def("reset", &myactuator_rmd::Driver::reset)
.def("sendCurrentSetpoint", &myactuator_rmd::Driver::sendCurrentSetpoint)
.def("sendPositionAbsoluteSetpoint", &myactuator_rmd::Driver::sendPositionAbsoluteSetpoint)
.def("sendTorqueSetpoint", &myactuator_rmd::Driver::sendTorqueSetpoint)
.def("sendVelocitySetpoint", &myactuator_rmd::Driver::sendVelocitySetpoint)
Expand Down
21 changes: 17 additions & 4 deletions include/myactuator_rmd/driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,17 @@ namespace myactuator_rmd {
*/
void reset();

/**\fn sendCurrentSetpoint
* \brief
* Send a current set-point to the actuator
*
* \param[in] current
* The current set-point in Ampere [-20.00, 20.00]
* \return
* Feedback control message containing actuator position, velocity, torque and temperature
*/
Feedback sendCurrentSetpoint(float const current);

/**\fn sendPositionAbsoluteSetpoint
* \brief
* Send an absolute position set-point to the actuator additionally specifying a maximum velocity
Expand All @@ -251,14 +262,16 @@ namespace myactuator_rmd {

/**\fn sendTorqueSetpoint
* \brief
* Send a torque set-point to the actuator by specifying the current
* Send a torque set-point to the actuator by setting the current
*
* \param[in] current
* The current set-point in Ampere [-20.00, 20.00]
* \param[in] torque
* The desired torque in [Nm]
* \param[in] torque_constant
* The motor's torque constant [Nm/A], depends on the model of the motor
* \return
* Feedback control message containing actuator position, velocity, torque and temperature
*/
Feedback sendTorqueSetpoint(float const current);
Feedback sendTorqueSetpoint(float const torque, float const torque_constant = 2.09);

/**\fn sendVelocitySetpoint
* \brief
Expand Down
13 changes: 9 additions & 4 deletions src/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,21 @@ namespace myactuator_rmd {
return;
}

Feedback Driver::sendCurrentSetpoint(float const current) {
SetTorqueRequest const request {current};
auto const response {sendRecv<SetTorqueResponse>(request)};
return response.getStatus();
}

Feedback Driver::sendPositionAbsoluteSetpoint(float const position, float const max_speed) {
SetPositionAbsoluteRequest const request {position, max_speed};
auto const response {sendRecv<SetPositionAbsoluteResponse>(request)};
return response.getStatus();
}

Feedback Driver::sendTorqueSetpoint(float const current) {
SetTorqueRequest const request {current};
auto const response {sendRecv<SetTorqueResponse>(request)};
return response.getStatus();
Feedback Driver::sendTorqueSetpoint(float const torque, float const torque_constant) {
auto const current {torque/torque_constant};
return sendCurrentSetpoint(current);
}

Feedback Driver::sendVelocitySetpoint(float const speed) {
Expand Down

0 comments on commit 4e73165

Please sign in to comment.