stereolabs / zed-ros-wrapper

ROS wrapper for the ZED SDK
https://www.stereolabs.com/docs/ros/
MIT License
447 stars 391 forks source link

Storing magnetometer caliberaton file locally #786

Open dineshrboson opened 2 years ago

dineshrboson commented 2 years ago

Preliminary Checks

Proposal

I am performing GPS Waypoint Navigation and in order to calculate angle between coordinates and reach that angle I am using zed magnetometer topic as you are aware of the fact that we need to calibrate the magnetometer in the zed_sensor_viewer and set that calibration into the camera. As a matter of fact the magnetometer in the zed will demagnetize again after some time, and it is very difficult to take the zed camera out of the robot and do calibration and mount it back and its not a perfect way to do it I believe , so it there is a way to actually load the calibration from python code everyday once before launching the GPS waypoint navigation. As a side note whenever I am using mobile magnetometer topic using (android sensor app) giving way better results like going in a straight path and whenever using the zed magnetometer topic Its not actually perfect after doing hard iron calibration also.

Use-Case

No response

Anything else?

No response

Myzhar commented 2 years ago

Hi @dineshrboson can you please explain better what you mean with As a matter of fact the magnetometer in the zed will demagnetize again after some time?

The ZED magnetometer does not demagnetize, the magnetometer readings are affected by hard and soft ironing effects introduced by the robot components and by the environment where the robot is performing. The camera magnetometer MUST NOT be calibrated outside the robot, when you insert the camera again inside it the magnetometer reading will be distorted by the motor magnets, the cables, and the case (if metallic). As for every type of magnetometer sensor, the calibration must be performed ONBOARD. I know that this is not always easy because robots are ofter huge and heavy and it's not easy to "rotate them freely in the space", but it's the only way to achieve a reliable magnetometer calibration. An alternative is to perform the calibration by manually driving the robot, performing on place rotations and movements on not planar surfaces (if it's a ground robot).

PS magnetometer calibration parameters are stored in the EEPROM of the camera and they are restored each time the camera is opened.

dineshrboson commented 2 years ago

It's not actually demagnetized, but distorted because of the metal objects near the camera placed.

Can you give me an Idea of how to do calibration for a ground robot, do I need to write a python script to open zed_sensor_viewer and then manually drive the robot and perform rotations and then how can I save that from the code itself?

Is there any chance that the calibration parameters stored in EEPROM memory will be affected by the magnetic distortions and then those will be saved further?

Myzhar commented 2 years ago

It's not actually demagnetized, but distorted because of the metal objects near the camera placed.

Exactly what I wrote in my first reply.

Can you give me an Idea of how to do calibration for a ground robot, do I need to write a python script to open zed_sensor_viewer and then manually drive the robot and perform rotations and then how can I save that from the code itself? The only way is by opening the ZED Sensor Viewer tool and following the visual instructions. We do not provide APIs to perform calibration.

The alternative is to retrieve raw values and use the ROS2 tools to perform your own magnetometer calibration or write your ROS node to perform the procedure while driving the robot...

Is there any chance that the calibration parameters stored in EEPROM memory will be affected by the magnetic distortions and then those will be saved further?

The procedure will save the parameters calculated in the environment where the procedure is executed, so they are affected by the distortions present in that moment...

dineshrboson commented 2 years ago

Think about using the zed camera in a production robot. User will be taking the robot to different environmental conditions, and he can't perform the zed magnetometer calibration frequently following the visual instructions, so is there any way to tackle this problem?!

dineshrboson commented 2 years ago

Can you elaborate on how to retrieve raw values, (one way may be through ROS topic) and I am using ROS1 and is there any tool like you mentioned for ROS2 to perform calibration?