mavlink / mavros

MAVLink to ROS gateway with proxy for Ground Control Station
Other
879 stars 990 forks source link

Different behavior of mavros-based mission and QGC plan #1634

Closed dkati closed 2 years ago

dkati commented 2 years ago

Hello again.

My main goal is, while in mission,to force UAV "rotate" (yaw) based on the next waypoint.

Making the plan on the QGC, this is being doing nice and smooth.

although , via mavros, it doesnt...

Here is my QGC plan

{
    "fileType": "Plan",
    "geoFence": {
        "circles": [
        ],
        "polygons": [
        ],
        "version": 2
    },
    "groundStation": "QGroundControl",
    "mission": {
        "cruiseSpeed": 15,
        "firmwareType": 12,
        "globalPlanAltitudeMode": 1,
        "hoverSpeed": 5,
        "items": [
            {
                "AMSLAltAboveTerrain": null,
                "Altitude": 10,
                "AltitudeMode": 1,
                "autoContinue": true,
                "command": 22,
                "doJumpId": 1,
                "frame": 3,
                "params": [
                    0,
                    0,
                    0,
                    null,
                    39.4327538,
                    22.7950964,
                    10
                ],
                "type": "SimpleItem"
            },
            {
                "AMSLAltAboveTerrain": null,
                "Altitude": 10,
                "AltitudeMode": 1,
                "autoContinue": true,
                "command": 16,
                "doJumpId": 2,
                "frame": 3,
                "params": [
                    0,
                    0,
                    0,
                    null,
                    39.4325341,
                    22.79418495,
                    10
                ],
                "type": "SimpleItem"
            },
            {
                "autoContinue": true,
                "command": 178,
                "doJumpId": 3,
                "frame": 2,
                "params": [
                    1,
                    5,
                    -1,
                    0,
                    0,
                    0,
                    0
                ],
                "type": "SimpleItem"
            },
            {
                "AMSLAltAboveTerrain": null,
                "Altitude": 15,
                "AltitudeMode": 1,
                "autoContinue": true,
                "command": 16,
                "doJumpId": 4,
                "frame": 3,
                "params": [
                    0,
                    0,
                    0,
                    null,
                    39.43295672,
                    22.79414203,
                    15
                ],
                "type": "SimpleItem"
            },
            {
                "AMSLAltAboveTerrain": null,
                "Altitude": 10,
                "AltitudeMode": 1,
                "autoContinue": true,
                "command": 16,
                "doJumpId": 5,
                "frame": 3,
                "params": [
                    0,
                    0,
                    0,
                    null,
                    39.43350364,
                    22.79497888,
                    10
                ],
                "type": "SimpleItem"
            },
            {
                "AMSLAltAboveTerrain": null,
                "Altitude": 10,
                "AltitudeMode": 1,
                "autoContinue": true,
                "command": 16,
                "doJumpId": 6,
                "frame": 3,
                "params": [
                    0,
                    0,
                    0,
                    null,
                    39.43342906,
                    22.79538658,
                    10
                ],
                "type": "SimpleItem"
            },
            {
                "autoContinue": true,
                "command": 20,
                "doJumpId": 7,
                "frame": 2,
                "params": [
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0
                ],
                "type": "SimpleItem"
            }
        ],
        "plannedHomePosition": [
            39.4327538,
            22.7950964,
            54
        ],
        "vehicleType": 2,
        "version": 2
    },
    "rallyPoints": {
        "points": [
        ],
        "version": 2
    },
    "version": 1
}

and here is the function i have to send waypoints

Mission& Mission::addCMDGoTo(double lat, double lon, double alt,
                            bool isrelative) {
  mavros_msgs::Waypoint wp;

  wp.frame = isrelative ? mavros_msgs::Waypoint::FRAME_GLOBAL_REL_ALT
                        : mavros_msgs::Waypoint::FRAME_GLOBAL;
  wp.command = mavros_msgs::CommandCode::NAV_WAYPOINT;
  wp.is_current = false;
  wp.autocontinue = true;
  wp.x_lat = lat;
  wp.y_long = lon;
  wp.z_alt = alt;
  wp.param4 = NULL; // possibly unnecessary
  mWaypoints.request.waypoints.push_back(wp);
  return *this;
}

and i call it via a for loop.... Generally, it works, but UAV doesnt "rotate" when switching to the next waypoint, as QGC does

vooon commented 2 years ago

Try to upload mission by QGC then dump it with mavros. Then upload your mission trough mavros and do the dump again. It must have some difference.

dkati commented 2 years ago

i dont know what u mean by the term 'dump it'

vooon commented 2 years ago

mavwp dump.

dkati commented 2 years ago

a terminal command?i simply run

mavwp dump

at a fresh terminal?

(i am not at PC right now, thats why i ask)

vooon commented 2 years ago

On secondary terminal, while mavros node is running you need to run rosrun mavros mavwp dump mission1.txt. You might also use rosrun mavros mavwp show to see the table.

dkati commented 2 years ago

i did it. i reallized that the frame i used was wrong and i was sending yaw:0 . indeed, it needed yaw: std::numeric_limits::quiet_NaN();

you can close the issue safely :) Thanks a lot for that