Commit Graph

285 Commits

Author SHA1 Message Date
skyscraper
c0c8f1a5cc RC_Channel: RC_Channel refactor
Fix up RC_Channel examples.

Change direct access to data members
to access via member functions
2016-05-10 16:21:17 +10:00
skyscraper
d16659331f RC_Channel_aux: Rename static member functions
Further to refactor of RC_Channel class which included
adding get_xx set_xx methods, some methods names are now
in conflict with those in the derived RC_Channel_aux class.
To keep a uniform naming convention in RC_Channel where
functions are most used and most numerous, the offending
functions in RC_Channel__aux are renamed as follows

 RC_Channel_aux::set_radio_trim(Aux_servo_function_t function)
    to RC_Channel_aux::set_trim_to_radio_in_for(Aux_servo_function_t function)

 RC_Channel_aux::set_servo_out(Aux_servo_function_t function, int16_t value)
    to RC_Channel_aux::set_servo_out_for(Aux_servo_function_t function, int16_t value)

 Rationale:

        RC_Channel is a complicated class, which combines
        several functionalities dealing with stick inputs
        in pwm and logical units, logical and actual actuator
        outputs, unit conversion etc, etc
        The intent of this PR is to clarify existing use of
        the class. At the basic level it should now be possible
        to grep all places where private variable is set by
        searching for the set_xx function.

        (The wider purpose is to provide a more generic and
        logically simpler method of output mixing. This is a small step)
2016-05-10 16:21:15 +10:00
skyscraper
d9ab3baf84 RC_Channel: Refactor to make data members private
rename all public data members of RC_Channnels with
leading underscore and make all data members private.
Provide get_xx and set_xx methods for access

 Rationale:

        RC_Channel is a complicated class, which combines
        several functionalities dealing with stick inputs
        in pwm and logical units, logical and actual actuator
        outputs, unit conversion etc, etc
        The intent of this PR is to clarify existing use of
        the class. At the basic level it should now be possible
        to grep all places where private variable is set by
        searching for the set_xx function.

        (The wider purpose is to provide a more generic and
        logically simpler method of output mixing. This is a small step)

add function to save radio trim
(expression where c is an object of type RC_Channel)
old public member(int16_t)   get function -> int16_t     set function (int16_t)

(expression where c is an object of type RC_Channel)

c.radio_in                     c.get_radio_in()           c.set_radio_in(v)
c.control_in                   c.get_control_in()         c.set_control_in(v)
c.servo_out                    c.get_servo_out()          c.set_servo_out(v)
c.pwm_out                      c.get_pwm_out()            // use existing
c.radio_out                    c.get_radio_out()          c.set_radio_out(v)
c.radio_max                    c.get_radio_max()          c.set_radio_max(v)
c.radio_min                    c.get_radio_min()          c.set_radio_min(v)
c.radio_trim                   c.get_radio_trim()         c.set_radio_trim(v);
// other
c.min_max_configured() // return true if min and max are configured
c.save_radio_trim()    // save radio trim to eeprom
2016-05-10 16:21:15 +10:00
Andrew Tridgell
50908edc91 RC_Channel: added parameter docs for missing RCn_FUNCTION values 2016-05-09 17:33:21 +10:00
Andrew Tridgell
ab0b76764f RC_Channel: added set_servo_failsafe_pwm() 2016-05-07 07:25:27 +10:00
skyscraper
134ea338da RC_Channel: remove unused control_mix method 2016-05-05 18:58:17 -03:00
Andrew Tridgell
54f7aeed83 RC_Channel: extend channel mapping to 16 channels
this gives more flexibility, no reason to limit it to 8
2016-04-23 21:03:46 +10:00
Andrew Tridgell
ed2f26d7b8 RC_Channel: allow for pass-thru from low channels to any channel
this makes it easier to setup things like ignition cut or bottle drop
with a 8 channel radio
2016-04-10 20:33:12 +10:00
Ricardo de Almeida Gonzaga
5bd034a5a8 Global: start using cmath instead of math.h 2016-04-05 21:06:19 -07:00
Andrew Tridgell
1ecfa6b487 RC_Channel: fixed example in SITL 2016-03-25 21:35:33 +11:00
Andrew Tridgell
4deb01b8d5 RC_Channel: set AP_PARAM_NO_SHIFT 2016-03-18 12:33:34 +11:00
Lucas De Marchi
08cc7b2472 RC_Channel: replace header guard with pragma once 2016-03-16 18:40:44 +11: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
Andrew Tridgell
a07a8aece1 RC_Channel: added pwm_to_angle_dz_trim() 2016-01-06 22:47:21 +11:00
Andrew Tridgell
9941c91d36 RC_Channel: prevent a warning message for assigned RC channels 2016-01-06 19:16:12 +11:00
Andrew Tridgell
b6155d2cb6 RC_Channel: fixed output for k_motor* 2016-01-05 06:41:51 +11:00
Andrew Tridgell
238e912000 RC_Channel: allow find_channel() to be called early
and fix a bug!
2016-01-05 06:40:48 +11:00
Andrew Tridgell
9123ef9f38 RC_Channel: added find_channel() and channel numbers 2016-01-04 17:06:57 +11:00
Andrew Tridgell
6a58264c6b RC_Channel: added set_aux_channel_default() API
this will allow for a default channel for aux functions. Also adds
heli_rsc and heli_tail_rsc functions
2016-01-04 16:14:09 +11:00
Andrew Tridgell
7cc53b6449 RC_Channel: setup only in or out part of channels for aux channels
this allows separate use of input and output
2016-01-04 11:23:36 +09:00
Andrew Tridgell
48b774bc63 RC_Channel: allow more complete separation of input and output of channels
this allows for the type and range of channels to be different on
input and output
2016-01-04 11:23:30 +09:00
Jonathan Challinger
027e622a3c RC_Channel: 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
Andrew Tridgell
e1c890eb58 RC_Channel: added RC_UART example
useful for UART -> ESCs
2015-12-27 16:12:27 +11:00
Lucas De Marchi
e8e48fd8e0 RC_Channel: 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
Lucas De Marchi
2591261af6 Global: rename min and max macros to uppercase
The problem with using min() and max() is that they conflict with some
C++ headers. Name the macros in uppercase instead. We may go case by
case later converting them to be typesafe.

Changes generated with:

	git ls-files '*.cpp' '*.h' -z | xargs -0 sed -i 's/\([^_[:alnum:]]\)max(/\1MAX(/g'
	git ls-files '*.cpp' '*.h' -z | xargs -0 sed -i 's/\([^_[:alnum:]]\)min(/\1MIN(/g'
2015-12-01 16:28:09 -02:00
Andrew Tridgell
52f2fce1d5 RC_Channel: prevent float exception with bad RCn_MIN/MAX/TRIM
thanks to Michael for finding this
2015-11-30 21:53:54 +11:00
Andrew Tridgell
8f4ce7f20b build: removed all nocore.inoflag files
these were APM2 specific
2015-11-16 08:05:17 +11:00
Robert Lefebvre
58e918341d RC_Channel: Add motor_run_enable aux function 2015-11-12 19:37:27 +09:00
Andrew Tridgell
ea5cd99651 RC_Channel: use is_bounded_int32() 2015-11-11 13:45:09 +11:00
Grant Morphett
7edf8c0e0a RC_Channel: New method to detect if channel is in trim location
This is a new method which will return true if an RC_Channel has a PWM
value that is at its TRIM value plus or minus the allowed dead zone
around the TRIM.
2015-11-11 13:39:38 +11:00
Lucas De Marchi
2a91d2169e RC_Channel: remove check for AVR CPUs
Remove the checks for HAL_CPU_CLASS > HAL_CPU_CLASS_16 and
HAL_CPU_CLASS >= HAL_CPU_CLASS_75. Corresponding dead code will be
removed on separate commits.
2015-11-04 12:14:14 +11:00
Lucas De Marchi
2847af905e RC_Channel: remove checks for HAL_BOARD_APM2 and HAL_BOARD_APM1 2015-11-04 12:14:13 +11: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
Jonathan Challinger
21e7d46944 RC_Channel: use set_default for runtime param defaults 2015-10-26 11:15:54 +11:00
Caio Marcelo de Oliveira Filho
e36728d1db RC_Channel: make example compile again
By adding a missing library dependency. Also remove unnecessary
includes, in particular including each board HAL file is not needed
anymore.
2015-10-21 09:16:09 +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
Grant Morphett
122e88dbed RC_Channel: remove the unused test function get_failsafe 2015-09-09 10:28:02 +10:00
Andrew Tridgell
1162503199 RC_Channel: fixed example build 2015-08-11 17:00:13 +10:00
Gustavo Jose de Sousa
d2780623f7 RC_Channel: 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:25 +10:00
Andrew Tridgell
c86ff1ac25 RC_Channel: prevent floating exception on bad MIN/MAX/TRIM values 2015-07-27 12:04:03 +10:00
Randy Mackay
03a336d496 RC_Channel: update_aux_servo_function made public 2015-06-10 16:47:06 +09:00
Andrew Tridgell
e234844905 RC_Channel: fixed example sketch 2015-06-01 18:05:50 +10:00
Andrew Tridgell
6c1c2dd8bd RC_Channel: convert example from .pde to .cpp 2015-06-01 17:07:08 +10:00
Randy Mackay
b121d83beb RC_Channel: add EPM, LandingGear to FUNCTION param description 2015-05-27 18:05:01 +09:00
Randy Mackay
1b13250fd8 RC_Channel: small parameter description change 2015-05-14 10:33:08 +09:00
Andrew Tridgell
fa688a7b14 RC_Channel: fix for HAL_SITL rename 2015-05-05 09:45:57 +10:00
Randy Mackay
5b15c07d47 RC_Channel: fix example sketch 2015-05-01 21:02:57 +09:00
Andrew Tridgell
6959cdbf15 RC_Channel: fixed usage of _reverse to be consistent
users could set RCn_REV to 0 and get very confusing results
2015-02-18 12:47:56 +11:00
Robert Lefebvre
4935a42054 RC_Channel_Aux: Add new landing gear control to Aux_servo_function_t enum.
Conflicts:
	libraries/RC_Channel/RC_Channel_aux.h
