Commit Graph

262 Commits

Author SHA1 Message Date
Patrick José Pereira 653784479e AP_OpticalFlow: Use SITL singleton
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
2018-06-26 00:02:01 +01:00
Lucas De Marchi daa8819619 AP_OpticalFlow: use ins singleton 2018-03-16 00:37:35 -07:00
Peter Barker 82a68a82e6 AP_OpticalFlow: use baro singleton 2018-03-08 21:20:05 -08:00
Peter Barker 9b23b469cf AP_OpticalFlow: correct compiler warning
In file included from
../../libraries/AP_OpticalFlow/AP_OpticalFlow_Pixart.cpp:28:
../../libraries/AP_OpticalFlow/AP_OpticalFlow_Pixart.h:75:13: warning:
private field 'sum_x' is not used [-Wunused-private-field]
    int32_t sum_x;
            ^
../../libraries/AP_OpticalFlow/AP_OpticalFlow_Pixart.h:76:13: warning:
private field 'sum_y' is not used [-Wunused-private-field]
    int32_t sum_y;
            ^
../../libraries/AP_OpticalFlow/AP_OpticalFlow_Pixart.h:77:14: warning:
private field 'last_print_ms' is not used [-Wunused-private-field]
    uint32_t last_print_ms;
             ^
4 warnings generated.
2018-03-02 09:26:37 +09:00
Andrew Tridgell ead72214ac AP_OpticalFlow: support SP01 board 2018-02-14 18:27:00 +11:00
Andrew Tridgell 429a2beb86 AP_OpticalFlow: enable pixart flow on PCNC1 boards 2018-02-08 17:36:33 +11:00
Andrew Tridgell 570a05e9d3 AP_OpticalFlow: fixed pixart SPI name 2018-02-08 17:36:33 +11:00
Andrew Tridgell 7c8cf0a39e AP_OpticalFlow: fixed SPI name for pixart flow sensor 2018-02-08 17:36:33 +11:00
Andrew Tridgell 85f4958e4e AP_OpticalFlow: use AP_FEATURE_BOARD_DETECT 2018-01-15 11:46:02 +11:00
Andrew Tridgell ddf8523c2b AP_OpticalFlow: prevent crash on bad device name 2018-01-15 11:46:02 +11:00
Andrew Tridgell 3cd5386a7e AP_OpticalFlow: support ChibiOS 2018-01-15 11:46:02 +11:00
Peter Barker 7646e09349 AP_OpticalFlow: AP_AHRS no longer requires GPS in constructor 2017-12-27 00:58:02 +00:00
Andrew Tridgell 0d4dca0394 AP_OpticalFlow: removed create() method for objects
See discussion here:

  https://github.com/ArduPilot/ardupilot/issues/7331

we were getting some uninitialised variables. While it only showed up in
AP_SbusOut, it means we can't be sure it won't happen on other objects,
so safest to remove the approach

Thanks to assistance from Lucas, Peter and Francisco
2017-12-14 08:12:28 +11:00
Lucas De Marchi beabae6a98 global: use static method to construct AP_AHRS_NavEKF 2017-09-26 03:01:21 +01:00
Lucas De Marchi c9fbf7b722 global: use static method to construct AP_NavEKF3 2017-09-26 03:01:21 +01:00
Lucas De Marchi e2fe36357a global: use static method to construct AP_NavEKF2 2017-09-26 03:01:21 +01:00
Lucas De Marchi 72fd2d6f05 global: use static method to construct AP_SerialManager 2017-09-26 03:01:21 +01:00
Lucas De Marchi fbe0d9761c global: use static method to construct AP_OpticalFlow 2017-09-26 03:01:21 +01:00
Lucas De Marchi 04c3dca3ce AP_OpticalFlow: add static create method 2017-09-26 03:01:21 +01:00
Lucas De Marchi 40fd1b346c global: remove rangefinder from AP_AHRS_NavEKF
AP_AHRS_NavEKF doesn't use the rangefinder, it just delegates the
calls to the right estimator.

