Revision 4e393fcc
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 
} 
scout/libscout/src/MotorControl.h  

65  65 
#define MOTOR_LEFT_SPIN MOTOR_LEFT_REV  MOTOR_RIGHT 
66  66 
#define MOTOR_RIGHT_SPIN MOTOR_LEFT  MOTOR_RIGHT_REV 
67  67  
68 
#define MAXSPEED 255 

68 
#define MAXSPEED_ABS 127.0f 

69 
#define MAXSPEED_MPS 1.0f 

69  70 
#define MOTOR_PERCENT 'p' 
70  71 
#define MOTOR_MMS 'm' 
71  72 
#define MOTOR_CMS 'c' 
Also available in: Unified diff