Commit Graph

303 Commits

Author SHA1 Message Date
Ricardo de Almeida Gonzaga 5bd034a5a8 Global: start using cmath instead of math.h 2016-04-05 21:06:19 -07:00
Andrew Tridgell 4d01cb1716 HAL_SITL: fixed SITL engine mul error
expression without get() was treated as int
2016-03-26 14:17:12 +11:00
Andrew Tridgell 5c92adddf9 HAL_SITL: allow examples to run under SITL 2016-03-25 21:35:16 +11:00
Lucas De Marchi e6059f5197 AP_Compass: rename files to follow other libraries
AP_Compass.h is the main header to be exported and AP_Compass.cpp its
implementation. There's no need for an additional header.
2016-03-23 17:50:38 -03:00
Lucas De Marchi bcdc3336de AP_HAL_SITL: replace header guard with pragma once 2016-03-16 18:40:41 +11:00
Will Sackfield 0a60d713af AP HAL SITL: Use fully qualified SITL namespace
* using namespace SITL caused ambiguities due to
both SITL and HAL SITL using the same namespace
2016-02-29 14:14:37 +11:00
Michael du Breuil 287a3367ad AP_HAL_SITL: Force the simulated gps time to be on valid intervals for u-blox hardware 2016-02-26 09:57:03 +11:00
Lucas De Marchi c3d8ba3ea5 AP_HAL_SITL: use empty I2CDevice 2016-02-16 19:49:09 -02:00
Lucas De Marchi 9aa49cda93 Global: remove system_initializing() from scheduler
This is not used anymore.
2016-02-12 23:42:34 -02:00
Andrew Tridgell cb60384dc4 AP_HAL_SITL: allow auto-baudrate detection in GPS driver in SITL
this is useful when testing a real GPS in SITL
2016-02-11 18:46:01 +11:00
Tom Pittenger f695f37ca3 AP_HAL_SITL: handle negative throttle
- negative throttle was causing negative voltage offsets
2016-02-09 14:18:01 +11:00
Lucas De Marchi 0e09975fa6 AP_HAL_SITL: fix typo 2016-02-01 14:18:51 -02:00
Andrew Tridgell 097c2011e1 HAL_SITL: prevent abort on select with -1 fd 2016-01-10 21:26:35 +11:00
Andrew Tridgell deb0b9c197 HAL_SITL: read in larger chunks 2016-01-10 17:43:01 +11:00
Andrew Tridgell 655f57ad01 HAL_SITL: cleanup class names
remove SITL prefix
2016-01-10 17:43:01 +11:00
Andrew Tridgell 492c733750 HAL_SITL: added RingBuffers to UART driver
makes for faster log download
2016-01-10 17:43:01 +11:00
Andrew Tridgell 22e25cc792 HAL_SITL: added Flightaxis support 2016-01-09 07:38:51 +11:00
Andrew Tridgell b4cc3d9668 HAL_SITL: implement get_custom_defaults_file() 2016-01-07 09:09:40 +11:00
Andrew Tridgell 6c064ae8bd HAL_SITL: flow control is enabled on SITL
faster parameter download
2016-01-06 19:16:08 +11:00
Andrew Tridgell dd07ffce08 HAL_SITL: enable debug of rcoutput channel enable and frequency 2016-01-05 09:47:55 +11:00
Andrew Tridgell 2dd8a0af74 HAL_SITL: allow visualisation of quad motor speeds in flightgear 2016-01-04 11:09:27 +11:00
Andrew Tridgell 1450f33b51 HAL_SITL: support 16 RC input channels in SITL 2016-01-04 08:22:02 +11:00
Andrew Tridgell 83c8505b3c HAL_SITL: send state to flightgear viewer 2016-01-04 08:02:37 +11:00
Andrew Tridgell e6555aae6d HAL_SITL: added quadplane model 2016-01-01 14:35:15 +11:00
Andrew Tridgell d0896a1fb2 HAL_SITL: fixed init of channel 8 out in plane and rover
should be low
2016-01-01 14:35:15 +11:00
Andrew Tridgell c6b6d7137d HAL_SITL: added plane simulator 2016-01-01 12:41:06 +11:00
Andrew Tridgell 05e04ee1a7 HAL_SITL: added semaphore support 2015-12-21 07:38:30 +11:00
Julien BERAUD d8bcb36530 AP_HAL_SITL: add empty optical flow
No embedded optical flow on sitl
2015-12-18 17:56:04 +11:00
Tom Pittenger 48ae0d645d AP_HAL_SITL: compiler warning: float to double promotion
- replace atof() with strtof() for the correct return time
2015-12-08 14:54:43 +09:00
Lucas De Marchi c72f812944 AP_HAL_SITL: rename AP_HAL_Empty instances 2015-12-08 11:12:14 +11:00
Lucas De Marchi 4c82c535cc AP_HAL_SITL: use init() method without arguments
Override the init() method from parent class that doesn't have a
parameter since it's not used here.
2015-12-02 14:49:11 -02:00
Tom Pittenger bb4f0783ad 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
2015-11-23 19:45:40 +11:00
Andrew Tridgell 7a5c4ec65d HAL_SITL: use battery info from FDM if available 2015-11-23 13:31:29 +11:00
Andrew Tridgell a6ef064950 HAL_SITL: removed support for the old FDM protocol
we are now fully converted to the new C++ based SITL system
2015-11-23 13:21:33 +11:00
Caio Marcelo de Oliveira Filho bb165d8a4c AP_HAL_SITL: Remove unused extern declaration for HALs 2015-11-20 16:32:45 +09:00
Caio Marcelo de Oliveira Filho 783db23a0f AP_HAL_SITL: remove unused functions 2015-11-20 12:36:42 +09:00
Caio Marcelo de Oliveira Filho 85d12efbef AP_HAL_SITL: use millis/micros/panic functions 2015-11-20 12:31:20 +09:00
Caio Marcelo de Oliveira Filho 3ef77617fd AP_HAL_SITL: implement new AP_HAL functions
Implement the new AP_HAL functions and use them in the Scheduler when
possible.