For libraries/AP_AHRS/examples/AHRS_Test/AHRS_Test.cpp the initialization
order has also been modified to match the order on vehicles. It's more
correct since it passes a reference when EKF2/EKF3 are already
constructed, while thos constructors use a pointer.  Ideally these
should be moved to an init() method though, or use a get_instance().
2017-09-26 03:01:21 +01:00
Lucas De Marchi 9027a55696 global: use static method to construct RangeFinder 2017-09-26 03:01:21 +01:00
Lucas De Marchi 8094482f21 global: use static method to construct AP_GPS 2017-09-26 03:01:21 +01:00
Lucas De Marchi 87b30b4552 global: use static method to construct AP_InertialSensor 2017-09-26 03:01:21 +01:00
Lucas De Marchi c1a957fbf3 global: use static method to construct Compass 2017-09-26 03:01:21 +01:00
Lucas De Marchi 91feec0e14 global: use static method to construct AP_Baro 2017-09-26 03:01:21 +01:00
Randy Mackay 59ffc3cd65 AP_OpticalFlow: minor order declaration change
non-functional change
2017-08-23 11:19:14 +09:00
Randy Mackay cf24eef359 AP_OpticalFlow: init checks if enabled 2017-08-23 11:19:14 +09:00
Randy Mackay bc38affcb1 AP_OpticalFlow: px4flow retries init 10 times at startup
This resolves an issue in which some px4flow sensors are slow to startup
2017-08-23 11:19:14 +09:00
Randy Mackay fdb4c7b5ee AP_OpticalFlow: failure to init leaves enabled unchanged 2017-08-23 11:19:14 +09:00
Randy Mackay a7afffe14a AP_OpticalFlow: rename BUS_ID parameter to ADDR
This makes the parameter more consistent with RangeFinder
2017-08-23 11:19:14 +09:00
Andrew Tridgell 97e88501c6 AP_OpticalFlow: support pixart 3901 2017-06-16 17:14:10 +01:00
Pierre Kancir 45ca91808d AP_OpticalFlow: example fix travis warning
missing function declaration
implicit cast
some style fix
2017-04-13 19:56:16 +01:00
Jacob Walser a9a8521383 AP_OpticalFlow: Fix parameter metadata 2017-03-22 16:16:26 -07:00
mirkix ac60ddfdde AP_OpticalFlow: allow to search on I2C bus 2 2017-03-07 22:48:48 -08:00
mirkix ad208cab56 AP_OpticalFlow: BBBmini remove onboard OpticalFlow 2017-03-07 22:48:48 -08:00
Randy Mackay e725ae866b AP_OpticalFlow: fix example sketch 2017-02-27 15:18:13 +09:00
murata d9dbf6e1eb AP_OpticalFlow: Change from magic number 0 to definition name. 2017-02-18 14:12:36 +00:00
murata 77c402556b AP_OpticalFlow: Unify from print or println to printf. 2017-01-27 18:20:22 +11:00
Julien Beraud 677a2f600f AP_OpticalFlow_Onboard: remove gyro_cb
Not needed anymore
2017-01-23 21:23:16 +11:00
Julien Beraud 305239b467 AP_OpticalFlow_Onboard: fix scale in gyro calculation
Scale was wrong due to incorrect gyro integration
2017-01-23 21:23:16 +11:00
Lucas De Marchi 5472bc4de1 Global: change Device::PeriodicCb signature
Remove bool return as it's never being used and not supported on PX4.
2017-01-14 10:03:54 +11:00
Peter Barker 889ec829fc AP_OpticalFlow: fix warning in SITL compilation 2017-01-02 15:58:32 +09:00
Andrew Tridgell 75688c8342 AP_OpticalFlow: Add EKF3 and remove EKF1 2016-12-19 08:07:09 +11:00
Andrew Tridgell bdc41446ae AP_OpticalFlow: fixed build 2016-12-05 16:51:49 -08:00
Randy Mackay a517db4b5e AP_OpticalFlow: resolve compiler warning 2016-11-30 18:00:15 +09:00
Andrew Tridgell 22717f23be AP_OpticalFlow: apply yaw for flow in all drivers 2016-11-28 08:26:57 +11:00
Andrew Tridgell 06dfbc3e09 AP_OpticalFlow: added common driver for PX4Flow
used on Linux and NuttX boards
2016-11-28 08:26:57 +11:00
Andrew Tridgell 52715c5d16 AP_OpticalFlow: fixed default pixart flow scaling 2016-11-28 08:26:57 +11:00
Andrew Tridgell 9b93e12bbb AP_OpticalFlow: retry config register write up to 5 times 2016-11-28 08:26:57 +11:00
Andrew Tridgell ea462d80e6 AP_OpticalFlow: added _applyYaw method to backend
for common handling of yaw correction
2016-11-28 08:26:57 +11:00
Andrew Tridgell abc42c737c AP_OpticalFlow: added update function for Pixart flow driver 2016-11-28 08:26:57 +11:00
Andrew Tridgell 0be1b1aac2 AP_OpticalFlow: give access to AHRS from all backends 2016-11-28 08:26:56 +11:00
Andrew Tridgell 2e2f8ad8cf AP_OpticalFlow: added SITL flow driver as normal driver
move away from HAL_SITL embedded drivers
2016-11-28 08:26:56 +11:00
Andrew Tridgell 0889b25afa AP_OpticalFlow: initial code for Pixart optical flow chip 2016-11-28 08:26:56 +11:00
Julien Beraud d50fd3a6cd AP_OpticalFlow: fix onboard init
mistake in patch to avoid segfault which enabled
AP_OpticalFlow_Linux instead of AP_OpticalFlow_Onboard.
Store a reference to ahrs in order to execute init later, when
ahrs is initialized.
2016-11-21 16:38:59 -02:00
Julien Beraud dc86a53862 OpticalFlow: move onboard alloc to init()
No reason to keep it in the constructor
2016-11-16 20:38:00 +11:00
Andrew Tridgell 76b2759317 AP_OpticalFlow: fixed shadowed variable build warning 2016-11-09 17:08:06 +11:00
Andrew Tridgell 6e2fbf1988 AP_OpticalFlow: fixed threading in opticalflow for linux 2016-11-09 17:08:02 +11:00
murata c808ee2f49 Global: To nullptr from NULL.
RC_Channel: To nullptr from NULL.

