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