Skip to content

Commit

Permalink
added constexpr, removed redundant clamping
Browse files Browse the repository at this point in the history
  • Loading branch information
Mokaz committed Jan 1, 2024
1 parent 67cc23b commit 8e7601a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
7 changes: 2 additions & 5 deletions motion/thruster_interface/src/thruster_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,8 @@ 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 8e7601a

Please sign in to comment.