thien94 / vision_to_mavros

A collection of ROS and non-ROS (Python) code that converts data from vision-based system (external localization system like fiducial tags, VIO, SLAM, or depth image) to corresponding mavros topics or MAVLink messages that can be consumed by a flight control stack (with working and tested examples for ArduPilot).
https://ardupilot.org/dev/docs/ros-vio-tracking-camera.html
GNU General Public License v3.0
242 stars 146 forks source link

Drone flies well for a while and then it goes forward very quickly while using a backwards facing t265 #37

Closed maxilar20 closed 3 years ago

maxilar20 commented 3 years ago

I'm having an issue where I can't manage to set the yaw variable correctly. The camera is facing backwards and so I set the yaw_camera to 3.1215 but when I'm flying it just wants to go to the side very quickly. It worked when It was just facing forwards but I changed only that value and it doesn't seem to work now.

I also tried giving it a transformation from the t265 frame to a base_link frame that was positioned correctly (and leaving the yaw value at 0) but it only worked for some second until I wanted to move it, then it just flew to the side very quickly.

thien94 commented 3 years ago

Hi @maxilar20, thank you for the question. I have not personally tested the backward-facing configuration, so I can only provide suggestions:

An example of the trajectory: image

maxilar20 commented 3 years ago

Thanks for the quick reply!

So, I did what you said about the yaw_cam value, and when I try to see the gps position it start with a heading of 270 degrees: Screenshot from 2021-04-09 22-56-59

and when I move it forwards, the drone moves to the south on the map, and when I move it to the right it moves to the west. Screenshot from 2021-04-09 22-57-15 Screenshot from 2021-04-09 22-57-35

EDIT 1: This is a portion of my launch file that contains the node:

    <node pkg="vision_to_mavros" type="vision_to_mavros_node" name="t265_to_mavros" output="screen" >
        <remap from="vision_pose" to="/mavros/vision_pose/pose" />
        <param name="target_frame_id"   value="/camera_odom_frame" />
        <param name="source_frame_id"   value="/camera_link" />
        <param name="output_rate"       value="30" />
        <param name="roll_cam"          value="0" />
        <param name="pitch_cam"         value="0" />
        <param name="yaw_cam"           value="3.1415" />
        <param name="gamma_world"       value="-1.5707963" />
    </node>

EDIT 2: I think I know why this error happened. Will try to run solving this issue first.

[ WARN] [1618023225.034181315]: Using default target_frame_id: /camera_odom_frame [ WARN] [1618023225.043092296]: Using default source_frame_id: /camera_link [ WARN] [1618023225.045550371]: Using default output_rate: 20.000000 [ WARN] [1618023225.049702426]: Using default gamma_world: -1.570796 [ WARN] [1618023225.051964167]: Using default roll_cam: 0.000000 [ WARN] [1618023225.055198500]: Using default pitch_cam: 0.000000 [ WARN] [1618023225.057329611]: Using default yaw_cam: 1.570796

EDIT 3: After I solved this issue it appeared correctly in the map, and flew ok for some seconds, but when I tried to move it, it just went crazy.

maxilar20 commented 3 years ago

Is it normal that it's pointing to the south on startup?

thien94 commented 3 years ago

The default heading should be north if gamma_world is set correctly. However, do check that the result is repeatable between multiple runs (in case the heading was incorrect due to other reasons not aware of) before testing out a new param.

A bit of a guessing game, but you can record the result with gamma_world as 0, +1.570796, -1.570796, 3.1415 to see how the param affects the heading.