Revision 4e393fcc
Added code for unit conversion, pending tests.
scout/libscout/src/MotorControl.cpp  

235  235 
case MOTOR_ABSOLUTE:/* Speed given as absolute */ 
236  236 
return rel_speed; 
237  237 
case MOTOR_PERCENT:/* Convert from percentage */ 
238 
return rel_speed * MAXSPEED / 100;


238 
return rel_speed * MAXSPEED_ABS / 100.0;


239  239 
case MOTOR_MMS:/* Convert from mm/s */ 
240 
/** @todo Make math to do this conversion **/ 

241 
return rel_speed; 

240 
return rel_speed * MAXSPEED_ABS * 100.0 / MAXSPEED_MPS; 

242  241 
case MOTOR_CMS:/* Convert from cm/s */ 
243 
/** @todo Make math to do this conversion **/ 

244 
return rel_speed; 

242 
return rel_speed * MAXSPEED_ABS * 10.0 / MAXSPEED_MPS; 

245  243 
default: /* The units aren't recognized */ 
246 
/** @todo Decide on default case. Either percent or absolute. **/


244 
ROS_WARN("MotorControl::rel_to_abs used with default units.");


247  245 
return rel_speed; 
248  246 
} 
249  247 
} 
...  ...  
262  260 
case MOTOR_ABSOLUTE:/* Speed given as absolute */ 
263  261 
return abs_speed; 
264  262 
case MOTOR_PERCENT:/* Convert from percentage */ 
265 
return abs_speed * 100 / MAXSPEED;


263 
return abs_speed * 100.0 / MAXSPEED_ABS;


266  264 
case MOTOR_MMS:/* Convert from mm/s */ 
267 
/** @todo Make math to do this conversion **/ 

268 
return abs_speed; 

265 
return abs_speed * MAXSPEED_MPS / (MAXSPEED_ABS * 100.0); 

269  266 
case MOTOR_CMS:/* Convert from cm/s */ 
270 
/** @todo Make math to do this conversion **/ 

271 
return abs_speed; 

267 
return abs_speed * MAXSPEED_MPS / (MAXSPEED_ABS * 10.0); 

272  268 
default: /* The units aren't recognized */ 
273 
/** @todo Decide on default case. Either percent or absolute. **/


269 
ROS_WARN("MotorControl::rel_to_abs used with default units.");


274  270 
return abs_speed; 
275  271 
} 
276  272 
} 
Also available in: Unified diff