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:
gpspos = current_loc.lat;
gpspos = current_loc.lng;
gpspos = 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:
/* 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:
pos = current_loc.lat;
pos = current_loc.lng;
pos = 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;
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!
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!
Did you ever have any success with this? Trying to do something similar and having trouble figuring out whether SITL is a viable option...