vectr-ucla / direct_lidar_inertial_odometry

[IEEE ICRA'23] A new lightweight LiDAR-inertial odometry algorithm with a novel coarse-to-fine approach in constructing continuous-time trajectories for precise motion correction.
MIT License
632 stars 131 forks source link

No localization with Livox Lidar #5

Closed WeilongXia closed 1 year ago

WeilongXia commented 1 year ago

Thanks a lot for opening source such a great work, but when I run the code, I found that the odometry output pose has always been the origin and has not changed. I have checked the data topics of lidar and imu, and there is nothing wrong. The frequency of lidar is 10Hz, and the frequency of imu is 200Hz. What are the possible reasons for the above case? Looking forward to your reply~ Screenshot from 2023-06-17 14-40-19 Screenshot from 2023-06-17 14-40-34 Screenshot from 2023-06-17 14-44-04

kennyjchen commented 1 year ago

Yeah I haven't tested Livox support out since I don't have any data. Think you could upload a bag for me to play around with? Thanks!

WeilongXia commented 1 year ago

This is the dataset of Livox-mid360: https://1drv.ms/u/s!AjkIEg1kWUNeiAIZHIDBTzXmtHqf?e=cWek2u And the extrinsic between the Lidar frame and IMU frame is Screenshot from 2023-06-17 13-39-45

Joosoo1 commented 1 year ago

Yes, it seems that we are experiencing the same problem, may I ask if you are using it as a navigation for robots? Drones or unmanned vehicles?Maybe we can communicate that i have recently encountered some difficulties.

WeilongXia commented 1 year ago

Yeah I 'm going to use it as a localization module for drones, and maybe we can use the g-mail to communicate: xiawl0524@gmail.com

Yes, it seems that we are experiencing the same problem, may I ask if you are using it as a navigation for robots? Drones or unmanned vehicles?Maybe we can communicate that i have recently encountered some difficulties.↳

Joosoo1 commented 1 year ago

ok, after my test, livox-mid360 can run DLIO successfully, just change the point cloud publishing form "xfer_format" to "2" in livox_ros_driver2, then it can run DLIO successfully. DLIO can be run successfully, as follows:

Effect Screenshot xfer_format

Joosoo1 commented 1 year ago

But the results do not seem to be very good, odom data z-axis jitter will be relatively large, may be due to the reason of not tuning parameters, but also may be due to the built-in imu noise is too large, the follow-up we can exchange about how to make it better and more stable, in addition, I am also intended to apply it to the top of the drone, used as navigation and positioning.

WeilongXia commented 1 year ago

Thanks to your reply, the dimension of the acceleration data from the build-in imu in Livox MID-360 is g(gravity) instead of m/s^2, maybe you should multiply the data with a constant value like 9.8?

Joosoo1 commented 1 year ago

Thanks to your reply, the dimension of the acceleration data from the build-in imu in Livox MID-360 is g(gravity) instead of m/s^2, maybe you should multiply the data with a constant value like 9.8?

ok,i will try!If you have better results, please let me know too!

WeilongXia commented 1 year ago

I have tried to set xfer_format t o 2, and the result seems great! Screenshot from 2023-06-21 20-03-39 Screenshot from 2023-06-21 20-07-35

Joosoo1 commented 1 year ago

wow! Your results look great, the position estimation is accurate and the built point cloud map has no drift, but my results are as bad as ever, still with a large offset on the z-axis, can you share your configuration parameters file? Also, about the z-axis, my livox has a z-axis accel bias of -5, while yours is 0. I think there is something wrong here. Result 3 Result 4

kennyjchen commented 1 year ago

Hi @WeilongXia and @Joosoo1 -- thanks for the great discussion you two have started here. Looks like the Livox branch is working! It just needs to be published in the standard format.

Yeah something is definitely wrong if the IMU biases are that large. Have you checked your extrinsics? That's typically an issue, especially since the convention for IMU and LiDAR are different.

Edit: it's working, but deskewing is not (note the deskewed points: 0 in the terminal screenshots above). Looks like a per-point timestamp issue with Livox sensors.

kennyjchen commented 1 year ago

@Joosoo1 Yes, change the units of the accelerometer to m/s^2 as per the advice above.

Could someone record me a dataset in the new xfer_format? Thanks.

Joosoo1 commented 1 year ago

Well, it's true that because of the acceleration units, it has to be m/s^2 for it to work well. I provide the dataset:https://1drv.ms/u/s!AiyqJY-cvK5varx4IwdfshuTfeE?e=TtbAdI pointcloud_topic:/livox/lidar imu_topic:/livox/imu (the acceleration unit is g, so you need to modify the code in DLIO) The parameters are: ! livox-mid360 (built-in imu) extranet

dxdydz3dt commented 1 year ago

Can you translate in English Please!. I am trying to run Livox but its not working

Joosoo1 commented 1 year ago

Can you translate in English Please!. I am trying to run Livox but its not working You can take a look at this: https://github.com/vectr-ucla/direct_lidar_inertial_odometry/issues/5#issuecomment-1600450012

It is necessary to additionally convert the acceleration units of the /livox/imu topic output to m/s^2,then the DLIO will work well, of course all this needs to be under the source code of the livox branch.

Joosoo1 commented 1 year ago

@kennyjchen I found that when livox outputs the standard point cloud, its feild.name is not "offsettime", so according to the code "deskew= false", deskewing is not wrok! fieldname

kennyjchen commented 1 year ago

Hmm, yeah unfortunately it looks like in the livox_ros_driver2 package, only x y z and intensity fields are copied over when publishing using the xfer_format: 2 value.

https://github.com/Livox-SDK/livox_ros_driver2/blob/master/src/lddc.cpp#L437

It looks like with their custom message, they have per-point timestamps . However, it looks like both timestamp and offset_time are used, which is a bit confusing since their CustomPoint.msg contains offset_time, but the data above (the first link) has a timestamp field.

If only timestamps are available using their custom point format, we'll need to build support for that (unless they add timestamps to the PCL format). I'll keep digging.

kennyjchen commented 1 year ago

Ok -- I think I might have figured this out. For future reference, this is how different sensors timestamp their points:

I pushed a few changes to the feature/livox-support branch. Please test this out using the original xfer_format value so that there are timestamp fields.

@WeilongXia -- I played around with your data, and it looks like the LiDAR and IMU measurements are not time synchronized. Is there an option in the Livox driver to synchronize them somehow?

EDIT 6/28: updated the list above to be more accurate and include both xfer_format: 0 and xfer_format: 1. As of the time of this writing, seems like there is a bug in timestamping with xfer_format: 0.

WeilongXia commented 1 year ago

Ok, I found a timesync choice in the config file like this Screenshot from 2023-06-24 11-27-10 and I'll try to record a new rosbag.

juliangaal commented 1 year ago

@WeilongXia could you rename the issue to something more meaningful, if you don't mind, for future reference? Something like "No localization with Livox Lidar"

WeilongXia commented 1 year ago

I tested the feature/livox-support branch with the original xfer_format(value 1) , but there is no localization output. @Joosoo1 Have you tested the new branch with xfer_format value is 1? In livox_ros_driver2, when I run the msg_MID360.launch file, the lidar topic type is livox_ros_driver2/CustomMsg rather than sensor_msgs::PointCloud2, so I modify some code in livox_ros_driver2 like this:

else if (kLivoxCustomMsg == transfer_format_)
        {
            // PublishCustomPointcloud(p_queue, index);
            PublishPointcloud2(p_queue, index);
        }
else if (kLivoxCustomMsg == transfer_format_)
        {
            // **pub = cur_node_->GetNode().advertise<livox_ros_driver2::CustomMsg>(name_str, queue_size);
            // DRIVER_INFO(*cur_node_, "%s publish use livox custom format, set ROS publisher queue size %d", name_str,
            //             queue_size);
            **pub = cur_node_->GetNode().advertise<sensor_msgs::PointCloud2>(name_str, queue_size);
            DRIVER_INFO(*cur_node_, "%s publish use PointCloud2 format, set ROS publisher queue size %d", name_str,
                        queue_size);
        }
else if (kLivoxCustomMsg == msg_type)
    {
        // DRIVER_INFO(*cur_node_, "%s publish use livox custom format", topic_name.c_str());
        // return cur_node_->create_publisher<CustomMsg>(topic_name, queue_size);
        DRIVER_INFO(*cur_node_, "%s publish use PointCloud2 format", topic_name.c_str());
        return cur_node_->create_publisher<PointCloud2>(topic_name, queue_size);
    }
yijing2050 commented 1 year ago

ld multiply the data with a constant value like 9.8?

@Joosoo1 I used xfer_format = 0,and there was no point cloud. My wechat:yijingxs, you can add me and it is convenient to communicate with each other

Joosoo1 commented 1 year ago

Yes, I tested the new branch and the DLIO only has odom output when xfer_format=2, but the result is completely wrong, so I have been using the original DLIO now, the original DLIO works well, I tested it on the drone and the positioning is very good. But deskwing is not working and will have some effect on DLIO,So I look forward to the author's help in solving this problem.

Joosoo1 commented 1 year ago

ld multiply the data with a constant value like 9.8?

@Joosoo1 I used xfer_format = 0,and there was no point cloud. My wechat:yijingxs, you can add me and it is convenient to communicate with each other xfer_format = 2, old DLIO could working!

Joosoo1 commented 1 year ago

ld multiply the data with a constant value like 9.8?

@Joosoo1 I used xfer_format = 0,and there was no point cloud. My wechat:yijingxs, you can add me and it is convenient to communicate with each other xfer_format = 2, old DLIO could working!

Also, when you use imu with acceleration units of m/s^2, you should change the https://github.com/vectr-ucla/direct_lidar_inertial_odometry/tree/feature/livox-support/src/ under the livox branch Lines 1373 to 1375 of the code in dlio/odom.cc should be changed to Eigen::Vector3f lin_accel(imu_raw->linear_acceleration.x * gravity_, imu_raw->linear_acceleration.y * gravity_, imu_raw->linear_acceleration.z * gravity_); recompile!

yijing2050 commented 1 year ago

Thanks for your reply and kind advice. I have another problem when compiling, the first is the version of cmake. As my ros version is melodic,and the cmake version is 3.10.2, so I modify

VERSION 3.12.4

cmake_minimum_required(VERSION 3.10.2) project(direct_lidar_inertial_odometry) Could this modification do influence the output of the code?

 it have no add_compile_definitions.Then I comment out the section:# Not all machines have <cpuid.h> available

set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

file(WRITE ${CMAKE_BINARY_DIR}/test_cpuid.cpp "#include <cpuid.h>")

try_compile(HAS_CPUID ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/test_cpuid.cpp)

file(REMOVE ${CMAKE_BINARY_DIR}/test_cpuid.cpp)

if(HAS_CPUID)

  add_compile_definitions(HAS_CPUID)

endif()

after done above, I compiled successfully.

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2023年6月26日(星期一) 中午11:54 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [vectr-ucla/direct_lidar_inertial_odometry] No localization with Livox Lidar (Issue #5)

ld multiply the data with a constant value like 9.8?

@Joosoo1 I used xfer_format = 0,and there was no point cloud. My wechat:yijingxs, you can add me and it is convenient to communicate with each other xfer_format = 2, old DLIO could working!

Also, when you use imu with acceleration units of m/s^2, you should change the https://github.com/vectr-ucla/direct_lidar_inertial_odometry/tree/feature/livox-support/src/ under the livox branch Lines 1373 to 1375 of the code in dlio/odom.cc should be changed to Eigen::Vector3f lin_accel(imu_raw->linearacceleration.x * gravity, imu_raw->linearacceleration.y * gravity, imu_raw->linearacceleration.z * gravity); recompile!

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

Joosoo1 commented 1 year ago

Thanks for your reply and kind advice. I have another problem when compiling, the first is the version of cmake. As my ros version is melodic,and the cmake version is 3.10.2, so I modify #VERSION 3.12.4 cmake_minimum_required(VERSION 3.10.2) project(direct_lidar_inertial_odometry) Could this modification do influence the output of the code?  it have no add_compile_definitions.Then I comment out the section:# Not all machines have <cpuid.h> available #set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) #file(WRITE ${CMAKE_BINARY_DIR}/test_cpuid.cpp "#include <cpuid.h>") #try_compile(HAS_CPUID ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/test_cpuid.cpp) #file(REMOVE ${CMAKE_BINARY_DIR}/test_cpuid.cpp) #if(HAS_CPUID) #  add_compile_definitions(HAS_CPUID) #endif() after done above, I compiled successfully. ------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2023年6月26日(星期一) 中午11:54 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [vectr-ucla/direct_lidar_inertial_odometry] No localization with Livox Lidar (Issue #5) ld multiply the data with a constant value like 9.8? @Joosoo1 I used xfer_format = 0,and there was no point cloud. My wechat:yijingxs, you can add me and it is convenient to communicate with each other xfer_format = 2, old DLIO could working! Also, when you use imu with acceleration units of m/s^2, you should change the https://github.com/vectr-ucla/direct_lidar_inertial_odometry/tree/feature/livox-support/src/ under the livox branch Lines 1373 to 1375 of the code in dlio/odom.cc should be changed to Eigen::Vector3f lin_accel(imu_raw->linearacceleration.x * gravity, imu_raw->linearacceleration.y * gravity, imu_raw->linearacceleration.z * gravity); recompile! — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

I don't know much about this, but if it compiles successfully, you should be able to run the program successfully, so you can test it as soon as possible!

kennyjchen commented 1 year ago

@yijing2050 Unfortunately DLIO only supports ROS Noetic, but it sounds like you got it working. Removing those lines won't have any affect on the output; it's just to build support for ARM architectures.

@WeilongXia @Joosoo1 The xfer_format should be 0 so that it's a message of type PointCloud2 but contains the timestamps. I will look into this again later this week. Sorry to ask again -- could someone record me a new bag that ideally time synchronizes the Mid-360's LiDAR and IMU (if not already), using xfer_format: 0? Thank you. In the meanwhile, you can turn deskewing off, but note that (especially at 10Hz) the point clouds will be quite distorted.

yijing2050 commented 1 year ago

@kennyjchen livox_repub.zip [Uploading livox_repub.zip…]()

yijing2050 commented 1 year ago

Actually, I have compiled successfully although, but i haven't got the odom.. The configuration is as the below. 2023-06-27 10-12-35屏幕截图 2023-06-27 10-12-02屏幕截图 2023-06-27 10-12-59屏幕截图 2023-06-27 10-22-02屏幕截图 2023-06-27 10-21-39屏幕截图 2023-06-27 10-21-14屏幕截图

kennyjchen commented 1 year ago

Ok -- after digging through the Livox driver and also looking at this dataset, it seems like there is a bug for per-point timestamps when using xfer_format: 0(i.e., Livox pointcloud2(PointXYZRTLT) pointcloud format). The point cloud and IMU timestamps look synchronized, but the point timestamps are off and do not fall within the sweep window for some reason. This might be just the provided dataset, but either way they don't look lined-up.

I looked at other Mid-360 packages (e.g., this), and it seems like most people use xfer_format: 1 (Livox's custom pointcloud format) so that the offset_time field is available and contains the time since the beginning of the sweep. This requires a subscription to Livox's custom pointcloud format though.

So new plan: please try the updated branch but with xfer_format: 1. Your topic of type livox_ros_driver::CustomMsg should be called /robot/livox, which will call this new callback. This is all assuming that offset_time is in nanoseconds relative to the beginning of the sweep (which I think is the case).

(Please be careful with the units of gravity. I removed the previous multiplication with gravity.)

Note that I have not tested this at all, because I do not have a Livox sensor or any bags with xfer_format: 1. If someone could record me one that would be great so I can test it on my side. Otherwise, let me know if it works or not!

Joosoo1 commented 1 year ago

Sorry for the late reply, and thank you @kennyjchen author for your efforts to solve this problem. Here is the dataset I recorded: accel in units is g;and xfer_format: 1 https://onedrive.live.com/?cid=6FAEBC9C8F25AA2C&id=6FAEBC9C8F25AA2C%21120&parId=root&o=OneUp

kennyjchen commented 1 year ago

Ok, I think I got it working. Credit to this Tweet for supplying the data I played around with.

image

Please use the newer livox_ros_driver2 package with xfer_format: 1. The latest feature/livox-support branch seems to be working with deskewing. Let me know.

Joosoo1 commented 1 year ago

Ok, I think I got it working. Credit to this Tweet for supplying the data I played around with.

image

Please use the newer livox_ros_driver2 package with xfer_format: 1. The latest feature/livox-support branch seems to be working with deskewing. Let me know.

Doesn't seem to work: new-DLIO

WeilongXia commented 1 year ago

Ok, I think I got it working. Credit to this Tweet for supplying the data I played around with.↳ image Please use the newer livox_ros_driver2 package with xfer_format: 1. The latest feature/livox-support branch seems to be working with deskewing. Let me know.↳

Doesn't seem to work: new-DLIO

You should modify livox_topic to "/livox/lidar", and pointcloud_topic to another one. Hi author @kennyjchen , with deskew set to "false", it can work with Livox-MID360 now as below! Screenshot from 2023-07-03 10-27-17 And the offset_time units in livox_ros_driver2 is microseconds.

WeilongXia commented 1 year ago

Hi author, when i set deskew to true, the program is not working properly, this is the dataset i used: https://1drv.ms/u/s!AjkIEg1kWUNeiArwedvaRRYd5hWB?e=BaII3v Could you please help to figure this out?

kennyjchen commented 1 year ago

@WeilongXia -- Your dataset works for me with deskewing.

image

image

I'm using the latest feature/livox-support branch without any modifications and the following command:

rosbag play 2023-06-28-10-00-30.bag /livox/imu:=/robot/imu /livox/lidar:=/robot/livox

What are the errors that you're seeing?

Joosoo1 commented 1 year ago

@@yes! DLIO is now working with deskewing!just modify livox_topic to "/livox/lidar"

kennyjchen commented 1 year ago

Good to hear!

yijing2050 commented 1 year ago

DLIO is now working with deskewing in Ubuntu 18.04, but it seems not stable and the path is not smooth as fast_lio2. And the map will fly in some time later. 2023-07-06 22-21-28屏幕截图

kennyjchen commented 1 year ago

That max comp time looks pretty awful, which can result in these sorts of behaviors if too many frames are skipped. Are extrinsics correct?

juliangaal commented 1 year ago

@Joosoo1 what are the extrinsics of the dataset you provided?

Joosoo1 commented 1 year ago

@Joosoo1 what are the extrinsics of the dataset you provided? Please use this dataset, I tested it and it works great!:https://1drv.ms/u/s!AjkIEg1kWUNeiArwedvaRRYd5hWB?e=BaII3v The extrinsics are as follows: image

CharlieV5 commented 1 year ago

May I ask you guys what is the meaning of dlio/pointcloud/dekew in dlio.yaml? Does it mean that this program will do the deskewing for pointcloud, or this program will consider the input points has been deskewed so it will no do the deskewing? What will happen when dlio/pointcloud/dekew is set as false? Thank you!

Ok, I think I got it working. Credit to this Tweet for supplying the data I played around with.↳ image Please use the newer livox_ros_driver2 package with xfer_format: 1. The latest feature/livox-support branch seems to be working with deskewing. Let me know.↳

Doesn't seem to work: new-DLIO

You should modify livox_topic to "/livox/lidar", and pointcloud_topic to another one. Hi author @kennyjchen , with deskew set to "false", it can work with Livox-MID360 now as below! Screenshot from 2023-07-03 10-27-17 And the offset_time units in livox_ros_driver2 is microseconds.

kennyjchen commented 1 year ago

It will undistort the point cloud when set to true.

CharlieV5 commented 1 year ago

It will undistort the point cloud when set to true.

Thanks

85256638 commented 2 months ago

@Joosoo1 what are the extrinsics of the dataset you provided? Please use this dataset, I tested it and it works great!:https://1drv.ms/u/s!AjkIEg1kWUNeiArwedvaRRYd5hWB?e=BaII3v The extrinsics are as follows: image

Hi, can you kindly let me know where to update those extrinsic values? I guess in the dlio.yaml? can you kindly paste yours please? I would like to know how to adapt Livox Horizon's extrinsic from the datasheet to the dlio.yaml configuration.

dlio:

  version: 1.1.1

  adaptive: true

  pointcloud:
    deskew: true
    voxelize: true

  imu:
    calibration: true
    intrinsics:
      accel:
        bias: [ 0.0, 0.0, 0.0 ]
        sm:   [ 1.,  0.,  0.,
                0.,  1.,  0.,
                0.,  0.,  1. ]
      gyro:
        bias: [ 0.0, 0.0, 0.0 ]

  extrinsics:
    baselink2imu:
      t: [ 0.006253, -0.011775, 0.007645 ]
      R: [ 1.,  0.,  0.,
           0.,  1.,  0.,
           0.,  0.,  1. ]
    baselink2lidar:
      t: [ 0.,  0.,  0. ]
      R: [ 1.,  0.,  0.,
           0.,  1.,  0.,
           0.,  0.,  1. ]

LIvox Horizon extrinsic: image

85256638 commented 2 months ago

@Joosoo1 what are the extrinsics of the dataset you provided? Please use this dataset, I tested it and it works great!:https://1drv.ms/u/s!AjkIEg1kWUNeiArwedvaRRYd5hWB?e=BaII3v The extrinsics are as follows: image

Hi, can you kindly let me know where to update those extrinsic values? I guess in the dlio.yaml? can you kindly paste yours please? I would like to know how to adapt Livox Horizon's extrinsic from the datasheet to the dlio.yaml configuration.

dlio:

  version: 1.1.1

  adaptive: true

  pointcloud:
    deskew: true
    voxelize: true

  imu:
    calibration: true
    intrinsics:
      accel:
        bias: [ 0.0, 0.0, 0.0 ]
        sm:   [ 1.,  0.,  0.,
                0.,  1.,  0.,
                0.,  0.,  1. ]
      gyro:
        bias: [ 0.0, 0.0, 0.0 ]

  extrinsics:
    baselink2imu:
      t: [ 0.006253, -0.011775, 0.007645 ]
      R: [ 1.,  0.,  0.,
           0.,  1.,  0.,
           0.,  0.,  1. ]
    baselink2lidar:
      t: [ 0.,  0.,  0. ]
      R: [ 1.,  0.,  0.,
           0.,  1.,  0.,
           0.,  0.,  1. ]

LIvox Horizon extrinsic: image

@kennyjchen @Joosoo1 this issue has been closed, I would love to hear your advice :) thanks!