Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: USBHost USBHostXpad mbed-rtos mbed
Fork of x4180_Tank by
Traxster.cpp
- Committer:
- hotwheelharry
- Date:
- 2014-11-26
- Revision:
- 3:c1620db50a75
- Parent:
- 2:5e870c215495
- Child:
- 8:36b2ef26a0b1
File content as of revision 3:c1620db50a75:
#include "Traxster.h"
#include "utils.h"
#include "rtos.h"
//extern Serial pc;
//extern Mutex m;
int getMotorSpeedInt(float f){
int max = 100;
if(f > 1.0)
f = 1.0;
if(f < -1.0)
f = -1.0;
return (int)round( (float)max * f );
}
void Traxster::SetMotors(float fm1, float fm2)
{
int m1 = getMotorSpeedInt(fm1);
int m2 = getMotorSpeedInt(fm2);
//clear robot msgs
while (rob.readable())
rob.getc();
if (m1 == 0 && m2 == 0)
{
rob.puts("stop\r");
}
else
{
//m.lock();
//pc.printf("mogo 1:%d 2:%d\r\n", m1, m2);
//m.unlock();
rob.printf("mogo 1:%d 2:%d\r", m1, m2);
}
//clear robot msgs
while (rob.readable())
rob.getc();
}
