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.
main.cpp
- Committer:
- LuisRA
- Date:
- 2019-04-09
- Revision:
- 0:2b691d200d6f
- Child:
- 1:dc87724abce8
File content as of revision 0:2b691d200d6f:
#include "mbed.h"
#include "BufferedSerial.h"
#include "rplidar.h"
Serial pc(SERIAL_TX, SERIAL_RX, 1000000);
RPLidar lidar;
BufferedSerial se_lidar(PA_9, PA_10);
PwmOut rplidar_motor(A3);
int main()
{
pc.baud(1000000);//115200);
pc.printf("main\n");
wait(1);
rplidar_motor.period(0.001f);
lidar.begin(se_lidar);
lidar.setAngle(0,360);
pc.printf("Program started.\n");
lidar.startThreadScan();
while(1) {
struct RPLidarMeasurement data;
// poll for measurements. Returns -1 if no new measurements are available. returns 0 if found one.
if(lidar.pollSensorData(&data) == 0)
{
pc.printf("%f\t%f\t%d\t%c\n", data.distance, data.angle, data.quality, data.startBit);
}
wait(0.1);
}
}