<fix> 1. optimize device state handling, now apply mode settings on each connection regardless of device state
This commit is contained in:
@@ -18,7 +18,7 @@ This driver package provides core functionality for point cloud SLAM application
|
|||||||
|
|
||||||
## 1. Version
|
## 1. Version
|
||||||
|
|
||||||
Current Version: v0.7.0
|
Current Version: v0.7.1
|
||||||
|
|
||||||
## 2. Preparation
|
## 2. Preparation
|
||||||
|
|
||||||
|
|||||||
+8
-16
@@ -46,7 +46,7 @@ limitations under the License.
|
|||||||
#include <ros/package.h>
|
#include <ros/package.h>
|
||||||
#include <ros/ros.h>
|
#include <ros/ros.h>
|
||||||
#endif
|
#endif
|
||||||
#define ros_driver_version "0.7.0"
|
#define ros_driver_version "0.7.1"
|
||||||
#define recommended_firmware_version "0.8.0"
|
#define recommended_firmware_version "0.8.0"
|
||||||
|
|
||||||
// Global variable declarations
|
// Global variable declarations
|
||||||
@@ -1138,7 +1138,7 @@ static void lidar_device_callback(const lidar_device_info_t* device, bool attach
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool need_open_device = true;
|
bool need_open_device = true;
|
||||||
bool need_configure_device = true;
|
bool get_calib_file = true;
|
||||||
switch (device->initial_state) {
|
switch (device->initial_state) {
|
||||||
case LIDAR_DEVICE_NOT_INITIALIZED:
|
case LIDAR_DEVICE_NOT_INITIALIZED:
|
||||||
#ifdef ROS2
|
#ifdef ROS2
|
||||||
@@ -1156,17 +1156,17 @@ static void lidar_device_callback(const lidar_device_info_t* device, bool attach
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case LIDAR_DEVICE_STREAMING:
|
case LIDAR_DEVICE_STREAMING:
|
||||||
need_open_device = false;
|
|
||||||
need_configure_device = false;
|
|
||||||
#ifdef ROS2
|
#ifdef ROS2
|
||||||
RCLCPP_INFO(rclcpp::get_logger("device_cb"), "Device state: streaming, skip opening and configuring");
|
RCLCPP_WARN(rclcpp::get_logger("device_cb"), "Device state: streaming, this should not happen, exitting...");
|
||||||
#else
|
#else
|
||||||
ROS_INFO("Device state: streaming, skip opening and configuring");
|
ROS_WARN("Device state: streaming, this should not happen, exitting...");
|
||||||
#endif
|
#endif
|
||||||
|
system("pkill -f rviz");
|
||||||
|
exit(1);
|
||||||
break;
|
break;
|
||||||
case LIDAR_DEVICE_STREAM_STOPPED:
|
case LIDAR_DEVICE_STREAM_STOPPED:
|
||||||
need_open_device = false;
|
need_open_device = false;
|
||||||
need_configure_device = false;
|
get_calib_file = false;
|
||||||
#ifdef ROS2
|
#ifdef ROS2
|
||||||
RCLCPP_INFO(rclcpp::get_logger("device_cb"), "Device state: stream stopped, resume streaming");
|
RCLCPP_INFO(rclcpp::get_logger("device_cb"), "Device state: stream stopped, resume streaming");
|
||||||
#else
|
#else
|
||||||
@@ -1197,7 +1197,7 @@ static void lidar_device_callback(const lidar_device_info_t* device, bool attach
|
|||||||
|
|
||||||
std::string calib_config = config_dir + "/calib.yaml";
|
std::string calib_config = config_dir + "/calib.yaml";
|
||||||
calib_file_ = calib_config;
|
calib_file_ = calib_config;
|
||||||
if (need_configure_device) {
|
if (get_calib_file) {
|
||||||
if (lidar_get_calib_file(odinDevice, config_dir.c_str())) {
|
if (lidar_get_calib_file(odinDevice, config_dir.c_str())) {
|
||||||
#ifdef ROS2
|
#ifdef ROS2
|
||||||
RCLCPP_ERROR(rclcpp::get_logger("device_cb"), "Failed to get calibration file");
|
RCLCPP_ERROR(rclcpp::get_logger("device_cb"), "Failed to get calibration file");
|
||||||
@@ -1246,7 +1246,6 @@ static void lidar_device_callback(const lidar_device_info_t* device, bool attach
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (need_configure_device) {
|
|
||||||
if (lidar_set_mode(odinDevice, type)) {
|
if (lidar_set_mode(odinDevice, type)) {
|
||||||
#ifdef ROS2
|
#ifdef ROS2
|
||||||
RCLCPP_ERROR(rclcpp::get_logger("device_cb"), "Set mode failed");
|
RCLCPP_ERROR(rclcpp::get_logger("device_cb"), "Set mode failed");
|
||||||
@@ -1267,13 +1266,6 @@ static void lidar_device_callback(const lidar_device_info_t* device, bool attach
|
|||||||
ROS_WARN("Some custom parameters failed to apply");
|
ROS_WARN("Some custom parameters failed to apply");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
#ifdef ROS2
|
|
||||||
RCLCPP_INFO(rclcpp::get_logger("device_cb"), "Skipping device mode configuration for current state");
|
|
||||||
#else
|
|
||||||
ROS_INFO("Skipping device mode configuration for current state");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ROS2
|
#ifdef ROS2
|
||||||
RCLCPP_INFO(rclcpp::get_logger("device_cb"), "Custom map mode: %d", g_custom_map_mode);
|
RCLCPP_INFO(rclcpp::get_logger("device_cb"), "Custom map mode: %d", g_custom_map_mode);
|
||||||
|
|||||||
Reference in New Issue
Block a user