rplidar_driver_serial.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2014, RoboPeak
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without 
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  * 1. Redistributions of source code must retain the above copyright notice, 
00009  *    this list of conditions and the following disclaimer.
00010  *
00011  * 2. Redistributions in binary form must reproduce the above copyright notice, 
00012  *    this list of conditions and the following disclaimer in the documentation 
00013  *    and/or other materials provided with the distribution.
00014  *
00015  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
00016  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
00017  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
00018  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
00019  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00020  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
00021  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
00022  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
00023  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
00024  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
00025  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026  *
00027  */
00028 /*
00029  *  RoboPeak LIDAR System
00030  *  Serial based RPlidar Driver
00031  *
00032  *  Copyright 2009 - 2014 RoboPeak Team
00033  *  http://www.robopeak.com
00034  * 
00035  */
00036 
00037 #pragma once
00038 
00039 namespace rp { namespace standalone{ namespace rplidar {
00040 
00041 class RPlidarDriverSerialImpl : public RPlidarDriver
00042 {
00043 public:
00044 
00045     enum {
00046         MAX_SCAN_NODES = 2048,
00047     };
00048 
00049     RPlidarDriverSerialImpl();
00050     virtual ~RPlidarDriverSerialImpl();
00051 
00052 public:
00053     virtual u_result connect(const char * port_path, _u32 baudrate, _u32 flag);
00054     virtual void disconnect();
00055     virtual bool isConnected();
00056 
00057     virtual u_result reset(_u32 timeout = DEFAULT_TIMEOUT);
00058 
00059     virtual u_result getHealth(rplidar_response_device_health_t &, _u32 timeout = DEFAULT_TIMEOUT);
00060     virtual u_result getDeviceInfo(rplidar_response_device_info_t &, _u32 timeout = DEFAULT_TIMEOUT);
00061         virtual u_result getFrequency(rplidar_response_measurement_node_t * nodebuffer, size_t count, float & frequency);
00062 
00063     virtual u_result startScan(bool force, _u32 timeout = DEFAULT_TIMEOUT);
00064     virtual u_result stop(_u32 timeout = DEFAULT_TIMEOUT);
00065     virtual u_result grabScanData(rplidar_response_measurement_node_t * nodebuffer, size_t & count, _u32 timeout = DEFAULT_TIMEOUT);
00066     virtual u_result ascendScanData(rplidar_response_measurement_node_t * nodebuffer, size_t count);
00067 
00068         virtual u_result stopMotor();
00069         virtual u_result startMotor();
00070         
00071         
00072 protected:
00073     u_result _waitNode(rplidar_response_measurement_node_t * node, _u32 timeout);
00074     u_result _waitScanData(rplidar_response_measurement_node_t * nodebuffer, size_t & count, _u32 timeout = DEFAULT_TIMEOUT);
00075         u_result _cacheScanData();
00076     u_result _sendCommand(_u8 cmd, const void * payload = NULL, size_t payloadsize = 0);
00077     u_result _waitResponseHeader(rplidar_ans_header_t * header, _u32 timeout);
00078 
00079     void     _disableDataGrabbing();
00080 
00081     bool     _isConnected;
00082     bool     _isScanning;
00083 
00084         rp::hal::Locker         _lock;
00085     rp::hal::Event          _dataEvt;
00086     rp::hal::serial_rxtx  * _rxtx;
00087     rplidar_response_measurement_node_t      _cached_scan_node_buf[2048];
00088     size_t                                   _cached_scan_node_count;
00089         rp::hal::Thread _cachethread;
00090 
00091     
00092 };
00093 
00094 
00095 }}}


rplidar_ros
Author(s):
autogenerated on Fri Aug 28 2015 12:46:43