The '_sketch_start_time' was renamed and moved as a detail of
implementation of the functions code. It allows the code to return time
starting from zero.

The 'stopped_clock_usec' was renamed to follow convention in the file
and add a getter so that AP_HAL functions can reach it. It's not a
problem this getter is public because in practice, regular code
shouldn't even access the SITLScheduler directly -- only code that
should is from SITL itself.
2015-11-20 12:25:38 +09:00
Caio Marcelo de Oliveira Filho efbc7648b1 AP_HAL: create AP_HAL namespace and use for some HAL functionality
For certain basic functionality, there aren't much benefit to be able to
vary the implementation easily at runtime. So instead of using virtual
functions, use regular functions that are "resolved" at link time. The
implementation of such functions is provided per board/platform.

Examples of functions that fit this include: getting the current
time (since boot), panic'ing, getting system information, rebooting.

These functions are less likely to benefit from the indirection provided
by virtual interfaces. For more complex hardware access APIs the
indirection makes more sense and ease the testing (when we have it!).

The idea is that instead of calling

    hal.scheduler->panic("on the streets of london");

now use

    AP_HAL::panic("on the streets of london");

A less important side-effect is that call-site code gets
smaller. Currently the compiler needs to get the hal, get the scheduler
pointer, get the right function pointer in the vtable for that
scheduler. And the call must include an extra parameter ("this"). Now it
will be just a function call, with the address resolved at link time.

