15 static LS01B obj(port, baud_rate, resolution);
38 printf(
"start ls01b\n");
49 printf(
"end ls01b\n");
74 version =
"ls01b_v2_0";
85 printf(
"startScan\n");
93 printf(
"start scan error !\n");
104 printf(
"stopScan\n");
111 printf(
"stop scan error !\n");
122 printf(
"setScanMode is_continuous = %d\n", is_continuous);
137 printf(
"setScanMode error !\n");
148 printf(
"stopRecvData\n");
156 printf(
"stopRecvData error !\n");
167 printf(
"switchData use_angle = %d\n", use_angle);
184 printf(
"switchData error !\n");
196 printf(
"setMotorSpeed rpm = %d\n", rpm);
201 data[3] = (rpm & 0xff);
202 data[2] = (rpm >> 8) & 0xff;
207 printf(
"setMotorSpeed error !\n");
218 printf(
"setResolution resolution = %f\n", resolution);
224 if (resolution == 0.25){
228 else if (resolution == 0.5){
232 else if (resolution == 1.0){
251 printf(
"setResolution error !\n");
264 uint8_t start_count = 0;
267 char * packet_bytes =
new char[
data_len_];
268 if (packet_bytes == NULL)
274 boost::posix_time::ptime t1,t2;
275 t1 = boost::posix_time::microsec_clock::universal_time();
281 int count =
serial_->
read(&header[start_count], 1);
290 if(0 == start_count){
291 if (0xA5 == (header[start_count]&0xff)){
298 else if (1 == start_count) {
299 if (0x6A == (header[start_count]&0xff) || 0x5A == (header[start_count]&0xff))
301 if (0x6A == (header[start_count]&0xff))
303 t2 = boost::posix_time::microsec_clock::universal_time();
304 boost::posix_time::millisec_posix_time_system_config::time_duration_type t_elapse;
306 real_rpm_ = 1000000.0 / t_elapse.ticks();
310 boost::unique_lock<boost::mutex> lock(
mutex_);
320 int count =
serial_->
read(&header[start_count], 4);
329 rpm_ = ((header[2]&0x7f) << 8) + (header[3]&0xff);
330 int flag = ((header[2] & 0x80) == 0) ? 0 : 1;
331 int angular_resolution = (header[4]&0xff) >> 1;
332 int start_angle = ((header[4] & 0x01) << 8) + (header[5]&0xff);
349 double distance = ((packet_bytes[i+1] & 0xFF) << 8) | (packet_bytes[i+2] & 0xFF);
353 boost::unique_lock<boost::mutex> lock(
mutex_);
int read(char *buffer, int length, int timeout=30)
static LS01B * instance(std::string port, int baud_rate, double resolution)
std_msgs::Header * header(M &m)
static LSIOSR * instance(std::string name, int speed, int fd=0)
int setMotorSpeed(int rpm)
LS01B(std::string port, int baud_rate, double resolution=0.25)
int switchData(bool use_angle)
int getScan(std::vector< ScanPoint > &points, ros::Time &scan_time, float &scan_duration)
int getVersion(std::string &version)
boost::thread * recv_thread_
int setScanMode(bool is_continuous)
std::vector< ScanPoint > scan_points_
int setResolution(double resolution)
std::vector< ScanPoint > scan_points_bak_
int send(const char *buffer, int length, int timeout=30)