NDHANA94 / ros2_wheeltec_n100_imu

ROS2 driver pkg for wheeltec N100 IMU module.
7 stars 1 forks source link

Getting same error as previous person - segmentation fault #2

Open edfang1 opened 10 months ago

edfang1 commented 10 months ago

Will get a segmentation fault if the 921600 default baud rate is used. If i change the baud rate to anything else, get a lot of junk head_type errors that just scroll. Faster if you use the IMU - so some data is flowing.

Tried replacing all the 921600 to something else like 460800, rebuilt but data still shows the same. Not sure what else to try. Followed the directions on a clean workspace build and colcon build. So obviously connecting with the correct ttyUSBX port - but just cant seem to get the proper data. Running on 22.04

[WARN] [1704763714.999857018] [imu_node]: head_type error: m [WARN] [1704763715.419389586] [imu_node]: head_type error: y [WARN] [1704763715.669497928] [imu_node]: head_type error: [WARN] [1704763715.699406065] [imu_node]: head_type error: m [WARN] [1704763715.769009148] [imu_node]: head_type error: m [WARN] [1704763715.849610289] [imu_node]: head_type error: m [WARN] [1704763715.868508425] [imu_node]: head_type error: m

edfang1 commented 10 months ago

As a follow up, its segmentation faulting on this line in imu_node.cpp imu_data.orientation_covariance[0] = imu_mag_cov[0];

Not sure why, but it seems to be on that line. If the baud rate is lowered to 460800, garbage (probably mismatched baud rates) text comes out - but it does not segmentation fault. . But 921600 is immediately faults when it hits that line.

Onicc commented 1 month ago

The issue arises because the following vectors:

std::vector<double> imu_mag_cov;
std::vector<double> imu_gyro_cov;
std::vector<double> imu_accel_cov;

are being used without having assigned any values.

Solution: Modify lines 53 to 55 in imu_node.cpp of the repository here as follows:

imu_mag_cov = this->get_parameter("imu_mag_covVec").as_double_array();
imu_gyro_cov = this->get_parameter("imu_gyro_covVec").as_double_array();
imu_accel_cov = this->get_parameter("imu_accel_covVec").as_double_array();

This will ensure that the vectors are properly initialized with the values from the parameters.