Problem using 'real serial device' (XBee) with SITL

Hi folks

We are trying to use SITL with a "real serial device" but so far we couldn't manage to get it working properly.

The goal is to have two APM's, each with a Xbee connected.

The setup is the following:

(We are using a custom 3.2.1 firmware)
2 APM's with UART2 (uartC) connected to an XBee

APM A is in a cardboard box, transmitting it's gps location (external Ublox module) every second over the Xbee

CODE APM A:
void sendGps()
{
    Vector3f gpspos;
    gpspos[0] = current_loc.lat;
    gpspos[1] = current_loc.lng;
    gpspos[2] = current_loc.alt;
    hal.uartC->printf("%.6f %.6f %.6f\n", gpspos.x, gpspos.y, gpspos.z);
}

This works fine and we get 3 numbers. These should be taken by APM B to fly to this location (with an offset)

CODE APM B:
void calcOffset()
{
    /* here f_lon before f_lat, because initial value of f_lat needed */
        f_lon_new = f_lon + 10*89.8315284/**(1/(cos((f_lat/1e7)*0.0174532925)))*/;
        f_lat_new = f_lat + 10*89.8315284;
        f_alt_new = f_alt + 3*100.00f;
        hal.console->printf("f_lat_new: %10.8f f_lon_new: %10.8f f_alt_new: %10.8f\n",
            f_lat_new, f_lon_new, f_alt_new);
}


CODE APM B:
void followMasterdrone()
{
    Vector3f target;
    Vector3f pos;
    pos[0] = current_loc.lat;
    pos[1] = current_loc.lng;
    pos[2] = current_loc.alt;

    /* set target and speed ................................................... */
    target.x = (f_lat_new - pos.x) * LATLON_TO_CM;
    target.y = (f_lon_new - pos.y) * LATLON_TO_CM;
    target.z = f_alt_new  - pos.z;
     guided_set_destination(target);
}


The problem now is to get SITL to use these values in its simulation.

We have connected an Xbee to the computer and used the command -A: "sim_vehicle.sh -v ArduCopter -L Windisch3 -A "--uartC=uart:/dev/ttyUSB0" --console --map"" but in the simulation the drone only flies to the offset, ignoring the gps coordinates from the cardbox. We can get them in the console window by adding this link but we need the code to work with these values from the XBee.

Has someone an idea what we are doing wrong or what the problem might be?

Thanks so much for your help!

Additional Screenshots:

Bildschirmfoto vom 2016-02-16 11_32_42.png

Bildschirmfoto vom 2016-02-16 11_47_27.png

Bildschirmfoto vom 2016-02-16 11_48_45.png

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • Hey Ben,

    Did you ever have any success with this? Trying to do something similar and having trouble figuring out whether SITL is a viable option...

  • We are starting to believe the simulation is just not capable of this.  :-(

    But please let us know if you have any suggestions to solve this issue!

This reply was deleted.

Activity

Neville Rodrigues liked Neville Rodrigues's profile
Jun 30
Santiago Perez liked Santiago Perez's profile
Jun 21
More…