Skip to content

atinfinity/livox_ros_driver2

 
 

Repository files navigation

Livox ROS Driver 2

Livox ROS Driver 2 is the 2nd-generation driver package used to connect LiDAR products produced by Livox, applicable for ROS 2 (humble recommended).

Note

As a debugging tool, Livox ROS Driver is not recommended for mass production but limited to test scenarios. You should optimize the code based on the original source to meet your various needs.

1. Preparation

1.1 OS requirements

  • Ubuntu 22.04 for ROS 2 Humble;

Tip

Colcon is a build tool used in ROS 2.

How to install colcon: Colcon installation instructions

1.2 Install ROS 2

For ROS 2 Humble installation, please refer to: ROS Humble installation instructions

Desktop-Full installation is recommend.

2. Build & Run Livox ROS Driver 2

2.1 Clone Livox ROS Driver 2 source code:

git clone https://github.com/atinfinity/livox_ros_driver2.git ws_livox/src/livox_ros_driver2

Note

Be sure to clone the source code in a [work_space]/src/ folder (as shown above), otherwise compilation errors will occur due to the compilation tool restriction.

2.2 Build & install the Livox-SDK2

Note

Please follow the guidance of installation in the Livox-SDK2/README.md

2.3 Build the Livox ROS Driver 2:

For ROS 2 Humble:

cd ws_livox
rosdep install -y -i --from-paths src/livox_ros_driver2
colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release

2.4 Run Livox ROS Driver 2:

For ROS 2:

source install/setup.sh
ros2 launch livox_ros_driver2 [launch file]

in which,

  • [launch file] : is the ROS 2 launch file you want to use; the launch folder contains several launch samples for your reference.

A rviz launch example for HAP LiDAR would be:

ros2 launch livox_ros_driver2 rviz_HAP_launch.py

3. Launch file and livox_ros_driver2 internal parameter configuration instructions

3.1 Launch file configuration instructions

Launch files of ROS 2 are in the ws_livox/src/livox_ros_driver2/launch directory. Different launch files have different configuration parameter values and are used in different scenarios:

launch file name Description
rviz_HAP.launch Connect to HAP LiDAR device
Publish pointcloud2 format data
Autoload rviz
msg_HAP.launch Connect to HAP LiDAR device
Publish livox customized pointcloud data
rviz_MID360.launch Connect to MID360 LiDAR device
Publish pointcloud2 format data
Autoload rviz
msg_MID360.launch Connect to MID360 LiDAR device
Publish livox customized pointcloud data
rviz_mixed.launch Connect to HAP and MID360 LiDAR device
Publish pointcloud2 format data
Autoload rviz
msg_mixed.launch Connect to HAP and MID360 LiDAR device
Publish livox customized pointcloud data

3.2 Livox ros driver 2 internal main parameter configuration instructions

All internal parameters of Livox_ros_driver2 are in the launch file. Below are detailed descriptions of the three commonly used parameters :

Parameter Detailed description Default
publish_freq Set the frequency of point cloud publish
Floating-point data type, recommended values 5.0, 10.0, 20.0, 50.0, etc. The maximum publish frequency is 100.0 Hz.
10.0
multi_topic If the LiDAR device has an independent topic to publish pointcloud data
0 -- All LiDAR devices use the same topic to publish pointcloud data
1 -- Each LiDAR device has its own topic to publish point cloud data
0
xfer_format Set pointcloud format
0 -- Livox pointcloud2(PointXYZRTLT) pointcloud format
1 -- Livox customized pointcloud format
2 -- Standard pointcloud2 (pcl :: PointXYZI) pointcloud format in the PCL library (just for ROS)
0

Note

Other parameters not mentioned in this table are not suggested to be changed unless fully understood.

    Livox_ros_driver2 pointcloud data detailed description :

  1. Livox pointcloud2 (PointXYZRTLT) point cloud format, as follows :
float32 x               # X axis, unit:m
float32 y               # Y axis, unit:m
float32 z               # Z axis, unit:m
float32 intensity       # the value is reflectivity, 0.0~255.0
uint8   tag             # livox tag
uint8   line            # laser number in lidar
float64 timestamp       # Timestamp of point

Note

The number of points in the frame may be different, but each point provides a timestamp.

  1. Livox customized data package format, as follows :
std_msgs/Header header     # ROS standard message header
uint64          timebase   # The time of first point
uint32          point_num  # Total number of pointclouds
uint8           lidar_id   # Lidar device id number
uint8[3]        rsvd       # Reserved use
CustomPoint[]   points     # Pointcloud data

    Customized Point Cloud (CustomPoint) format in the above customized data package :

