Livox-SDK / livox_ros2_driver

Livox device driver under Ros2, support Lidar Mid-40, Mid-70, Tele-15, Horizon, Avia.
Other
77 stars 84 forks source link

There is nowhere to set variable is_initialized to false except in the constructor of the "LdsLidar." #21

Open BlueBirdHouse opened 2 years ago

BlueBirdHouse commented 2 years ago

Dear engineers of Livox ROS2 Driver, I encounter an error when I use the function "int LdsLidar :: DeInitLdsLidar". It happens when I "InitLdsLidar"; then, "DeInitLdsLidar"; then, "InitLdsLidar" again. It tells me that the LiDAR data source is already inited.

I have observed that in the "InitLdsLidar," you have set the variable is_initialized to true; however, there is nowhere to set it to false except in the constructor of the "LdsLidar." However, the class "LdsLidar" is used as static in "static LdsLidar lds_lidar(interval_ms)" of LisLidar *GetInstance(uint32_t interval_ms). That means there is only one copy of LdsLidar. So, if on code change the variable is_initialized to false, it will always be true.

I add one line is_initialized = false in LdsLidar::DeInitLdsLidar(void). It seems to work for the moment.

However, I am just a noviciate. I don't know whether my modification will cause some side effects.

Please help me.

Thanks.