This patch introduces the first functions that will be in the namespace,
further patches will implementations for each board and then switch the
call-sites. The extra init() function allow any initial setup needed for
the functions to work.
2015-11-20 12:25:24 +09:00
Andrew Tridgell 95ca0b39a8 HAL_SITL: moved virtual INS sensor to AP_InertialSensor_SITL 2015-11-16 17:57:35 +11:00
Andrew Tridgell 2675edcb96 HAL_SITL: removed unused variables 2015-11-16 17:57:35 +11:00
Andrew Tridgell 81e34006a5 HAL_SITL: make available_memory() uint32_t 2015-11-05 16:09:00 +11:00
Andrew Tridgell 75d2aed6e1 HAL_SITL: added help for uart command line checks 2015-11-04 14:26:55 +11:00
Lucas De Marchi cf8203c08b AP_HAL_SITL: remove checks for HAL_BOARD_APM2 and HAL_BOARD_APM1 2015-11-04 12:14:12 +11:00
Andrew Tridgell a5a1680fb3 HAL_SITL: added support for real UART devices
This allows use of real UART devices in the simulator. Useful for GPS
driver work or other MAVLink peripherals
2015-11-04 11:29:04 +11:00
Lucas De Marchi 1b07dabeb7 Replace prog_char and prog_char_t with char
prog_char and prog_char_t are now the same as char on supported
platforms. So, just change all places that use them and prefer char
instead.

AVR-specific places were not changed.
2015-10-30 14:35:30 +09:00
Lucas De Marchi 20c6ffc5e3 Replace use of UARTDriver::printf_P() with UARTDriver::printf()
This also starts to show warnings on places that were already using
wrong printf format strings.
2015-10-30 14:35:25 +09:00
Lucas De Marchi 7ceffb1e2b Replace use of vprintf_P() with vprintf() 2015-10-30 14:35:23 +09:00
Lucas De Marchi 6f4904189b Replace use of println_P() with println() 2015-10-30 14:35:22 +09:00
Lucas De Marchi 2c38e31c93 Remove use of PSTR
The PSTR is already define as a NOP for all supported platforms. It's
only needed for AVR so here we remove all the uses throughout the
codebase.

This was automated with a simple python script so it also converts
places which spans to multiple lines, removing the matching parentheses.

AVR-specific places were not changed.
2015-10-30 14:35:04 +09:00
Lucas De Marchi 9eaf7c5660 AP_HAL: add format attribute to panic() 2015-10-24 14:26:36 +11:00
Lucas De Marchi 6027a02fe9 AP_HAL_SITL: Scheduler: implement variadic version of panic() 2015-10-24 14:26:36 +11:00
Lucas De Marchi ad61a93c14 AP_HAL: turn panic() into a variadic method
Change the declaration on all HAL implementations so panic() in future
may implement a printf-like interface.
2015-10-24 14:26:35 +11:00
Caio Marcelo de Oliveira Filho 49a42dc985 SITL: use a SITL namespace 2015-10-22 11:04:42 -02:00
Andrew Tridgell 6b048b4045 HAL_SITL: use SimRover 2015-10-21 22:04:21 +11:00
wsilva32 ab7148386c AP_HAL_AVR_SITL: Limit SITL compass reports to 100Hz
Similarly to how the SITL baro currently works, setHIL is only called at 100Hz.
2015-10-21 10:39:27 +11:00
Caio Marcelo de Oliveira Filho 19b4ca60c4 AP_HAL: provide AP_HAL_MAIN()
Move the macros to a single place and reduce the variations not based on
board, but based on

- The name of the entry-point function, specified by AP_MAIN;
- Whether it contains argc/argv arguments or not.

The goal here is that programs (vehicles and examples) don't need to
include all possible boards to define a main function. Further patches
will change the programs.
2015-10-21 09:16:09 +11:00
Caio Marcelo de Oliveira Filho e4ef0e43c0 AP_HAL_SITL: merge init() and run() 2015-10-21 09:16:08 +11:00
Caio Marcelo de Oliveira Filho c6292ff097 AP_HAL_SITL: implement HAL::run() 2015-10-21 09:16:07 +11:00
Caio Marcelo de Oliveira Filho 2e464a53c2 AP_HAL: make code not depend on concrete HAL implementations
The switching between different AP_HAL was happening by giving different
definitions of AP_HAL_BOARD_DRIVER, and the programs would use it to
instantiate.