AC_Fence: To nullptr from NULL.

AC_Avoidance: To nullptr from NULL.

AC_PrecLand: To nullptr from NULL.

DataFlash: To nullptr from NULL.

SITL: To nullptr from NULL.

GCS_MAVLink: To nullptr from NULL.

DataFlash: To nullptr from NULL.

AP_Compass: To nullptr from NULL.

Global: To nullptr from NULL.

Global: To nullptr from NULL.
2016-11-02 16:04:47 -02:00
Andrew Tridgell 047a09c391 AP_OpticalFlow: use const reference
saves stack space and cpu
2016-10-27 14:58:59 +11:00
priseborough 1bde180f98 AP_OpticalFlow: Update parameter documentation
Add brief description of body frame conventions.
2016-10-27 14:54:45 +11:00
priseborough 9c7ab639a1 AP_OpticalFlow: Add parameters for flow sensor position offset 2016-10-27 14:54:41 +11:00
Mathieu OTHACEHE 152edf7189 Global: remove mode line from headers
Using a global .dir-locals.el file is a better alternative than
reincluding the same emacs header in every file of the project.
2016-10-24 09:42:01 -02:00
Lucas De Marchi ae53920e5b build: don't build examples with old build system
We currently check examples are buildable with waf which doesn't need
the libraries to be specified in a make.inc file.  Having the makefiles
there is misleading since people try to build and realize the build is
broken.
2016-10-11 13:03:08 +11:00
murata 13fe8cb4d0 AP_OpticalFlow: Changed short boundary the i2c_integral_frame. 2016-09-17 01:04:06 -03:00
murata 59796aaf9c AP_OpticalFlow: The first value of the register to the value of the definition. 2016-08-31 01:01:59 -03:00
LukeMike 316e5acaec AP_OpticalFlow_PX4: enabled sensor driver startup for all VR boards 2016-08-11 07:52:39 +10:00
Andrew Tridgell 78b2924c00 AP_OpticalFlow: auto-start px4flow driver if enabled 2016-08-10 19:54:01 +10:00
LukeMike 9f8b66758c VRBRAIN / AP_OpticalFlow: enabled OpticalFlow_PX4 for all VirtualRobotix boards 2016-08-07 20:31:51 +10:00
Lucas De Marchi 388a6683ad AP_OpticalFlow: fix optical flow initialization
This fixes the initialization for Linux boards using the PX4Flow module.
The problem is that after the conversion to use I2CDevice we now need to
use I2CDeviceManager, which is statically constructed after the vehicle
object.

