lidar code for ROC318
Dependencies: BufferedSerial mbed
inc/rplidar_protocol.h@0:0791d48ee421, 2018-10-19 (annotated)
- Committer:
- BenRJG
- Date:
- Fri Oct 19 17:42:05 2018 +0000
- Revision:
- 0:0791d48ee421
Imported lidar code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
BenRJG | 0:0791d48ee421 | 1 | /* |
BenRJG | 0:0791d48ee421 | 2 | * Copyright (c) 2014, RoboPeak |
BenRJG | 0:0791d48ee421 | 3 | * All rights reserved. |
BenRJG | 0:0791d48ee421 | 4 | * |
BenRJG | 0:0791d48ee421 | 5 | * Redistribution and use in source and binary forms, with or without |
BenRJG | 0:0791d48ee421 | 6 | * modification, are permitted provided that the following conditions are met: |
BenRJG | 0:0791d48ee421 | 7 | * |
BenRJG | 0:0791d48ee421 | 8 | * 1. Redistributions of source code must retain the above copyright notice, |
BenRJG | 0:0791d48ee421 | 9 | * this list of conditions and the following disclaimer. |
BenRJG | 0:0791d48ee421 | 10 | * |
BenRJG | 0:0791d48ee421 | 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
BenRJG | 0:0791d48ee421 | 12 | * this list of conditions and the following disclaimer in the documentation |
BenRJG | 0:0791d48ee421 | 13 | * and/or other materials provided with the distribution. |
BenRJG | 0:0791d48ee421 | 14 | * |
BenRJG | 0:0791d48ee421 | 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
BenRJG | 0:0791d48ee421 | 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
BenRJG | 0:0791d48ee421 | 17 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
BenRJG | 0:0791d48ee421 | 18 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
BenRJG | 0:0791d48ee421 | 19 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
BenRJG | 0:0791d48ee421 | 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
BenRJG | 0:0791d48ee421 | 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
BenRJG | 0:0791d48ee421 | 22 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
BenRJG | 0:0791d48ee421 | 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
BenRJG | 0:0791d48ee421 | 24 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
BenRJG | 0:0791d48ee421 | 25 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
BenRJG | 0:0791d48ee421 | 26 | * |
BenRJG | 0:0791d48ee421 | 27 | */ |
BenRJG | 0:0791d48ee421 | 28 | /* |
BenRJG | 0:0791d48ee421 | 29 | * RoboPeak LIDAR System |
BenRJG | 0:0791d48ee421 | 30 | * Data Packet IO protocol definition for RP-LIDAR |
BenRJG | 0:0791d48ee421 | 31 | * |
BenRJG | 0:0791d48ee421 | 32 | * Copyright 2009 - 2014 RoboPeak Team |
BenRJG | 0:0791d48ee421 | 33 | * http://www.robopeak.com |
BenRJG | 0:0791d48ee421 | 34 | * |
BenRJG | 0:0791d48ee421 | 35 | */ |
BenRJG | 0:0791d48ee421 | 36 | //#ifndef RPLIDAR_PROTOCOL_H |
BenRJG | 0:0791d48ee421 | 37 | //#define RPLIDAR_PROTOCOL_H |
BenRJG | 0:0791d48ee421 | 38 | |
BenRJG | 0:0791d48ee421 | 39 | #pragma once |
BenRJG | 0:0791d48ee421 | 40 | |
BenRJG | 0:0791d48ee421 | 41 | // RP-Lidar Input Packets |
BenRJG | 0:0791d48ee421 | 42 | |
BenRJG | 0:0791d48ee421 | 43 | #define RPLIDAR_CMD_SYNC_BYTE 0xA5 |
BenRJG | 0:0791d48ee421 | 44 | #define RPLIDAR_CMDFLAG_HAS_PAYLOAD 0x80 |
BenRJG | 0:0791d48ee421 | 45 | |
BenRJG | 0:0791d48ee421 | 46 | |
BenRJG | 0:0791d48ee421 | 47 | #define RPLIDAR_ANS_SYNC_BYTE1 0xA5 |
BenRJG | 0:0791d48ee421 | 48 | #define RPLIDAR_ANS_SYNC_BYTE2 0x5A |
BenRJG | 0:0791d48ee421 | 49 | |
BenRJG | 0:0791d48ee421 | 50 | #define RPLIDAR_ANS_PKTFLAG_LOOP 0x1 |
BenRJG | 0:0791d48ee421 | 51 | |
BenRJG | 0:0791d48ee421 | 52 | |
BenRJG | 0:0791d48ee421 | 53 | #if defined(_WIN32) |
BenRJG | 0:0791d48ee421 | 54 | #pragma pack(1) |
BenRJG | 0:0791d48ee421 | 55 | #endif |
BenRJG | 0:0791d48ee421 | 56 | |
BenRJG | 0:0791d48ee421 | 57 | typedef struct _rplidar_cmd_packet_t { |
BenRJG | 0:0791d48ee421 | 58 | _u8 syncByte; //must be RPLIDAR_CMD_SYNC_BYTE |
BenRJG | 0:0791d48ee421 | 59 | _u8 cmd_flag; |
BenRJG | 0:0791d48ee421 | 60 | _u8 size; |
BenRJG | 0:0791d48ee421 | 61 | _u8 data[0]; |
BenRJG | 0:0791d48ee421 | 62 | } __attribute__((packed)) rplidar_cmd_packet_t; |
BenRJG | 0:0791d48ee421 | 63 | |
BenRJG | 0:0791d48ee421 | 64 | |
BenRJG | 0:0791d48ee421 | 65 | typedef struct _rplidar_ans_header_t { |
BenRJG | 0:0791d48ee421 | 66 | _u8 syncByte1; // must be RPLIDAR_ANS_SYNC_BYTE1 |
BenRJG | 0:0791d48ee421 | 67 | _u8 syncByte2; // must be RPLIDAR_ANS_SYNC_BYTE2 |
BenRJG | 0:0791d48ee421 | 68 | _u32 size:30; |
BenRJG | 0:0791d48ee421 | 69 | _u32 subType:2; |
BenRJG | 0:0791d48ee421 | 70 | _u8 type; |
BenRJG | 0:0791d48ee421 | 71 | } __attribute__((packed)) rplidar_ans_header_t; |
BenRJG | 0:0791d48ee421 | 72 | |
BenRJG | 0:0791d48ee421 | 73 | #if defined(_WIN32) |
BenRJG | 0:0791d48ee421 | 74 | #pragma pack() |
BenRJG | 0:0791d48ee421 | 75 | #endif |