From 546244d48efb7bcc4b869ba78a25232619f53a76 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Fri, 6 Sep 2013 10:28:29 +0200 Subject: [PATCH] libft_adapter: correct position of abs statements --- src/libft_adapter.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libft_adapter.cpp b/src/libft_adapter.cpp index bacd2d7..24fa1c4 100644 --- a/src/libft_adapter.cpp +++ b/src/libft_adapter.cpp @@ -14,7 +14,7 @@ static pthread_mutex_t pwm_mutex = PTHREAD_MUTEX_INITIALIZER; void cb_set_output(const ::roboint::OutputConstPtr& msg) { pthread_mutex_lock(&pwm_mutex); - pwm_next[msg->num] = msg->speed; + pwm_next[msg->num] = abs(msg->speed); pthread_mutex_unlock(&pwm_mutex); } @@ -22,11 +22,11 @@ void cb_set_output(const ::roboint::OutputConstPtr& msg) { void cb_set_motor(const ::roboint::MotorConstPtr& msg) { pthread_mutex_lock(&pwm_mutex); if (msg->speed > 0) { - pwm_next[msg->num*2] = msg->speed; + pwm_next[msg->num*2] = abs(msg->speed); pwm_next[msg->num*2+1] = 0; } else { pwm_next[msg->num*2] = 0; - pwm_next[msg->num*2+1] = msg->speed; + pwm_next[msg->num*2+1] = abs(msg->speed); } pthread_mutex_unlock(&pwm_mutex); } @@ -105,7 +105,7 @@ int main(int argc, char **argv) msg.input[i] = (transfer_area->E_Main & (1<> i; } for (int i=0; i<=7; i++) { - msg.output[i] = abs(pwm[i]); + msg.output[i] = pwm[i]; pwm[i] = pwm_next[i]; if (pwm[i] == 0) { @@ -113,7 +113,7 @@ int main(int argc, char **argv) } else { transfer_area->M_Main |= (1<<(i)); } - transfer_area->MPWM_Main[i] = abs(pwm[i]); + transfer_area->MPWM_Main[i] = pwm[i]; } msg.ax = transfer_area->AX; msg.ay = transfer_area->AY; -- 2.39.5