So, if we try to call hal.i2c_mgr->get_device(), it will call the
get_device() method before the constructor is called and receive a
SIGSEGV:

Program received signal SIGSEGV, Segmentation fault.
0x000b06c0 in OpticalFlow::OpticalFlow (this=0x140914 <copter+4980>, ahrs=...)
    at ../../libraries/AP_OpticalFlow/OpticalFlow.cpp:54
54      ../../libraries/AP_OpticalFlow/OpticalFlow.cpp: No such file or directory.
2016-05-13 11:22:12 -03:00
Lucas De Marchi 6839ee4f37 AP_OpticalFlow: remove trailing whitespaces 2016-04-29 12:10:52 -03:00
Lucas De Marchi 5a52533084 AP_OpticalFlow: move bus definition to AP_HAL header 2016-04-29 12:10:21 -03:00
Ricardo de Almeida Gonzaga 46fb57fcf1 AP_OpticalFlow: use I2CDevice interface 2016-04-29 12:01:04 -03:00
Lucas De Marchi 47be4b5868 AP_OpticalFlow: fix use of undefined variable
../../libraries/AP_OpticalFlow/AP_OpticalFlow_Onboard.cpp:86:5: warning: "FLOWONBOARD_DEBUG" is not defined [-Wundef]
 #if FLOWONBOARD_DEBUG
     ^
2016-03-03 18:37:15 -03:00
Lucas De Marchi 008e3c9810 AP_OpticalFlow: replace header guard with pragma once 2016-02-18 14:52:35 -02:00
mirkix d1babdb0fb AP_OpticalFlow: Enable optical flow onboard for BBBMINI 2016-02-08 08:52:10 -02:00
Gustavo Jose de Sousa c2e3f05dbf waf: ardupilotwaf: prefix build context methods with ap_
It helps to distinguish between things from waf and things from ardupilotwaf.
2016-01-22 20:10:29 -02:00
Gustavo Jose de Sousa 3d22490397 waf: examples: use methods from bld instead of ardupilotwaf 2016-01-22 20:10:29 -02:00
Gustavo Jose de Sousa d281067bcc waf: make example binaries be placed in 'examples' dir
This commit makes examples' wscripts use ardupilotwaf.example() instead of
ardupilot.program().
2016-01-15 16:46:41 -02:00
Ricardo de Almeida Gonzaga 7adbccac9a AP_HAL_Linux: add support for OpticalFlow to MinnowBoardMax
This commit adds support for OpticalFlow to MinnowBoardMax trying to
leave the OpticalFlow implementation as generic as it already is.

We had to add some format conversion and software crop to the cameras that
do not have this features.
2016-01-11 15:31:27 -02:00
Jonathan Challinger b0de3957ea AP_OpticalFlow: fix example build 2015-12-29 10:46:35 -08:00
Lucas De Marchi a096703b06 Global: don't link with AP_Progmem
AP_Progmem is not used anymore.
2015-12-27 15:58:12 -02:00
Julien BERAUD a32738fd5f AP_OpticalFlow: Update test declaration
Declare a dummy vehicle to get a dummy ahrs. No problem since this code
is not used apart from compilation. Needed to declare an optical flow.
2015-12-18 17:56:06 +11:00
Lucas De Marchi 8b21dc9b22 AP_OpticalFlow: follow coding style
- use pragma once
 - sort headers
 - add missing header - always include what you are using in the header
