Need Return to Home Api


#1

Hello Srv,
Please tell me the api for Return to Home.
Is it working with waypoint api. so we can pause the mission and return to home. Or in Furture we can resume the waypoint task.

Thanks in advance


#2

Hello Trilok,

SRV is out of office and should be back in two days. Kindly wait until he gets back to you.


#3

Hi Trilok,
As we dont have a proper API available yet for RTL, we are providing you a hack around to do the same.
This is the sample code for JavaScript to make the rest API call which does the required function.

   var msgdata={};
   msgdata["broadcast"]=false;
   msgdata["command"]=176;
   msgdata["confirmation"]=0;
   msgdata["param1"]=129.0;
   msgdata["param2"]=4.0;
   msgdata["param3"]=5.0;
   msgdata["param4"]=0.0;
   msgdata["param5"]=0.0;
   msgdata["param6"]=0.0;
   msgdata["param7"]=0.0;
   console.log("clicked rtl");
   console.log(msgdata);
   $.ajax({
      type: "POST",
      dataType: "json",
      data: JSON.stringify(msgdata),
      url: "https://"+ip+"/ros/"+namespace+"/mavros/cmd/command",
      success: function(data){
           console.log(data);
      }
    });

Please make sure you make the rest call with these exact parameter values.

To set the return altitude you can set **RTL_RETURN_ALT** parameter for a value in meters.(default 30 ).

To set a loiter time after it reaches home set **RTL_LAND_DELAY** in seconds.(default 0 ).

To set a loiter height after it reaches home set **RTL_DESCEND_ALT** in meters. (default 0).

Add a new entry to the file at /flyt/flytos/flytcore/share/core_api/launch/core_api_autopilot.launch in the arg name="services" section, just before the closing square brackets. Add ,'/$(arg global_namespace)/mavros/cmd/command'

Relaunch FLytOS.


Emergency landing API
#4

Trilok,

Something that I’ve been doing is using the local coordinate API to return to home. I have it set to x=0 and y=0 at 5m, which brings it back home and hovers at 5 meters. If you wanted to pause your mission and return to home, use the pause waypoint API followed by the local coordinate API in your JS. Here’s an example of my RTH:

$("#RTH").click(function(){

var  msgdata={};
msgdata["twist"]={};
msgdata.twist["twist"]={};
msgdata.twist.twist["linear"]={};
msgdata.twist.twist.linear["x"]=0.00;
msgdata.twist.twist.linear["y"]=0.00;
msgdata.twist.twist.linear["z"]=-5.00;
msgdata.twist.twist["angular"]={};
msgdata.twist.twist.angular["z"]=1.00;
msgdata["tolerance"]=2.00;
msgdata["async"]=true;
msgdata["relative"]=false;
msgdata["yaw_valid"]=true;
msgdata["body_frame"]=false;

$.ajax({
    type: "POST",
    dataType: "json",
    data: JSON.stringify(msgdata),
    url: "http://"+ip+"/ros/"+namespace+"/navigation/position_set",
    success: function(data){
        console.log("RTH go", data);
    },
    error: function(data){
        console.log("RTH no-go", data)
    }
});

});


#5

Thanks for this,

But can you please tell me, how i use this between the way point mission running.
Drone will be much far than 5 meter.
and we have Geo coordinate of drone base location.

Thanks


Emergency landing API
#6

Hi,

I cannot understand you. Please reframe the question, add more detail, and present with more clarity.


#7

Hello Srv,
I want to know. if i have not distance in meters, but i have my base location coordinates. (Latitude, longitude)
Then i use this code (.js)


#8

Hi,

The code offered by Kyle, was in case there is no such specific API. Are you facing any problem with vallabh’s suggestion?


#9

Hello,
am not tried yet, because flysim is not working.
I can’t connect flytsim from any source. (web service api, flytconsole)

let me re download the old verson of flytsim and then check.

Thanks for your quick support :slight_smile: