Pierre-Yves Malengre
/
Lidar
Lidar program
inc/rplidar_protocol.h@0:1d10a6e6808c, 2021-03-03 (annotated)
- Committer:
- pymal
- Date:
- Wed Mar 03 21:49:13 2021 +0000
- Revision:
- 0:1d10a6e6808c
Trying to publish Lidar program
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pymal | 0:1d10a6e6808c | 1 | /* |
pymal | 0:1d10a6e6808c | 2 | * RPLIDAR SDK for Mbed |
pymal | 0:1d10a6e6808c | 3 | * |
pymal | 0:1d10a6e6808c | 4 | * Copyright (c) 2009 - 2014 RoboPeak Team |
pymal | 0:1d10a6e6808c | 5 | * http://www.robopeak.com |
pymal | 0:1d10a6e6808c | 6 | * Copyright (c) 2014 - 2019 Shanghai Slamtec Co., Ltd. |
pymal | 0:1d10a6e6808c | 7 | * http://www.slamtec.com |
pymal | 0:1d10a6e6808c | 8 | * |
pymal | 0:1d10a6e6808c | 9 | */ |
pymal | 0:1d10a6e6808c | 10 | /* |
pymal | 0:1d10a6e6808c | 11 | * Redistribution and use in source and binary forms, with or without |
pymal | 0:1d10a6e6808c | 12 | * modification, are permitted provided that the following conditions are met: |
pymal | 0:1d10a6e6808c | 13 | * |
pymal | 0:1d10a6e6808c | 14 | * 1. Redistributions of source code must retain the above copyright notice, |
pymal | 0:1d10a6e6808c | 15 | * this list of conditions and the following disclaimer. |
pymal | 0:1d10a6e6808c | 16 | * |
pymal | 0:1d10a6e6808c | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
pymal | 0:1d10a6e6808c | 18 | * this list of conditions and the following disclaimer in the documentation |
pymal | 0:1d10a6e6808c | 19 | * and/or other materials provided with the distribution. |
pymal | 0:1d10a6e6808c | 20 | * |
pymal | 0:1d10a6e6808c | 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
pymal | 0:1d10a6e6808c | 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
pymal | 0:1d10a6e6808c | 23 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
pymal | 0:1d10a6e6808c | 24 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
pymal | 0:1d10a6e6808c | 25 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
pymal | 0:1d10a6e6808c | 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
pymal | 0:1d10a6e6808c | 27 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
pymal | 0:1d10a6e6808c | 28 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
pymal | 0:1d10a6e6808c | 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
pymal | 0:1d10a6e6808c | 30 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
pymal | 0:1d10a6e6808c | 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
pymal | 0:1d10a6e6808c | 32 | * |
pymal | 0:1d10a6e6808c | 33 | */ |
pymal | 0:1d10a6e6808c | 34 | |
pymal | 0:1d10a6e6808c | 35 | #pragma once |
pymal | 0:1d10a6e6808c | 36 | #include "mbed.h" |
pymal | 0:1d10a6e6808c | 37 | // RP-Lidar Input Packets |
pymal | 0:1d10a6e6808c | 38 | |
pymal | 0:1d10a6e6808c | 39 | #define RPLIDAR_CMD_SYNC_BYTE 0xA5 |
pymal | 0:1d10a6e6808c | 40 | #define RPLIDAR_CMDFLAG_HAS_PAYLOAD 0x80 |
pymal | 0:1d10a6e6808c | 41 | |
pymal | 0:1d10a6e6808c | 42 | |
pymal | 0:1d10a6e6808c | 43 | #define RPLIDAR_ANS_SYNC_BYTE1 0xA5 |
pymal | 0:1d10a6e6808c | 44 | #define RPLIDAR_ANS_SYNC_BYTE2 0x5A |
pymal | 0:1d10a6e6808c | 45 | |
pymal | 0:1d10a6e6808c | 46 | #define RPLIDAR_ANS_PKTFLAG_LOOP 0x1 |
pymal | 0:1d10a6e6808c | 47 | |
pymal | 0:1d10a6e6808c | 48 | #define RPLIDAR_ANS_HEADER_SIZE_MASK 0x3FFFFFFF |
pymal | 0:1d10a6e6808c | 49 | #define RPLIDAR_ANS_HEADER_SUBTYPE_SHIFT (30) |
pymal | 0:1d10a6e6808c | 50 | |
pymal | 0:1d10a6e6808c | 51 | typedef struct _rplidar_cmd_packet_t { |
pymal | 0:1d10a6e6808c | 52 | uint8_t syncByte; //must be RPLIDAR_CMD_SYNC_BYTE |
pymal | 0:1d10a6e6808c | 53 | uint8_t cmd_flag; |
pymal | 0:1d10a6e6808c | 54 | uint8_t size; |
pymal | 0:1d10a6e6808c | 55 | uint8_t data[0]; |
pymal | 0:1d10a6e6808c | 56 | } __attribute__((packed)) rplidar_cmd_packet_t; |
pymal | 0:1d10a6e6808c | 57 | |
pymal | 0:1d10a6e6808c | 58 | |
pymal | 0:1d10a6e6808c | 59 | typedef struct _rplidar_ans_header_t { |
pymal | 0:1d10a6e6808c | 60 | uint8_t syncByte1; // must be RPLIDAR_ANS_SYNC_BYTE1 |
pymal | 0:1d10a6e6808c | 61 | uint8_t syncByte2; // must be RPLIDAR_ANS_SYNC_BYTE2 |
pymal | 0:1d10a6e6808c | 62 | uint32_t size:30; // see _u32 size:30; _u32 subType:2; |
pymal | 0:1d10a6e6808c | 63 | uint32_t subType:2; |
pymal | 0:1d10a6e6808c | 64 | uint8_t type; |
pymal | 0:1d10a6e6808c | 65 | } __attribute__((packed)) rplidar_ans_header_t; |