uint32  offset_time     # offset time relative to the base time
float32 x               # X axis, unit:m
float32 y               # Y axis, unit:m
float32 z               # Z axis, unit:m
uint8   reflectivity    # reflectivity, 0~255
uint8   tag             # livox tag
uint8   line            # laser number in lidar
  1. The standard pointcloud2 (pcl :: PointXYZI) format in the PCL library (only ROS can publish):

    Please refer to the pcl :: PointXYZI data structure in the point_types.hpp file of the PCL library.

4. LiDAR config

LiDAR Configurations (such as ip, port, data type... etc.) can be set via a json-style config file. Config files for single HAP, Mid360 and mixed-LiDARs are in the config folder. The parameter naming user_config_path in launch files indicates such json file path.

  1. Follow is a configuration example for HAP LiDAR (located in config/HAP_config.json):
{
  "lidar_summary_info" : {
    "lidar_type": 8  # protocol type index, please don't revise this value
  },
  "HAP": {
    "device_type" : "HAP",
    "lidar_ipaddr": "",
    "lidar_net_info" : {
      "cmd_data_port": 56000,  # command port
      "push_msg_port": 0,
      "point_data_port": 57000,
      "imu_data_port": 58000,
      "log_data_port": 59000
    },
    "host_net_info" : {
      "cmd_data_ip" : "192.168.1.5",  # host ip (it can be revised)
      "cmd_data_port": 56000,
      "push_msg_ip": "",
      "push_msg_port": 0,
      "point_data_ip": "192.168.1.5",  # host ip
      "point_data_port": 57000,
      "imu_data_ip" : "192.168.1.5",  # host ip
      "imu_data_port": 58000,
      "log_data_ip" : "",
      "log_data_port": 59000
    }
  },
  "lidar_configs" : [
    {
      "ip" : "192.168.1.100",  # ip of the LiDAR you want to config
      "pcl_data_type" : 1,
      "pattern_mode" : 0,
      "frame_id" : "livox_frame",
      "blind_spot_set" : 50,
      "extrinsic_parameter" : {
        "roll": 0.0,
        "pitch": 0.0,
        "yaw": 0.0,
        "x": 0,
        "y": 0,
        "z": 0
      }
    }
  ]
}

The parameter attributes in the above json file are described in the following table :

LiDAR configuration parameter

Parameter Type Description Default
ip String Ip of the LiDAR you want to config 192.168.1.100
pcl_data_type Int Choose the resolution of the point cloud data to send
1 -- Cartesian coordinate data (32 bits)
2 -- Cartesian coordinate data (16 bits)
3 --Spherical coordinate data
1
pattern_mode Int Space scan pattern
0 -- non-repeating scanning pattern mode
1 -- repeating scanning pattern mode
2 -- repeating scanning pattern mode (low scanning rate)
0
frame_id String frame_id of LiDAR and IMU "livox_frame"
blind_spot_set (Only for HAP LiDAR) Int Set blind spot
Range from 50 cm to 200 cm
50
extrinsic_parameter Set extrinsic parameter
The data types of "roll" "picth" "yaw" are float (Unit: degree)
The data types of "x" "y" "z" are int (Unit: mm)

For more infomation about the HAP config, please refer to: HAP Config File Description

  1. When connecting multiple LiDARs, add objects corresponding to different LiDARs to the lidar_configs array. Examples of mixed-LiDARs config file contents are as follows :
{
  "lidar_summary_info" : {
    "lidar_type": 8  # protocol type index, please don't revise this value
  },
  "HAP": {
    "lidar_net_info" : {  # HAP ports, please don't revise these values
      "cmd_data_port": 56000,  # HAP command port
      "push_msg_port": 0,
      "point_data_port": 57000,
      "imu_data_port": 58000,
      "log_data_port": 59000
    },
    "host_net_info" : {
      "cmd_data_ip" : "192.168.1.5",  # host ip
      "cmd_data_port": 56000,
      "push_msg_ip": "",
      "push_msg_port": 0,
      "point_data_ip": "192.168.1.5",  # host ip
      "point_data_port": 57000,
      "imu_data_ip" : "192.168.1.5",  # host ip
      "imu_data_port": 58000,
      "log_data_ip" : "",
      "log_data_port": 59000
    }
  },
  "MID360": {
    "lidar_net_info" : {  # Mid360 ports, please don't revise these values
      "cmd_data_port": 56100,  # Mid360 command port
      "push_msg_port": 56200,
      "point_data_port": 56300,
      "imu_data_port": 56400,
      "log_data_port": 56500
    },
    "host_net_info" : {
      "cmd_data_ip" : "192.168.1.5",  # host ip
      "cmd_data_port": 56101,
      "push_msg_ip": "192.168.1.5",  # host ip
      "push_msg_port": 56201,
      "point_data_ip": "192.168.1.5",  # host ip
      "point_data_port": 56301,
      "imu_data_ip" : "192.168.1.5",  # host ip
      "imu_data_port": 56401,
      "log_data_ip" : "",
      "log_data_port": 56501
    }
  },
  "lidar_configs" : [
    {
      "ip" : "192.168.1.100",  # ip of the HAP you want to config
      "pcl_data_type" : 1,
      "pattern_mode" : 0,
      "frame_id" : "livox_hap_frame",
      "blind_spot_set" : 50,
      "extrinsic_parameter" : {
        "roll": 0.0,
        "pitch": 0.0,
        "yaw": 0.0,
        "x": 0,
        "y": 0,
        "z": 0
      }
    },
    {
      "ip" : "192.168.1.12",  # ip of the Mid360 you want to config
      "pcl_data_type" : 1,
      "pattern_mode" : 0,
      "frame_id" : "livox_mid360_frame",
      "extrinsic_parameter" : {
        "roll": 0.0,
        "pitch": 0.0,
        "yaw": 0.0,
        "x": 0,
        "y": 0,
        "z": 0
      }
    }
  ]
}
  1. when multiple nics on the host connect to multiple LiDARs, you need to add objects corresponding to different LiDARs to the lidar_configs array. Run different luanch files separately, and the following is an example of mixing lidar configuration file contents:

