Skip to content

Commit

Permalink
Interpolate clamp fix (#117)
Browse files Browse the repository at this point in the history
* added constexpr, removed redundant clamping

* Committing clang-format changes

---------

Co-authored-by: Clang Robot <[email protected]>
  • Loading branch information
Mokaz and Clang Robot authored Jan 8, 2024
1 parent 67cc23b commit b015729
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
5 changes: 1 addition & 4 deletions motion/thruster_interface/src/thruster_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ float ThrusterInterface::interpolate(float force) {
int pwm_signal = std::round(
pwm1 + ((force - force1) * (pwm2 - pwm1)) / (force2 - force1) + 0.5);

int clipped_pwm_signal =
std::min(std::max(pwm_signal, 1400), 1600); // min 1100, max 1900

return clipped_pwm_signal;
return pwm_signal;
}

std::vector<uint8_t>
Expand Down
3 changes: 2 additions & 1 deletion motion/thruster_interface/src/thruster_interface_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
void ThrusterInterfaceROS::thrust_callback(
const vortex_msgs::msg::ThrusterForces::SharedPtr msg) {
// Convert from Newton to grams
double newton_to_gram_conversion_factor = 101.97162;

constexpr double newton_to_gram_conversion_factor = 101.97162;

std::vector<double> forces_in_grams = {
msg->thrust[0] * newton_to_gram_conversion_factor,
Expand Down

0 comments on commit b015729

Please sign in to comment.