A program or library code would have to explicitly include (and depend)
on the concrete implementation of the HAL, even when using it only via
interface.

The proposed change move this dependency to be link time. There is a
AP_HAL::get_HAL() function that is used by the client code. Each
implementation of HAL provides its own definition of this function,
returning the appropriate concrete instance.

Since this replaces the job of AP_HAL_BOARD_DRIVER, the definition was
removed.

The static variables for PX4 and VRBRAIN were named differently to avoid
shadowing the extern symbol 'hal'.
2015-10-21 09:16:07 +11:00
teddytrowbridge a4690a7b0a SITL_State: fixed _set_param_default
Fixed _set_param_default() so that it finds the parameter using it's
NAME rather than the entire NAME=VALUE string
2015-10-16 10:20:31 +11:00
Lucas De Marchi 7d9c75478f AP_HAL_SITL: remove unused write method 2015-09-29 11:53:51 +09:00
Lucas De Marchi 0ed7f94bfc AP_HAL_SITL: use method for downcast
Instead of just doing a static cast to the desired class, use a method
named "from". Pros:

  - When we have data shared on the parent class, the code is cleaner in
    child class when it needs to access this data. Almost all the data
    we use in AP_HAL benefits from this

  - There's a minimal type checking because now we are using a method
    that can only receive the type of the parent class
2015-09-23 09:01:29 +10:00
Michael Oborne b861233677 AP_HAL_SITL: add file based gps 2015-09-03 19:43:31 +10:00
Lucas De Marchi ffa37e6de2 AP_HAL_SITL: standardize inclusion of libaries headers
Do the missing header changes due to changing the code before the pr
getting accepted.
2015-08-18 17:12:52 +10:00
Fredrik Hedberg e2027a8414 SITL: Add HELI_DUAL_FRAME and HELI_COMPOUND_FRAME. 2015-08-13 18:23:30 +10:00
Gustavo Jose de Sousa 27b9d71e2c AP_HAL_SITL: standardize inclusion of libaries headers
This commit changes the way libraries headers are included in source files:

 - If the header is in the same directory the source belongs to, so the
 notation '#include ""' is used with the path relative to the directory
 containing the source.

 - If the header is outside the directory containing the source, then we use
 the notation '#include <>' with the path relative to libraries folder.

Some of the advantages of such approach:

 - Only one search path for libraries headers.

 - OSs like Windows may have a better lookup time.