MID360_config1:

{
  "lidar_summary_info" : {
    "lidar_type": 8  # protocol type index,please don't revise this value
  },
    "MID360": {
        "lidar_net_info": {
            "cmd_data_port": 56100, # command port
            "push_msg_port": 56200, 
            "point_data_port": 56300,
            "imu_data_port": 56400,
            "log_data_port": 56500
        },
        "host_net_info": [
            {
                "lidar_ip": ["192.168.1.100"], # Lidar ip
                "host_ip": "192.168.1.5", # host ip
                "cmd_data_port": 56101,
                "push_msg_port": 56201,
                "point_data_port": 56301,
                "imu_data_port": 56401,
                "log_data_port": 56501
            }
        ]
    },
    "lidar_configs": [
        {
            "ip": "192.168.1.100", # ip of the LiDAR you want to config
            "pcl_data_type": 1,
            "pattern_mode": 0,
            "frame_id" : "livox_frame",
            "extrinsic_parameter": {
                "roll": 0.0,
                "pitch": 0.0,
                "yaw": 0.0,
                "x": 0,
                "y": 0,
                "z": 0
            }
        }
    ]
}

MID360_config2:

{
  "lidar_summary_info" : {
    "lidar_type": 8  # protocol type index,please don't revise this value
  },
    "MID360": {
        "lidar_net_info": {
            "cmd_data_port": 56100, # command port
            "push_msg_port": 56200, 
            "point_data_port": 56300,
            "imu_data_port": 56400,
            "log_data_port": 56500
        },
        "host_net_info": [
            {
                "lidar_ip": ["192.168.2.100"], # Lidar ip
                "host_ip": "192.168.2.5", # host ip
                "cmd_data_port": 56101,
                "push_msg_port": 56201,
                "point_data_port": 56301,
                "imu_data_port": 56401,
                "log_data_port": 56501
            }
        ]
    },
    "lidar_configs": [
        {
            "ip": "192.168.2.100", # ip of the LiDAR you want to config
            "pcl_data_type": 1,
            "pattern_mode": 0,
            "frame_id" : "livox_frame",
            "extrinsic_parameter": {
                "roll": 0.0,
                "pitch": 0.0,
                "yaw": 0.0,
                "x": 0,
                "y": 0,
                "z": 0
            }
        }
    ]
}

5. Supported LiDAR list

  • HAP
  • Mid360
  • (more types are comming soon...)

6. FAQ

6.1 launch with "livox_lidar_rviz_HAP.launch" but no point cloud display on the grid?

Please check the Global Options - Fixed Frame field in the RViz Display pannel. Set the field value to livox_frame and check the PointCloud2 option in the pannel.

6.2 launch with command "ros2 launch livox_lidar_rviz_HAP_launch.py" but cannot open shared object file "liblivox_sdk_shared.so" ?

Please add /usr/local/lib to the env LD_LIBRARY_PATH.

  • If you want to add to current terminal:

    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
  • If you want to add to current user:

    vim ~/.bashrc
    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
    source ~/.bashrc

About

Livox device driver under Ros(Compatible with ros2), support Lidar HAP and Mid-360.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 86.7%
  • Python 6.8%
  • C 3.5%
  • CMake 3.0%