Skip to content

Commit

Permalink
Closes #3; fix: Remove unnecessary exceptions for maximum speed, curr…
Browse files Browse the repository at this point in the history
…ent and position
  • Loading branch information
2b-t committed Mar 2, 2024
1 parent ac05c77 commit ebcd4d3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 24 deletions.
8 changes: 4 additions & 4 deletions include/myactuator_rmd/actuator_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ namespace myactuator_rmd {
* Send a current set-point to the actuator
*
* \param[in] current
* The current set-point in Ampere [-20.00, 20.00]
* The current set-point in Ampere
* \return
* Feedback control message containing actuator position, velocity, torque and temperature
*/
Expand All @@ -255,9 +255,9 @@ namespace myactuator_rmd {
* Send an absolute position set-point to the actuator additionally specifying a maximum velocity
*
* \param[in] position
* The position set-point in degree [-360.00, 360.00]
* The position set-point in degree
* \param[in] max_speed
* The maximum speed for the motion in degree per second [-1320.0, 1320.0]
* The maximum speed for the motion in degree per second
* \return
* Feedback control message containing actuator position, velocity, torque and temperature
*/
Expand All @@ -282,7 +282,7 @@ namespace myactuator_rmd {
* Send a velocity set-point to the actuator
*
* \param[in] speed
* The speed set-point in degree per second [-1320.00, 1320.00]
* The speed set-point in degree per second
* \return
* Feedback control message containing actuator position, velocity, torque and temperature
*/
Expand Down
16 changes: 8 additions & 8 deletions include/myactuator_rmd/protocol/requests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@ namespace myactuator_rmd {
* Class constructor
*
* \param[in] position
* The position set-point in degree [0.00, 360.00]
* The position set-point in degree
* \param[in] max_speed
* The maximum speed for the motion in degree per second [0.0, 1320.0]
* The maximum speed for the motion in degree per second
*/
SetPositionAbsoluteRequest(float const position, float const max_speed);
SetPositionAbsoluteRequest() = delete;
Expand All @@ -289,7 +289,7 @@ namespace myactuator_rmd {
* Get the maximum speed
*
* \return
* The maximum speed for the motion in degree per second [-1320.0, 1320.0]
* The maximum speed for the motion in degree per second
*/
[[nodiscard]]
float getMaxSpeed() const noexcept;
Expand All @@ -299,7 +299,7 @@ namespace myactuator_rmd {
* Get the position
*
* \return
* The position set-point in degree [-360.00, 360.00]
* The position set-point in degree
*/
[[nodiscard]]
float getPosition() const noexcept;
Expand Down Expand Up @@ -348,7 +348,7 @@ namespace myactuator_rmd {
* Class constructor
*
* \param[in] current
* The current set-point in Ampere [-20.00, 20.00]
* The current set-point in Ampere
*/
SetTorqueRequest(float const current);
SetTorqueRequest() = delete;
Expand All @@ -363,7 +363,7 @@ namespace myactuator_rmd {
* Get the torque current
*
* \return
* The torque current in Ampere [-20.00, 20.00]
* The torque current in Ampere
*/
[[nodiscard]]
float getTorqueCurrent() const noexcept;
Expand All @@ -380,7 +380,7 @@ namespace myactuator_rmd {
* Class constructor
*
* \param[in] speed
* The velocity set-point in degree per second [-1320.00, 1320.00]
* The velocity set-point in degree per second
*/
SetVelocityRequest(float const speed);
SetVelocityRequest() = delete;
Expand All @@ -395,7 +395,7 @@ namespace myactuator_rmd {
* Get the velocity set-point
*
* \return
* The speed for the motion in degree per second [-1320.0, 1320.0]
* The speed for the motion in degree per second
*/
[[nodiscard]]
float getSpeed() const noexcept;
Expand Down
12 changes: 0 additions & 12 deletions src/protocol/requests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ namespace myactuator_rmd {

SetPositionAbsoluteRequest::SetPositionAbsoluteRequest(float const position, float const max_speed)
: SingleMotorRequest{} {
if ((position < -360.0f) || (position > 360.0f)) {
throw ValueRangeException("Position value '" + std::to_string(position) + "' out of range [0.0, 360.0]");
}
if ((max_speed < -1320.0f) || (max_speed > 1320.0f)) {
throw ValueRangeException("Maximum speed value '" + std::to_string(max_speed) + "' out of range [0.0, 1320.0]");
}
auto const v {static_cast<std::uint16_t>(max_speed)};
auto const pos {static_cast<std::int32_t>(position*100.0f)};
setAt(v, 2);
Expand All @@ -98,9 +92,6 @@ namespace myactuator_rmd {

SetTorqueRequest::SetTorqueRequest(float const current)
: SingleMotorRequest{} {
if ((current < -20.0f) || (current > 20.0f)) {
throw ValueRangeException("Current value '" + std::to_string(current) + "' out of range [-20.0, 20.0]");
}
auto const c {static_cast<std::int16_t>(current/0.01f)};
setAt(c, 4);
return;
Expand All @@ -122,9 +113,6 @@ namespace myactuator_rmd {

SetVelocityRequest::SetVelocityRequest(float const speed)
: SingleMotorRequest{} {
if ((speed < -1320.0f) || (speed > 1320.0f)) {
throw ValueRangeException("Speed value '" + std::to_string(speed) + "' out of range [-1320.0, 1320.0]");
}
auto const s {static_cast<std::int32_t>(speed*100.0f)};
setAt(s, 4);
return;
Expand Down

0 comments on commit ebcd4d3

Please sign in to comment.