v2
Dependencies: BEAR_Protocol_Edited BufferedSerial Debug MaxSonar PID Process QEI UI iSerial mbed
Fork of clean_V1 by
inc/rplidar_cmd.h@7:ffd6959444ae, 2016-06-07 (annotated)
- Committer:
- palmdotax
- Date:
- Tue Jun 07 17:25:18 2016 +0000
- Revision:
- 7:ffd6959444ae
- Parent:
- 2:f873deba2305
v2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
palmdotax | 2:f873deba2305 | 1 | /* |
palmdotax | 2:f873deba2305 | 2 | * Copyright (c) 2014, RoboPeak |
palmdotax | 2:f873deba2305 | 3 | * All rights reserved. |
palmdotax | 2:f873deba2305 | 4 | * |
palmdotax | 2:f873deba2305 | 5 | * Redistribution and use in source and binary forms, with or without |
palmdotax | 2:f873deba2305 | 6 | * modification, are permitted provided that the following conditions are met: |
palmdotax | 2:f873deba2305 | 7 | * |
palmdotax | 2:f873deba2305 | 8 | * 1. Redistributions of source code must retain the above copyright notice, |
palmdotax | 2:f873deba2305 | 9 | * this list of conditions and the following disclaimer. |
palmdotax | 2:f873deba2305 | 10 | * |
palmdotax | 2:f873deba2305 | 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
palmdotax | 2:f873deba2305 | 12 | * this list of conditions and the following disclaimer in the documentation |
palmdotax | 2:f873deba2305 | 13 | * and/or other materials provided with the distribution. |
palmdotax | 2:f873deba2305 | 14 | * |
palmdotax | 2:f873deba2305 | 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
palmdotax | 2:f873deba2305 | 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
palmdotax | 2:f873deba2305 | 17 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
palmdotax | 2:f873deba2305 | 18 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
palmdotax | 2:f873deba2305 | 19 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
palmdotax | 2:f873deba2305 | 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
palmdotax | 2:f873deba2305 | 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
palmdotax | 2:f873deba2305 | 22 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
palmdotax | 2:f873deba2305 | 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
palmdotax | 2:f873deba2305 | 24 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
palmdotax | 2:f873deba2305 | 25 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
palmdotax | 2:f873deba2305 | 26 | * |
palmdotax | 2:f873deba2305 | 27 | */ |
palmdotax | 2:f873deba2305 | 28 | /* |
palmdotax | 2:f873deba2305 | 29 | * RoboPeak LIDAR System |
palmdotax | 2:f873deba2305 | 30 | * Data Packet IO packet definition for RP-LIDAR |
palmdotax | 2:f873deba2305 | 31 | * |
palmdotax | 2:f873deba2305 | 32 | * Copyright 2009 - 2014 RoboPeak Team |
palmdotax | 2:f873deba2305 | 33 | * http://www.robopeak.com |
palmdotax | 2:f873deba2305 | 34 | * |
palmdotax | 2:f873deba2305 | 35 | */ |
palmdotax | 2:f873deba2305 | 36 | |
palmdotax | 2:f873deba2305 | 37 | |
palmdotax | 2:f873deba2305 | 38 | #pragma once |
palmdotax | 2:f873deba2305 | 39 | #include "rptypes.h" |
palmdotax | 2:f873deba2305 | 40 | #include "rplidar_protocol.h" |
palmdotax | 2:f873deba2305 | 41 | |
palmdotax | 2:f873deba2305 | 42 | // Commands |
palmdotax | 2:f873deba2305 | 43 | //----------------------------------------- |
palmdotax | 2:f873deba2305 | 44 | |
palmdotax | 2:f873deba2305 | 45 | // Commands without payload and response |
palmdotax | 2:f873deba2305 | 46 | #define RPLIDAR_CMD_STOP 0x25 |
palmdotax | 2:f873deba2305 | 47 | #define RPLIDAR_CMD_SCAN 0x20 |
palmdotax | 2:f873deba2305 | 48 | #define RPLIDAR_CMD_FORCE_SCAN 0x21 |
palmdotax | 2:f873deba2305 | 49 | #define RPLIDAR_CMD_RESET 0x40 |
palmdotax | 2:f873deba2305 | 50 | |
palmdotax | 2:f873deba2305 | 51 | |
palmdotax | 2:f873deba2305 | 52 | // Commands without payload but have response |
palmdotax | 2:f873deba2305 | 53 | #define RPLIDAR_CMD_GET_DEVICE_INFO 0x50 |
palmdotax | 2:f873deba2305 | 54 | #define RPLIDAR_CMD_GET_DEVICE_HEALTH 0x52 |
palmdotax | 2:f873deba2305 | 55 | |
palmdotax | 2:f873deba2305 | 56 | #if defined(_WIN32) |
palmdotax | 2:f873deba2305 | 57 | #pragma pack(1) |
palmdotax | 2:f873deba2305 | 58 | #endif |
palmdotax | 2:f873deba2305 | 59 | |
palmdotax | 2:f873deba2305 | 60 | |
palmdotax | 2:f873deba2305 | 61 | // Response |
palmdotax | 2:f873deba2305 | 62 | // ------------------------------------------ |
palmdotax | 2:f873deba2305 | 63 | #define RPLIDAR_ANS_TYPE_MEASUREMENT 0x81 |
palmdotax | 2:f873deba2305 | 64 | |
palmdotax | 2:f873deba2305 | 65 | #define RPLIDAR_ANS_TYPE_DEVINFO 0x4 |
palmdotax | 2:f873deba2305 | 66 | #define RPLIDAR_ANS_TYPE_DEVHEALTH 0x6 |
palmdotax | 2:f873deba2305 | 67 | |
palmdotax | 2:f873deba2305 | 68 | |
palmdotax | 2:f873deba2305 | 69 | #define RPLIDAR_STATUS_OK 0x0 |
palmdotax | 2:f873deba2305 | 70 | #define RPLIDAR_STATUS_WARNING 0x1 |
palmdotax | 2:f873deba2305 | 71 | #define RPLIDAR_STATUS_ERROR 0x2 |
palmdotax | 2:f873deba2305 | 72 | |
palmdotax | 2:f873deba2305 | 73 | #define RPLIDAR_RESP_MEASUREMENT_SYNCBIT (0x1<<0) |
palmdotax | 2:f873deba2305 | 74 | #define RPLIDAR_RESP_MEASUREMENT_QUALITY_SHIFT 2 |
palmdotax | 2:f873deba2305 | 75 | #define RPLIDAR_RESP_MEASUREMENT_CHECKBIT (0x1<<0) |
palmdotax | 2:f873deba2305 | 76 | #define RPLIDAR_RESP_MEASUREMENT_ANGLE_SHIFT 1 |
palmdotax | 2:f873deba2305 | 77 | |
palmdotax | 2:f873deba2305 | 78 | typedef struct _rplidar_response_measurement_node_t { |
palmdotax | 2:f873deba2305 | 79 | _u8 sync_quality; // syncbit:1;syncbit_inverse:1;quality:6; |
palmdotax | 2:f873deba2305 | 80 | _u16 angle_q6_checkbit; // check_bit:1;angle_q6:15; |
palmdotax | 2:f873deba2305 | 81 | _u16 distance_q2; |
palmdotax | 2:f873deba2305 | 82 | } __attribute__((packed)) rplidar_response_measurement_node_t; |
palmdotax | 2:f873deba2305 | 83 | |
palmdotax | 2:f873deba2305 | 84 | typedef struct _rplidar_response_device_info_t { |
palmdotax | 2:f873deba2305 | 85 | _u8 model; |
palmdotax | 2:f873deba2305 | 86 | _u16 firmware_version; |
palmdotax | 2:f873deba2305 | 87 | _u8 hardware_version; |
palmdotax | 2:f873deba2305 | 88 | _u8 serialnum[16]; |
palmdotax | 2:f873deba2305 | 89 | } __attribute__((packed)) rplidar_response_device_info_t; |
palmdotax | 2:f873deba2305 | 90 | |
palmdotax | 2:f873deba2305 | 91 | typedef struct _rplidar_response_device_health_t { |
palmdotax | 2:f873deba2305 | 92 | _u8 status; |
palmdotax | 2:f873deba2305 | 93 | _u16 error_code; |
palmdotax | 2:f873deba2305 | 94 | } __attribute__((packed)) rplidar_response_device_health_t; |
palmdotax | 2:f873deba2305 | 95 | |
palmdotax | 2:f873deba2305 | 96 | #if defined(_WIN32) |
palmdotax | 2:f873deba2305 | 97 | #pragma pack() |
palmdotax | 2:f873deba2305 | 98 | #endif |