Can we reset the drone to initial position after navigating it to some point


#1

I have navigated the drone to particular position but when I am trying to navigate it back to initial position its not getting back to initial position.
Is there any command to reset drone to initial position instead of navigating.


#2

Hi,

I don’t understand. What do you want to do?
Please mention the APIs that you are calling along with their arguments.

No there isn’t any. You would have to restart FlytSim for the same. Unless you have flown thousands of meters away, navigating it to initial position won’t take much time if done correctly.


#3

public class DroneNav {
static ObjectMapper mapper ;
public static boolean navigate(){
try{
// RestCalls.callGet(“http://localhost/ros/flytsim/navigation/arm”);

// sleep(4000);
takeOff(6.0f);
sleep(15000);
setPoint(0.0f,0.0f,0.0f, -1.5f);
sleep(5000);
setPoint(13.5f,0.0f,0.0f, 0.0f);
sleep(8000);
positionHold();
sleep(6000);
}
catch(Exception e){
System.out.println(“failed to connect”);
return false;
}
return true;
}
public static boolean setPoint(float x,float y,float z, float yaw){

  try{
  String pnt2 = "";

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("x",x);
    map.put("y", y);
     map.put("z", z);
    map.put("yaw", yaw);
     map.put("yaw_valid", true);
    map.put("tolerance", 2.00);
   map.put("relative", true);
 map.put("async", false);
    map.put("body_frame",true);
		// convert map to JSON string
pnt2 = mapper.writeValueAsString(map);
RestCalls.callPost("http://localhost/ros/flytsim/navigation/position_set", pnt2);
  }
  catch (Exception e) {
	// TODO: handle exception
	  return false;
}
  return true;

}

public static void takeOff(float alt){
try{
mapper = new ObjectMapper();
String json1 = “”;

  Map<String, Object> map1 = new HashMap<String, Object>();
map1.put("takeoff_alt",alt);

		// convert map to JSON string
json1 = mapper.writeValueAsString(map1);

RestCalls.callPost(“http://localhost/ros/flytsim/navigation/take_off”, json1);
}
catch(Exception e){
if(e instanceof RuntimeException ){
throw new RuntimeException();
}

 }

}

public static boolean reset(){

  try{
  String pnt2 = "";

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("x",0.00);
    map.put("y", 0.00);
     map.put("z", 0.00);
    map.put("yaw", -1.50);
     map.put("yaw_valid", true);
    map.put("tolerance", 2.00);
   map.put("relative", false);
 map.put("async", true);
    map.put("body_frame",false);
		// convert map to JSON string
pnt2 = mapper.writeValueAsString(map);
RestCalls.callPost("http://localhost/ros/flytsim/navigation/position_set", pnt2);
  }
  catch (Exception e) {
	// TODO: handle exception
	  return false;
}
  return true;

}

public static void sleep(int milli){
try{
Thread.sleep(milli);
}
catch(Exception e){}
}
public static boolean land(){
RestCalls.callGet(“http://localhost/ros/flytsim/navigation/land”);
return true;
}
public static void positionHold(){
RestCalls.callGet(“http://localhost/ros/flytsim/navigation/position_hold”);
}
}

I was calling navigate() first and then land()
reset() in the last


#4

Hi,

Please explain the observed and expected drone behaviour.
As I understand, according to your code:

STEP1 (navigate)

  • Vehicle arms, and does a takeoff to 6m,
  • Then it yaws by -1.5rad, at the same location,
  • Then moves in x direction by 13.5m, keeping y,z and yaw same,
  • And then, you call position hold after 8 sec, which would force the drone to hover at its current location.

STEP2 (land)

  • You command the drone to land
  • But in your code, you have not mentioned how exactly are you waiting for it to land (via sleep or callback or any other method)

STEP3 (reset)

  • Assuming vehicle is landed now and is in disarmed state, THERE IS NO WAY to move it unless you command it to takeoff. You cannot move a drone unless its armed. You must be getting similar responses in the API message as well.

Note: Suggest you to send only Takeoff command instead of sending ARM+Takeoff command.


#5

Sorry for improper information

After calling land() process gets stopped

after the drone has landed I call takeoff() and then call reset()


#6

As requested previously, please post your response.


#7

Expected :I want to navigate the drone to a point say (13.5 ,0,0) and then get the drone to initial point(0,0,0).

Observed :I was able to navigate the drone to point say (13.5,0,0) but was not able to bring it back exactly to initial point
(0,0,0).


#8

Hi,

Then where did the drone go to?
In other thread you are anyway suggesting that the drone is crashing. As I had said in that thread, it seems you have to set it up on a Linux machine.