mavlink / mavros

MAVLink to ROS gateway with proxy for Ground Control Station
Other
847 stars 983 forks source link

Setpoint_Position/Local makes ArduCopter drop #1944

Open ZhongmouLi opened 2 months ago

ZhongmouLi commented 2 months ago

mavros/cmd/takeoff - Setpoint_Position/Local makes drone drop in the air

It has been discussed that ArduCopter can only use the topic when it is in the air (see Setpoint_Position/Local Position Control: Relative Positioning, simple script using mavros setpoint_position and Takeoff service is not working as expected.

Therefore, it is suggested to first call takeoff service to make the drone in the air and then publish septoints.

However, I find that the drone will drop very quickly between the two actions which is dangerous. Is there any way to deal with this? My code is like

 // 1. send takeoff request
    mavros_msgs::CommandTOL srv_takeoff;
    srv_takeoff.request.altitude = 1.0;
    if(takeoff_client.call(srv_takeoff)){
      ROS_INFO("takeoff sent %d", srv_takeoff.response.success);
    }else{
      ROS_ERROR("Failed Takeoff");
      return -2;
    }

    // 2. wait takeoff to finish
    double t_takeoff_begin = ros::Time::now().toSec();
    double t_takeoff = 0;
    while (ros::ok() && t_takeoff<10)
    {
      ROS_INFO("taking off");
      t_takeoff = ros::Time::now().toSec()-t_takeoff_begin;
    }

    // 3. publish setpoints
    for (size_t ii = 0; ii < v_waypoints_t.rows()-1; ii++)
    {

MAVROS version and platform

Mavros: 1.17 ROS: Noetic Ubuntu: 20.04

Autopilot type and version

[X] ArduPilot [ ] PX4

Version: 4.4.0

Node logs

copy output of mavros_node. Usually console where you run roslaunch

Diagnostics

place here result of:
rostopic echo -n1 /diagnostics

Check ID

rosrun mavros checkid