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

Closed
opened 2022-09-05 05:50:04 +02:00 by BlueBirdHouse · 0 comments
BlueBirdHouse commented 2022-09-05 05:50:04 +02:00 (Migrated from github.com)

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.

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.
This repo is archived. You cannot comment on issues.
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mmr/Livox-SDK#185