Skip to content
Snippets Groups Projects
Commit 3bd787ae authored by Paul Beuchat's avatar Paul Beuchat
Browse files

Small correction to rounding behaviour in Pololu SMC G2 driver

parent d59451d2
Branches
No related tags found
1 merge request!14Small correction to rounding behaviour in Pololu SMC G2 driver
......@@ -498,7 +498,7 @@ bool Pololu_SMC_G2::set_motor_target_speed_percent(int target_speed)
bool Pololu_SMC_G2::set_motor_target_speed_percent(float target_speed)
{
// Convert the percent to the nearest 3200 integer
int target_speed_3200 = static_cast<int>( target_speed * 32.0f );
int target_speed_3200 = static_cast<int>( std::round(target_speed * 32.0f) );
// Call the function for signed 3200 speeds
return this->set_motor_target_speed_3200(target_speed_3200);
}
......
......@@ -44,6 +44,7 @@
#include <unistd.h>
#include <iostream>
#include <bitset>
#include <cmath>
#include "pololu_smc_g2/pololu_smc_g2_constants.h"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment