Commit Graph

143 Commits

Author SHA1 Message Date
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
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
Gustavo Jose de Sousa f32c4ceda9 AP_OpticalFlow: 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:38:21 +10:00
Randy Mackay 4aef64c153 OpticalFlow_Linux: reworked driver
remove PANICs from init
return semaphore if init fails
add successful initialisation check before attempting to read from sensor
structure made private where possible
formatting fixes
check I2C reads succeed
add request_measurement to request sensor to produce measurement
quit after 20 of previous 40 reads fail
throttle reads to 10hz max
2015-08-07 15:51:11 +09:00
Víctor Mayoral Vilches ed3366aaae AP_OpticalFlow: Add support for Linux
Add a Linux userspace driver for the PX4FLOW sensor.
2015-08-07 15:50:41 +09:00
Randy Mackay 03356a8d3a OptFlow: fix parameter descriptions 2015-07-06 11:37:38 +09:00
Randy Mackay 7bbaeac55f OpticalFlow: init _last_update_ms member
This resolves a defect found with coverity
2015-06-08 14:46:11 +09:00
Andrew Tridgell 637f8430c9 AP_OpticalFlow: convert example from .pde to .cpp 2015-06-01 17:07:06 +10:00
Andrew Tridgell 4ee54a8915 AP_OpticalFlow: fix for HAL_SITL rename 2015-05-05 09:45:56 +10:00
Paul Riseborough 53358a4e10 AP_OpticalFlow: Add parameter to compensate for flow sensor yaw angle
AP_OpticalFlow: update parameter name
2015-04-10 11:07:31 +09:00
Randy Mackay 385558db4d OptFlow: fix example sketch 2015-03-13 16:41:01 +09:00
Andrew Tridgell 995311f807 AP_OpticalFlow: change for new PX4 device paths 2015-02-14 12:25:44 +11:00
Randy Mackay f48a71f30a OptFlow: fix example sketch 2015-01-28 17:15:47 +09:00
Andrew Tridgell 19c717df2e AP_OpticalFlow: updates for new AP_Baro API 2015-01-09 11:50:56 +11:00
Andrew Tridgell aff01c6d09 AP_OpticalFlow: fixed reversed timestamp
thanks to Randy
2015-01-03 14:16:34 +11:00
Andrew Tridgell 11ff12dfd3 AP_OpticalFlow: split library into frontend/backend
this will make it easier to add a SITL backend
2015-01-03 14:16:33 +11:00
Andrew Tridgell f8bce994b5 AP_OpticalFlow: don't write an error message if no flow sensor
most users have no flow sensor
2015-01-01 11:02:43 +11:00
Randy Mackay 3c23f00e81 OptFlow: remove ADNS3080 image grabber example 2014-12-08 14:58:24 +09:00
Andrew Tridgell 22a7b69260 AP_OpticalFlow: don't build optical flow example
broken by library changes
2014-12-06 22:05:42 +11:00
Andrew Tridgell ed510d4f87 AP_OpticalFlow: run PX4 flow sensor at 10Hz
Pair-Programmed-With: Paul Riseborough <p_riseborough@live.com.au>
2014-12-06 18:16:51 +11:00