AP_HAL_SITL: created ADS-B simulator to generate additional ghost aircraft within SITL

- The values are very aggressive, you'll come into contact with another aircraft very soon
- Credit goes to Tridge for this work
- This also allows hardware attached via UART to feed real aircraft into the simulator

This feature is enabled with the following command:
sim_vehicle -A --adsb
This commit is contained in:
Tom Pittenger 2015-11-18 17:22:47 -08:00 committed by Andrew Tridgell
parent f88de986bc
commit bb4f0783ad
3 changed files with 21 additions and 4 deletions

View File

@ -60,7 +60,7 @@ void SITL_State::_set_param_default(const char *parm)
/*
setup for SITL handling
*/
void SITL_State::_sitl_setup(void)
void SITL_State::_sitl_setup(const char *home_str)
{
#ifndef __CYGWIN__
_parent_pid = getppid();
@ -93,6 +93,9 @@ void SITL_State::_sitl_setup(void)
if (enable_gimbal) {
gimbal = new Gimbal(_sitl->state);
}
if (enable_ADSB) {
adsb = new ADSB(_sitl->state, home_str);
}
}
if (_synthetic_clock_mode) {
@ -252,6 +255,9 @@ void SITL_State::_fdm_input_local(void)
if (gimbal != NULL) {
gimbal->update();
}
if (adsb != NULL) {
adsb->update();
}
// update simulation time
hal.scheduler->stop_clock(_sitl->state.timestamp_us);

View File

@ -23,6 +23,7 @@
#include <AP_Terrain/AP_Terrain.h>
#include <SITL/SITL.h>
#include <SITL/SIM_Gimbal.h>
#include <SITL/SIM_ADSB.h>
class HAL_SITL;
@ -71,7 +72,7 @@ private:
void _parse_command_line(int argc, char * const argv[]);
void _set_param_default(const char *parm);
void _usage(void);
void _sitl_setup(void);
void _sitl_setup(const char *home_str);
void _setup_fdm(void);
void _setup_timer(void);
void _setup_adc(void);
@ -200,6 +201,10 @@ private:
bool enable_gimbal;
SITL::Gimbal *gimbal;
// simulated gimbal
bool enable_ADSB;
SITL::ADSB *adsb;
// TCP address to connect uartC to
const char *_client_address;
};

View File

@ -46,6 +46,7 @@ void SITL_State::_usage(void)
"\t--instance N set instance of SITL (adds 10*instance to all port numbers)\n"
"\t--speedup SPEEDUP set simulation speedup\n"
"\t--gimbal enable simulated MAVLink gimbal\n"
"\t--adsb enable simulated ADSB peripheral\n"
"\t--autotest-dir DIR set directory for additional files\n"
"\t--uartA device set device string for UARTA\n"
"\t--uartB device set device string for UARTB\n"
@ -113,7 +114,8 @@ void SITL_State::_parse_command_line(int argc, char * const argv[])
CMDLINE_UARTB,
CMDLINE_UARTC,
CMDLINE_UARTD,
CMDLINE_UARTE
CMDLINE_UARTE,
CMDLINE_ADSB,
};
const struct GetOptLong::option options[] = {
@ -134,6 +136,7 @@ void SITL_State::_parse_command_line(int argc, char * const argv[])
{"uartE", true, 0, CMDLINE_UARTE},
{"client", true, 0, CMDLINE_CLIENT},
{"gimbal", false, 0, CMDLINE_GIMBAL},
{"adsb", false, 0, CMDLINE_ADSB},
{"autotest-dir", true, 0, CMDLINE_AUTOTESTDIR},
{0, false, 0, 0}
};
@ -184,6 +187,9 @@ void SITL_State::_parse_command_line(int argc, char * const argv[])
case CMDLINE_GIMBAL:
enable_gimbal = true;
break;
case CMDLINE_ADSB:
enable_ADSB = true;
break;
case CMDLINE_AUTOTESTDIR:
autotest_dir = strdup(gopt.optarg);
break;
@ -240,7 +246,7 @@ void SITL_State::_parse_command_line(int argc, char * const argv[])
}
}
_sitl_setup();
_sitl_setup(home_str);
}
#endif