2015-12-18 17:56:05 +11:00
Julien BERAUD c5cca02bc8 AP_OpticalFlow: Add support for onboard optflow
Onboard Optical flow needs to have access to the ahrs to get
correct gyro values.
Therefore the constructor takes the ahrs as a param like it is done
for other classes that need to have access to these datas
2015-12-18 17:56:05 +11:00
Lucas De Marchi 1ba22398a5 AP_OpticalFlow: remove unused AP_ADC_AnalogSource 2015-12-03 13:32:44 +11:00
Caio Marcelo de Oliveira Filho 6e7b73610d waf: add waf support 2015-12-03 07:54:30 +11:00
Caio Marcelo de Oliveira Filho 5b06924779 AP_OpticalFlow: use millis/micros/panic functions 2015-11-20 12:33:19 +09:00
Andrew Tridgell 8f4ce7f20b build: removed all nocore.inoflag files
these were APM2 specific
2015-11-16 08:05:17 +11:00
Lucas De Marchi 0d95a9c41d AP_OpticalFlow: reduce lock region
Release the lock as soon as we can.
2015-11-05 16:12:03 +09:00
Lucas De Marchi 70edf31ca6 AP_OpticalFlow: make error path common 2015-11-05 16:12:00 +09:00
Lucas De Marchi 7b726d824d AP_OpticalFlow: remove num_errors increment due to busy bus
num_errors should be used to detect bad bus transfers, not if we
actually read something. Since we are using i2c_sem->take_nonblocking()
failing here is more likely if the bus is shared.
2015-11-05 16:11:58 +09:00
Lucas De Marchi 41ddb67712 AP_OpticalFlow: pack struct passed to I2C layer
We pass "sizeof(i2c_integral_frame)" to hal.i2c->readRegisters(). Since
we have a padding in i2c_integral_frame we actually read 3 bytes more
than we should. Add PACKED to the struct so this is fixed.

i2c_frame doesn't have a padding (or hole) so there isn't this problem,
but since it's also used to calculate the frame size, use PACKED there
too.
2015-11-05 16:11:56 +09:00
Lucas De Marchi 5244559010 Minimize AP_Progmem.h includes
Most of AP_Progmem is already gone so we can stop including it in most
of the places. The only places that need it are the ones using
pgm_read_*() APIs.

In some cases the header needed to be added in the .cpp since it was
removed from the .h to reduce scope. In those cases the headers were
also reordered.
2015-10-30 14:35:32 +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 831d8acca5 Remove use of PROGMEM
Now variables don't have to be declared with PROGMEM anymore, so remove
them. This was automated with:

    git grep -l -z PROGMEM | xargs -0 sed -i 's/ PROGMEM / /g'
    git grep -l -z PROGMEM | xargs -0 sed -i 's/PROGMEM//g'

The 2 commands were done so we don't leave behind spurious spaces.

AVR-specific places were not changed.
2015-10-30 14:35:16 +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
Caio Marcelo de Oliveira Filho de98ec7c1a AP_OpticalFlow: fix build of example for PX4 2015-10-21 09:16:12 +11:00
Caio Marcelo de Oliveira Filho ae9bc62e84 AP_OpticalFlow: remove unnecessary includes from example 2015-10-21 09:16:12 +11:00
Caio Marcelo de Oliveira Filho ec52df991c build: compile only the HAL files needed by the board
Instead of requiring every program to specify the HAL related modules,
let the build system do it (in practice everything we compiled depended
on HAL anyway). This allow including only the necessary files in the
compilation.
2015-10-21 09:16:07 +11:00