Skip to content

Commit

Permalink
feat:support AVIA and Mid-70
Browse files Browse the repository at this point in the history
  • Loading branch information
Livox-SDK committed Oct 26, 2020
1 parent 2c68829 commit fb5669b
Show file tree
Hide file tree
Showing 75 changed files with 4,344 additions and 4,113 deletions.
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

livox_ros_driver is a new ROS package, specially used to connect LiDAR products produced by Livox. The driver can be run under ubuntu 14.04/16.04/18.04 operating system with ROS environment (indigo, kinetic, melodic) installed. Tested hardware platforms that can run livox_ros_driver include: Intel x86 cpu platforms, and some ARM64 hardware platforms (such as nvida TX2 / Xavier, etc.).

## 0. Version and Release History

### 0.1 Current Version

[v2.6.0](https://github.com/Livox-SDK/livox_ros_driver/releases)

### 0.2 Release History

[Release History](https://github.com/Livox-SDK/livox_ros_driver/releases)

## 1. Install dependencies

Before running livox_ros_driver, ROS and Livox-SDK must be installed.
Expand Down Expand Up @@ -171,14 +181,12 @@ In the "ws_livox/src/livox_ros_driver/launch" path, there are two json files, li
    The parameter attributes in the above json file are described in the following table :

<center>LiDAR configuration parameter</center>

| Parameter | Type | Description | Default |
| :------------------------- | ------- | ------------------------------------------------------------ | --------------- |
| broadcast_code | String | LiDAR broadcast code, 15 characters, consisting of a 14-character length serial number plus a character-length additional code | 0TFDG3B006H2Z11 |
| enable_connect | Boolean | Whether to connect to this LiDAR<br>true -- Connect this LiDAR<br>false --Do not connect this LiDAR | false |
| enable_fan | Boolean | Whether to automatically control the fan of this LiDAR<br>true -- Automatically control the fan of this LiDAR<br>false -- Does not automatically control the fan of this LiDAR | true |
| return_mode | Int | return mode<br>0 -- First single return mode<br>1 -- Strongest single return mode<br>2 -- Dual return mode | 0 |
| coordinate | Int | Coordinate<br>0 -- Cartesian<br>1 -- Spherical | 0 |
| coordinate | Int | Coordinate<br>0 -- Cartesian<br>1 -- Spherical | 0 |
| imu_rate | Int | Push frequency of IMU sensor data<br>0 -- stop push<br>1 -- 200 Hz<br>Others -- undefined, it will cause unpredictable behavior<br>Currently only Horizon supports this, MID serials do not support it | 0 |
| extrinsic_parameter_source | Int | Whether to enable extrinsic parameter automatic compensation<br>0 -- Disable automatic compensation of LiDAR external reference<br>1 -- Automatic compensation of LiDAR external reference | 0 |

Expand All @@ -198,7 +206,6 @@ In the "ws_livox/src/livox_ros_driver/launch" path, there are two json files, li
"lidar_config": [
{
"broadcast_code": "0TFDG3B006H2Z11",
"enable_fan": true,
"return_mode": 0,
"imu_rate": 1
}
Expand All @@ -209,7 +216,6 @@ In the "ws_livox/src/livox_ros_driver/launch" path, there are two json files, li
&ensp;&ensp;&ensp;&ensp;The main difference between the content of Hub json configuration file and the content of the LiDAR json configuration file is that the Hub configuration item "hub_config" is added, and the related configuration content of the Hub is shown in the following table :

<center>HUB configuration parameter</center>

| Parameter | Type | Description | Default |
| -------------- | ------- | ------------------------------------------------------------ | --------------- |
| broadcast_code | String | HUB broadcast code, 15 characters, consisting of a 14-character length serial number plus a character-length additional code | 13UUG1R00400170 |
Expand Down Expand Up @@ -251,7 +257,6 @@ $GPRMC,190430,A,4812.3038,S,07330.7690,W,3.7,3.8,090210,13.7,E,D*26
livox_ros_driver only supports the timestamp synchronization function when connected to LiDAR. The timestamp related configuration item timesync_config is in the livox_lidar_config.json file. The detailed configuration content is shown in the table below :

<center>Timestamp synchronization function configuration instructions</center>

| Parameter | Type | Description | Default |
| ---------------- | -------- | ------------------------------------------------------------ | -------------- |
| enable_timesync | Boolean | Whether to enable the timestamp synchronization <br>true -- Enable timestamp synchronization<br>false -- Disable timestamp synchronization | false |
Expand Down
16 changes: 10 additions & 6 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
览沃ROS驱动程序是一个全新的 ROS 包,专门用于连接览沃生产的 LiDAR 产品。该驱动程序可以在安装了
ROS 环境( indigo,kinetic,melodic )的 ubuntu14.04/16.04/18.04 操作系统下运行。经测试可以运行览沃 ROS 驱动程序的硬件平台包括:intel x86 主流 cpu 平台,部分 ARM64 硬件平台(如,nvida TX2/Xavier 等)。

## 0. 版本和发布记录

### 0.1 当前版本

v2.6.0

### 0.2 发布记录

[发布记录](https://github.com/Livox-SDK/livox_ros_driver/releases)

## 1. 安装依赖

运行览沃 ROS 驱动程序之前,必须安装 ROS 和 Livox-SDK。
Expand Down Expand Up @@ -165,7 +175,6 @@ uint8 line # laser number in lidar
{
"broadcast_code": "0TFDG3B006H2Z11",
"enable_connect": true,
"enable_fan": true,
"return_mode": 0,
"coordinate": 0,
"imu_rate": 1,
Expand All @@ -178,12 +187,10 @@ uint8 line # laser number in lidar
&ensp;&ensp;&ensp;&ensp;上面 json 文件中各参数属性说明如下表:

<center>LiDAR 配置参数说明</center>

| 属性 | 类型 | 描述 | 默认值 |
| :------------------------- | ------ | ------------------------------------------------------------ | --------------- |
| broadcast_code | 字符串 | LiDAR 广播码,15位字符,由14位字符长度序列号加一个字符长度附加码组成 | 0TFDG3B006H2Z11 |
| enable_connect | 布尔值 | 是否连接此 LiDAR<br>true -- 连接此 LiDAR<br>false -- 禁止连接此 LiDAR | false |
| enable_fan | 布尔值 | 是否自动控制此 LiDAR 风扇<br>true -- 自动控制 LiDAR 风扇<br>false -- 禁止自动控制此 LiDAR 风扇 | true |
| return_mode | 整型 | 回波模式<br>0 -- 第一个回波模式<br>1 -- 最强回波模式<br>2 -- 双回波模式 | 0 |
| coordinate | 整型 | 原始点云数据的坐标轴类型<br>0 -- 直角坐标系<br>1 -- 球坐标系 | 0 |
| imu_rate | 整型 | IMU 传感器数据的推送频率<br>0 -- 关闭 IMU 传感器数据推送<br>1 -- 以 200Hz 频率推送 IMU 传感器数据<br>其他值 -- 未定义,会导致不可预测的行为发生<br>目前只有 Horizon/Tele 支持此选项,MID 序列不支持 | 0 |
Expand All @@ -206,7 +213,6 @@ uint8 line # laser number in lidar
"lidar_config": [
{
"broadcast_code": "0TFDG3B006H2Z11",
"enable_fan": true,
"return_mode": 0,
"imu_rate": 1
}
Expand All @@ -217,7 +223,6 @@ uint8 line # laser number in lidar
&ensp;&ensp;&ensp;&ensp;中心板 json 配置文件内容与 LiDAR 配置文件的主要区别在于,增加了中心板配置项 hub_config ,中心板相关的具体配置内容见下表:

<center>HUB 配置参数说明</center>

| 属性 | 类型 | 描述 | 默认值 |
| -------------- | ------ | ------------------------------------------------------------ | --------------- |
| broadcast_code | 字符串 | HUB 广播码,15位字符,由14位字符长度的序列号加一个字符长度的附加码组成 | 13UUG1R00400170 |
Expand Down Expand Up @@ -261,7 +266,6 @@ uint8 line # laser number in lidar
览沃 ROS 驱动程序只有在与 LiDAR 连接的时候才支持时间戳同步功能,时间戳相关的配置项 timesync_config 位于 livox_lidar_config.json 文件中,详细的配置内容见下表:

<center>时间戳同步功能配置说明</center>

| 属性 | 类型 | 描述 | 默认值 |
| ---------------- | ------ | ------------------------------------------------------------ | -------------- |
| enable_timesync | 布尔值 | 是否使能时间戳同步功能<br>true -- 使能时间戳同步功能<br>false -- 禁止时间戳同步功能 | false |
Expand Down
20 changes: 10 additions & 10 deletions livox_ros_driver/common/FastCRC/FastCRC.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,32 +49,32 @@
// ================= 16-BIT CRC ===================

class FastCRC16 {
public:
public:
FastCRC16(uint16_t seed);

// change function name from mcrf4xx_upd to mcrf4xx
uint16_t
mcrf4xx_calc(const uint8_t *data,
const uint16_t datalen); // Equivalent to _crc_ccitt_update() in
// crc16.h from avr_libc
uint16_t mcrf4xx_calc(
const uint8_t *data,
const uint16_t datalen); // Equivalent to _crc_ccitt_update() in
// crc16.h from avr_libc

private:
private:
uint16_t seed_;
};

// ================= 32-BIT CRC ===================

class FastCRC32 {
public:
public:
FastCRC32(uint32_t seed);

// change function name from crc32_upd to crc32
uint32_t crc32_calc(
const uint8_t *data,
uint16_t len); // Call for subsequent calculations with previous seed
uint16_t len); // Call for subsequent calculations with previous seed

private:
private:
uint32_t seed_;
};

#endif // FASTCRC_FASTCRC_H_
#endif // FASTCRC_FASTCRC_H_
12 changes: 5 additions & 7 deletions livox_ros_driver/common/FastCRC/FastCRCsw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ FastCRC16::FastCRC16(uint16_t seed) { seed_ = seed; }
*/

uint16_t FastCRC16::mcrf4xx_calc(const uint8_t *data, uint16_t len) {

uint16_t crc = seed_;

while (((uintptr_t)data & 3) && len) {
Expand Down Expand Up @@ -90,11 +89,11 @@ FastCRC32::FastCRC32(uint32_t seed) { seed_ = seed; }
crc = (table[(crc & 0xff) + 0x300]) ^ (table[((crc >> 8) & 0xff) + 0x200]) ^ \
(table[((crc >> 16) & 0xff) + 0x100]) ^ (table[(crc >> 24) & 0xff]);

#define crcsm_n4d(crc, data, table) \
crc ^= data; \
crc = (crc >> 8) ^ (table[crc & 0xff]); \
crc = (crc >> 8) ^ (table[crc & 0xff]); \
crc = (crc >> 8) ^ (table[crc & 0xff]); \
#define crcsm_n4d(crc, data, table) \
crc ^= data; \
crc = (crc >> 8) ^ (table[crc & 0xff]); \
crc = (crc >> 8) ^ (table[crc & 0xff]); \
crc = (crc >> 8) ^ (table[crc & 0xff]); \
crc = (crc >> 8) ^ (table[crc & 0xff]);

/** CRC32
Expand All @@ -110,7 +109,6 @@ FastCRC32::FastCRC32(uint32_t seed) { seed_ = seed; }
#endif

uint32_t FastCRC32::crc32_calc(const uint8_t *data, uint16_t len) {

uint32_t crc = seed_ ^ 0xffffffff;

while (((uintptr_t)data & 3) && len) {
Expand Down
4 changes: 2 additions & 2 deletions livox_ros_driver/common/comm/comm_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ typedef struct {
} config;
} CommDevConfig;

} // namespace livox_ros
#endif // COMM_COMM_DEVICE_H_
} // namespace livox_ros
#endif // COMM_COMM_DEVICE_H_
32 changes: 16 additions & 16 deletions livox_ros_driver/common/comm/comm_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
//

#include "comm_protocol.h"
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <iostream>

namespace livox_ros {

Expand Down Expand Up @@ -116,23 +116,23 @@ int32_t CommProtocol::ParseCommStream(CommPacket *o_pack) {
while ((GetValidDataSize() > protocol_->GetPreambleLen()) &&
(GetValidDataSize() > offset_to_read_index_)) {
switch (fsm_parse_step_) {
case kSearchPacketPreamble: {
FsmSearchPacketPreamble();
break;
}
case kFindPacketLength: {
FsmFindPacketLength();
break;
}
case kGetPacketData: {
ret = FsmGetPacketData(o_pack);
break;
}
default: { FsmParserStateTransfer(kSearchPacketPreamble); }
case kSearchPacketPreamble: {
FsmSearchPacketPreamble();
break;
}
case kFindPacketLength: {
FsmFindPacketLength();
break;
}
case kGetPacketData: {
ret = FsmGetPacketData(o_pack);
break;
}
default: { FsmParserStateTransfer(kSearchPacketPreamble); }
}

/* Must exit when in the below case */
if ((ret == kParseSuccess) || (ret == kParseNeedMoreData)) break;
if ((ret == kParseSuccess) || (ret == kParseNeedMoreData)) break;
}

return ret;
Expand Down Expand Up @@ -221,4 +221,4 @@ int32_t CommProtocol::FsmGetPacketData(CommPacket *o_pack) {
return ret;
}

} // namespace livox_ros
} // namespace livox_ros
10 changes: 5 additions & 5 deletions livox_ros_driver/common/comm/comm_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
#ifndef COMM_COMM_PROTOCOL_H_
#define COMM_COMM_PROTOCOL_H_

#include <stdint.h>
#include "gps_protocol.h"
#include "protocol.h"
#include "sdk_protocol.h"
#include <stdint.h>

namespace livox_ros {
const uint32_t kCacheSize = 8192;
Expand All @@ -50,7 +50,7 @@ typedef struct {
} CommCache;

class CommProtocol {
public:
public:
CommProtocol(ProtocolConfig &config);
~CommProtocol();

Expand All @@ -67,7 +67,7 @@ class CommProtocol {

void ResetParser();

private:
private:
uint32_t GetCacheTailSize();
uint32_t GetValidDataSize();
void UpdateCache(void);
Expand Down Expand Up @@ -101,5 +101,5 @@ class CommProtocol {
}
};

} // namespace livox_ros
#endif // COMM_COMM_PROTOCOL_H_
} // namespace livox_ros
#endif // COMM_COMM_PROTOCOL_H_
10 changes: 4 additions & 6 deletions livox_ros_driver/common/comm/gps_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ int32_t GpsProtocol::ParsePacket(const uint8_t *i_buf, uint32_t i_len,
// GpsPacket *gps_packet = (GpsPacket *)i_buf;

if (i_len < GetPacketWrapperLen()) {
return -1; // packet length error
return -1; // packet length error
}
memset((void *)o_packet, 0, sizeof(CommPacket));
o_packet->protocol = kGps;
Expand Down Expand Up @@ -114,14 +114,12 @@ uint8_t GpsProtocol::CalcGpsPacketChecksum(const uint8_t *buf,

uint8_t AscciiToHex(const uint8_t *TwoChar) {
uint8_t h = toupper(TwoChar[0]) - 0x30;
if (h > 9)
h -= 7;
if (h > 9) h -= 7;

uint8_t l = toupper(TwoChar[1]) - 0x30;
if (l > 9)
l -= 7;
if (l > 9) l -= 7;

return h * 16 + l;
}

} // namespace livox_ros
} // namespace livox_ros
10 changes: 5 additions & 5 deletions livox_ros_driver/common/comm/gps_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#ifndef LIVOX_GPS_PROTOCOL_H_
#define LIVOX_GPS_PROTOCOL_H_

#include "protocol.h"
#include <stdint.h>
#include "protocol.h"

namespace livox_ros {

Expand All @@ -47,7 +47,7 @@ typedef struct {
uint8_t AscciiToHex(const uint8_t *TwoChar);

class GpsProtocol : public Protocol {
public:
public:
GpsProtocol();
~GpsProtocol() = default;

Expand All @@ -69,11 +69,11 @@ class GpsProtocol : public Protocol {

int32_t CheckPacket(const uint8_t *buf) override;

private:
private:
uint32_t found_length_;

uint8_t CalcGpsPacketChecksum(const uint8_t *buf, uint32_t length);
};

} // namespace livox_ros
#endif // LIVOX_GPS_PROTOCOL_H_
} // namespace livox_ros
#endif // LIVOX_GPS_PROTOCOL_H_
13 changes: 4 additions & 9 deletions livox_ros_driver/common/comm/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ typedef struct CommPacket {
uint8_t *data;
uint16_t data_len;
uint32_t padding;
// RequestPackCb *ack_request_cb;
// uint32_t retry_times;
// uint32_t timeout;
} CommPacket;

/** SDK Protocol info config */
Expand All @@ -72,9 +69,7 @@ typedef struct {
} SdkProtocolConfig;

/** NAME-0183 Protocol info config for gps */
typedef struct {
void *data;
} GpsProtocolConfig;
typedef struct { void *data; } GpsProtocolConfig;

typedef struct {
uint8_t type;
Expand All @@ -85,7 +80,7 @@ typedef struct {
} ProtocolConfig;

class Protocol {
public:
public:
virtual ~Protocol() = default;

virtual int32_t ParsePacket(const uint8_t *i_buf, uint32_t i_len,
Expand All @@ -107,5 +102,5 @@ class Protocol {
virtual int32_t CheckPacket(const uint8_t *buf) = 0;
};

} // namespace livox_ros
#endif // COMM_PROTOCOL_H_
} // namespace livox_ros
#endif // COMM_PROTOCOL_H_
Loading

0 comments on commit fb5669b

Please sign in to comment.