2015-01-07 11:58:17 +09:00
Andrew Tridgell
86bf02d64c RC_Channel: update example sketch to copy input to output 2014-12-02 16:27:33 +11:00
Kirill A. Kornilov
33e4f44434 RC_Channel: added set_radio_trimmed()
take into account trim value in set_radio()
2014-11-25 08:19:27 +11:00
Randy Mackay
73f3b50e2f RC_Channel: make get_control_mid const 2014-11-17 18:16:12 -08:00
Jonathan Challinger
9375fc8947 RC_Channel: add get_control_mid function 2014-11-17 18:16:09 -08:00
Jonathan Challinger
4d7988b302 RC_Channel: replace long with int32_t 2014-11-17 18:16:08 -08:00
Andrew Tridgell
6b0c15b70f RC_Channel: added norm_input_dz()
normalised input, taking into account dead zone
2014-11-18 12:44:05 +11:00
Andrew Tridgell
2270a904ce RC_Channel: make flaperson range from -4500 to 4500 2014-11-14 11:23:52 +11:00
Andrew Tridgell
16fd113020 RC_Channel: added channel_function()
this is used in the plane mixing code
2014-11-07 10:39:07 +11:00
Randy Mackay
79f95efb71 RC_Channel_aux: add epm to servo function enum 2014-09-17 21:13:30 +09:00
Andrew Tridgell
e1a13edf3d RC_Channel: fixed example build 2014-08-13 22:12:30 +10:00
Andrew Tridgell
2e5913df93 RC_Channel: fixed k_manual for set_servo_limit()
this allows for failsafe takeover of k_manual channels, which fixes
the behaviour for ignition failsafe
2014-08-09 22:50:14 +10:00
Andrew Tridgell
0d4985079e RC_Channel: added support for LimitValue settings
this allows you to set a channel failsafe or radio_out to a limit
value
2014-04-21 11:52:41 +10:00
Andrew Tridgell
7f4178d967 RC_Channel: added setup_failsafe_trim_all() function
sets all channels to output trim values on FMU failure
2014-04-21 08:37:24 +10:00
Randy Mackay
8600b9d4f1 RC_Channel: add parachute_release to function enum 2014-04-07 13:36:33 +09:00
Andrew Tridgell
11f196318e RC_Channel: added static functions to simplify operations on all channels
this avoids vehicle code having to loop over all channels for common
operations
2014-04-03 12:18:56 +11:00
Andrew Tridgell
8c0c9c317e RC_Channel: prevent a numerical exception with bad mount parameters 2014-03-26 17:38:27 +11:00
Andrew Tridgell
6039eab442 RC_Channel: support up to 12 aux channels on PX4
this allows RC13 and RC14 to work correctly as aux outputs on Pixhawk
2014-03-25 15:42:48 +11:00
Andrew Tridgell
68462025ba RC_Channel: constrain norm_input() to -1 to 1
if RC is not properly calibrated we could get a value beyond 1, which
could cause some flight modes to exceed the roll/pitch limits of the
aircraft
2014-03-15 20:43:13 +11:00
Andrew Tridgell
dd502e98b4 RC_Channel: added support for separate wheel steering channels on planes 2014-03-05 12:57:50 +11:00
Andrew Tridgell
a788405c8b RC_Channel: added percent_input() function
useful for plane flaps
2014-03-05 09:17:50 +11:00
Mike McCauley
be34e0358a RC_Channel: Removed duplicate defines from RC_Channel.h 2014-03-03 06:34:34 +11:00
Andrew Tridgell
e11ada7bf0 RC_Channel: fixed comment on enable_aux_servos()
thanks to Mike McCauley for spotting
2014-02-18 09:25:07 +11:00
Andrew Tridgell
00d2d5946c RC_Channel: added disable_aux_channel()
this will be used by copter to ensure motor channels are not enabled
for aux functions
2014-02-06 21:30:55 +11:00
Andrew Tridgell
b4208c7fc0 RC_Channel: added flaperon1 and flaperon2 function outputs 2014-02-06 12:35:32 +11:00
Andrew Tridgell
698736b66d RC_Channel: simplify the setup of aux channels
avoid the nasty mess of #if lines, as the info is in the constructor
anyway
2014-02-06 10:17:16 +11:00
Andrew Tridgell
f6d888e0da RC_Channel: added disable_out() method 2013-12-20 11:58:53 +11:00
Andrew Tridgell
e245bb07c2 RC_Channel: improved docs for RCn_FUNCTION=0 2013-12-16 11:17:26 +11:00
Randy Mackay
f8e2947823 RC_Channel: parameter @Units to pwm 2013-11-26 22:34:28 +09:00
Randy Mackay
330687a754 RC_Channel: formatting 2013-10-31 15:23:52 +09:00
Andrew Tridgell
97b7130bb9 libraries: update license header to GPLv3
we switched to GPLv3 a long time ago, but neglected to update the
per-file license headers
2013-08-30 13:01:39 +10:00
Andrew Tridgell
a12991923e RC_Channel: prevent overwrite of memory on high RC_Channel constructor 2013-08-18 11:42:23 +10:00
Randy Mackay
e4ca7d2fdf AC_Sprayer: first implementation 2013-08-05 21:11:09 +09:00
Andrew Tridgell
fef6a76078 RC_Channel: rename 'Manual' to RCPassThru
this should make it clearer what it does
2013-07-26 16:07:00 +10:00
Andrew Tridgell
21859f9364 RC_Channel: fixed dead_zone for range channels
The dead_zone was being used inconsistently, used in PWM space in one
place, and in control output space in another.