2015-08-11 16:28:43 +10:00
Michael du Breuil c8c34f54cc AP_HAL_SITL: Add hdop to ublox sitl sim (as well as vdop to be reported) 2015-08-08 13:22:02 +09:00
Tom Pittenger d51e6d466b AP_HAL_SITL: add support for airspeed failures 2015-07-23 14:38:06 +10:00
Lucas De Marchi 473415a3c2 AP_HAL_SITL: use ARRAY_SIZE macro 2015-07-21 14:25:03 +09:00
John Hsu c34ddb7fb8 HAL_SITL: added gazebo SITL model support 2015-07-20 09:10:48 +10:00
Randy Mackay 2b4aaf2368 SITL: add vibe monitor and SIM_ACC2_RND to sitl 2015-07-12 16:50:30 +09:00
Julien BERAUD 7275e33e79 AP_HAL: add the possibility to have more than 1 i2c
Bebop drone has 3 i2c
2015-07-10 14:23:17 +10:00
Andrew Tridgell 88a90495b2 HAL_SITL: allow for more data before GPS pipe flush 2015-07-04 15:14:39 +10:00
tcr3dr 9d26bc6958 HAL_SITL: Adds polyfill for feenableexcept on OS X. 2015-07-01 11:32:01 +10:00
Andrew Tridgell 15efae5a48 HAL_SITL: use SITL_NUM_CHANNELS 2015-06-30 08:55:02 +10:00
Andrew Tridgell 92c9779d18 HAL_SITL: pass turbulence to simulators 2015-06-29 11:25:44 +10:00
Andrew Tridgell a81590f7ac HAL_SITL: prevent FPE on zero range with optflow 2015-06-25 10:08:53 +10:00
Andrew Tridgell 4677c189e0 HAL_SITL: support balloon model 2015-06-15 09:20:56 +10:00
Andrew Tridgell c44ab01be8 AP_HAL: use noreturn attribute on panic
should reduce coverity warnings
2015-06-08 21:09:08 +10:00
Andrew Tridgell d57eca9de8 HAL_SITL: enable simulated antenna tracker 2015-06-01 12:53:50 +10:00
Andrew Tridgell 249b339e6c HAL_SITL: fixed a build warning 2015-05-30 22:16:37 +10:00
Lucas De Marchi acdcdc35fa AP_HAL_SITL: Do not compare delegate to NULL
Use the simpler "if (delegate_name)" since it allows simpler
implementation in the class, i.e. the bool operator rather than having
to compare to another object.
2015-05-26 13:46:48 +10:00
Andrew Tridgell 3daee9c8bc HAL_SITL: added --autotest-dir option 2015-05-25 13:04:17 +10:00
Andrew Tridgell e7abc07898 HAL_SITL: enable --gimbal option
instantiates a MAVLink gimbal
2015-05-25 12:20:26 +10:00
Andrew Tridgell 8dce5e11d6 HAL_SITL: removed earth-frame rates 2015-05-25 09:03:10 +10:00
Andrew Tridgell e7f3716e8c HAL_SITL: pass in wind speed to C++ simulators 2015-05-23 11:04:13 +10:00
Andrew Tridgell 6cbd291dd2 HAL_SITL: make model name case insensitive 2015-05-22 16:07:44 +10:00
Andrew Tridgell 4e117bc90f HAL_SITL: support last_letter simulator 2015-05-22 16:07:44 +10:00
Andrew Tridgell cd66ce1c74 HAL_SITL: don't advance clock on garbage SIM input 2015-05-21 21:17:22 +10:00
Tom Pittenger 7b95241306 AP_HAL_SITL: float to double promotion via cos instead of cosf 2015-05-16 08:21:37 +10:00
Andrew Tridgell 3370ec62a1 HAL_SITL: fix for multi-compass SITL 2015-05-15 14:25:44 +10:00
Andrew Tridgell 2a47cc3c81 HAL_SITL: cleanup command line handling 2015-05-11 08:48:42 +10:00
Andrew Tridgell 5687adbdba HAL_SITL: support JSBSim backend 2015-05-10 21:02:20 +10:00
Andrew Tridgell 8ec98a5ec9 SITL: make it possible to connect two SITL instances together
this adds --client to set uartC as a tcp client rather than a TCP
server
2015-05-10 15:36:18 +10:00
Tom Pittenger 1c8efb25a8 AP_HAL_SITL: replace fabs() with fabsf() 2015-05-09 09:57:26 +10:00
Andrew Tridgell 6a8da06d19 HAL_SITL: hook in CRRCSim backend 2015-05-05 21:42:46 +10:00
Andrew Tridgell c81ad1d622 HAL_SITL: reformat HAL_SITL with astyle 2015-05-05 10:59:07 +10:00
Andrew Tridgell d8791134f9 HAL_SITL: need to use fabs() for double checking 2015-05-05 09:45:59 +10:00
Andrew Tridgell b9abf30785 HAL_SITL: removed unused cygwin code 2015-05-05 09:45:58 +10:00
Andrew Tridgell 5158f91263 HAL_SITL: converted command line code to getopt_cpp 2015-05-05 09:45:58 +10:00
Andrew Tridgell b2b5c8cd18 HAL_SITL: fixed some build warnings 2015-05-05 09:45:58 +10:00
Andrew Tridgell 40e3b422b5 HAL_SITL: rename HAL_AVR_SITL to HAL_SITL
it is nothing to do with the original AVR emulation now
2015-05-05 09:45:54 +10:00