The fix required us to move the index number of the RC channel eeprom
value for RCn_DZ, as users will have a throttle deadzone of 3 set in
their eeprom due to a bug that Randy just fixed that caused the value
to always be saved to eeprom. In plane we then need to fix the
deadzone for the throttle to be 30

this fixes issue #303

Thanks to Soren Kuula for spotting this!
2013-07-13 13:18:54 +10:00
Randy Mackay
fb5ada38c0 RC: example sketch uses set_default_dead_zone 2013-07-12 11:44:58 +09:00
Randy Mackay
47437b9ddf RC: set dead zone only if parameter has not been set by user 2013-07-12 11:44:16 +09:00
Andrew Tridgell
6b7b69a048 RC_Channel: added secondary rudder support
this is used when nose wheel steering needs different reverse/range
from rudder
2013-06-29 17:31:03 +10:00
Andrew Tridgell
02252b5387 RC_Channel: removed reference to dip switches 2013-06-03 17:49:56 +10:00
Andrew Tridgell
c0058bbb03 RC_Channel: added output_trim() and read() functions
these make using rcmap in the plane code easier
2013-06-03 16:23:48 +10:00
Andrew Tridgell
0438952a8b RC_Channel: removed global rc_ch[] array
hide it as a object static instead
2013-06-03 16:23:47 +10:00
Andrew Tridgell
c96ac5edbb RC_Channel: fixed indent-tabs-mode 2013-05-30 09:48:45 +10:00
Andrew Tridgell
b71f36ee34 RC_Channel: support 8 auxillary RC channels
needed for full 12 channel support on PX4
2013-04-25 20:10:53 +10:00
Andrew Tridgell
a093926b04 Revert "RC_Channel: removed pwm_out variable from RC_Channel"
This reverts commit 8e4a003d8d.

It is used by MotorsMatrix
2013-03-29 22:36:29 +11:00
Andrew Tridgell
8e4a003d8d RC_Channel: removed pwm_out variable from RC_Channel
saves 16 bytes
2013-03-29 19:32:52 +11:00
Michael
5d91b06de3 RC_Channel: added secondary elevator support 2013-02-05 08:57:28 +11:00
Andrew Tridgell
9b4c75c66b RC_Channel: don't change trim if radio in is zero 2013-01-25 20:44:36 +11:00