Commit Graph

459 Commits

Author SHA1 Message Date
Carlo Wood
baf89f4398 Clean up of px4_defines.h (remove math.h)
This patch reorders px4_defines.h to make it more readable (I think)
but more importantly, cleans up the #include <math.h>/<cmath>
and [std::]isfinite stuff.

My main goal was to completely get rid of including math.h/cmath,
because that doesn't really belong in a header that is supposed to
define macro's and is included in almost every source file (if not
all).

I'm not sure what it did before ;) (pun intended), but now it does
the following:

PX4_ISFINITE is only used in C++ code (that was already the case,
but hereby is official; for C code just use 'isfinite()') and is
defined to be std::isfinite, except on __PX4_QURT because that uses
the HEXAGON toolset which (erroneously) defines isfinite as macro.

I would have liked to remove PX4_ISFINITE completely from the code
and just use std::isfinite whereever that is needed, but that would
have required changing the libecl submodule, and at the moment I'm
getting tired of changing submodules... so maybe something for the
future.

Also, all includes of <math.h> or <cmath> have been removed except
for __PX4_NUTTX. Like the HEXAGON toolset NuttX currently defines
isfinite as macro for C++. So, we could have solved this in the
same was as __P4_QURT; but since we can fix NuttX ourselves I chose
to add a kludge to px4_defines.h instead that fixes this problem,
until the time that NuttX can be fixed (again postponing changing
a submodule). The kludge still demands including <cmath>, thus.

After removal of the math header file, it needed to be included
in source files that actually need it, of course.

Finally, I had a look at the math macro's (like M_PI, M_PI_F,
M_DEG_TO_RAD etc). These are sometimes (erroneously) defined in
certain math.h header files (like both, hexagon and nuttx).
This is incorrect: neither the C nor the C++ standard defines
math constants (neither as macro nor otherwise). The "problem"
here was that px4_defines.h defined some of the M_*_F float
constants in terms of the M_* double constant, which are
sometimes not defined either thus. So, I cleaned this up by
defining the M_*_F math constants as float literals in px4_defines.h,
except when they are defined in math.h for that platform.
This means that math.h has to be always included when using those
constants, but well; not much difference there as those files
usually also need/use the macro NAN (which *is* a standard macro
defined by math.h).

Finally finally, DEFAULT_PARAM_FILE was removed as it isn't
used anymore.

All in all I think the resulting px4_defines.h is nice, giving me
much less the feeling of a nearly unmaintainable and over time
slowly growing collection of kludges and hacks.
2016-10-28 08:41:30 +02:00
Beat Küng
7415d94e12 mavlink: don't publish HIL_CONTROLS in HIL mode
it generates unnecessary load. If really needed, it can still be enabled
manually.
2016-10-20 18:54:47 +02:00
Beat Küng
318c970477 mavlink ulog streaming: add rate limiting
This limits the maximum bandwidth of ulog streaming to 70% of the specified
mavlink datarate. If less is used, the leftover is assigned to the mavlink
streams, if more is used, it starts to drop.

mavlink status outputs the currently used rate, to check if a link is
saturated.
2016-10-19 13:13:47 +02:00
Beat Küng
7d72f31a29 mavlink: integrate MavlinkULog into the main Mavlink task & receiver 2016-10-19 13:13:47 +02:00
Beat Küng
9ceb5a7e2e mavlink: extend status output 2016-10-06 09:01:57 +02:00
Beat Küng
241fd629ce ERROR macro: get rid of the many 'oddly, ERROR is not defined for c++', use PX4_ERROR 2016-09-30 13:50:51 +02:00
Julian Oes
1b69f9cb23 mavlink: don't miss first vehicle_command_ack
This fixes a corner case where the first advertise/publish of a
vehicle_command_ack was missed. What happened was that the
orb_subscribe_multi was not called until the topic had been published
and therefore orb_exists was happy. This means that by the time
orb_subscribe_multi was finally called, the first vehicle_command_ack
was already history and not detected by orb_check.

This changed adds a flag to the MavlinkOrbSubscription which tells it to
subscribe to a topic from the beginning.
2016-09-30 08:02:55 +02:00
Julian Oes
047c0e44bd mavlink_mission: support missions with int params
This brings support for the messages MISSION_REQUEST_INT and
MISSION_ITEM_INT which raises the lat/lon accuracy for waypoints.
2016-09-26 22:55:21 +02:00
Dennis Shtatnov
52fdbf4acc Syslink Bridge to Mavlink (#5479) 2016-09-11 11:23:15 +02:00
Beat Küng
90c7b06152 mavlink hil: add HIL_CONTROLS publication for compatibility (eg. with mavros) 2016-09-06 11:33:18 +02:00
Beat Küng
010c9e937b SITL: switch to HIL_ACTUATOR_CONTROLS mavlink message & add pwm_out_sim support for 16 outputs 2016-09-06 11:33:18 +02:00
Dennis Shtatnov
e91821d2a2 Merge Crazyflie motor driver with FMU
Comment corrections
2016-09-04 19:12:08 +02:00
Dennis Shtatnov
e6b98b2ab8 Tweak configs for CF2
Fix build error

Capitalization mistake for headers

Non-Mac compiler issue

Baudrate for crazyflie nrf and fix code style

Save space

Cleanup mpu9250 driver
2016-09-04 19:12:08 +02:00
Tim Dyer
b65ff53b00 Initial build for Crazyflie 2.0
Working crazyflie firmware build

* Console on USART3
* Could not disable building PX4IO firmware, currently commented out

Don't build PX4IO firmware if the board doesn't ask for it

Added crazyflie motor driver

Fixed wrong register

CLK_SEL is in PWR_MGMT_1

Initial I2C/SPI MPU9250 device

* Tested with I2C
* Need to add error checking
* Intermittent crash on stop call

Working ak8963 mag driver

Functional lps25h driver. Work in progress.

Works well enough to probe and allow sensors task to start.

Added serial port test module

HACK! Get sensors module working

Set crazyflie PWM range

Extend baudrate for Crazyflie's NRF radio

Added dummy tone alarm to allow for init

Added autostart script for Crazyflie
2016-09-04 19:12:08 +02:00
Lorenz Meier
8dc8ae7de8 MAVLink app: Only hold buffers for published topics 2016-08-28 10:49:41 +02:00
Lorenz Meier
d4b588f84a Fix proto version selection 2016-08-28 10:40:00 +02:00
Lorenz Meier
6f19531ce4 MAVLink: Cleanup of port handling, switch to MAVLink 2 if receiving MAVLink 2. Announce MAVLink 2 capability in autopilot_version message
commit
2016-08-28 10:08:15 +02:00
Lorenz Meier
720c445f21 MAVLink: Code style 2016-08-26 23:43:33 +02:00
Lorenz Meier
e67a6bdfc2 MAVLink: No need to restore previous port config on exit 2016-08-26 23:38:46 +02:00
Lorenz Meier
39ce001c41 MAVLink: use only the memory it needs 2016-08-15 19:53:21 +02:00
David Sidrane
deeefe5dd1 Describe the issues that requires the +=2 on arg[c|v] for NuttX (#5293)
This may be moot and should be revisited if only px4_getops is used, but this pr politely documents the reson for the logic.
2016-08-10 06:19:59 -10:00
Beat Küng
2241ab9cac mavlink: add a shell using SERIAL_CONTROL MAVLink message 2016-07-29 13:07:17 +02:00
Julian Oes
3ed8b735c2 mavlink: only warn once if broadcast fails
This fixes the issue where the console was spammed if a broadcast failed
after a connection had previously been established.
2016-07-13 19:40:59 +02:00
Julian Oes
d9343fa925 mavlink: use new copy_if_updated interface 2016-07-13 10:10:45 +02:00
Lorenz Meier
71d150f6ec MAVLink app: Fix rate handling 2016-07-10 17:05:33 +02:00
tommises
d2194d787f Refactored Mavlink stream configuration (#5015)
Streams ordered same way in all modes.
2016-07-10 16:22:22 +02:00
Lorenz Meier
972a6f7be8 Fix MAVLink reporting of Firmware version, implement dev / release version reporting 2016-07-02 11:43:24 +02:00
Hidenori
76ee17e532 RC input and PWM output for Navio2 2016-07-01 23:08:17 +02:00
Daniel Agar
050eedc4f8 mavlink publish WIND_COV (#4913)
* mavlink publish WIND_COV

-closes #4678

* px4fmu-v2_default disable logger and sync configs
2016-06-27 16:16:24 +02:00
Henry Zhang
ae6600e48f MAVLink app: fix mavlink forwarding issue. (#4907) 2016-06-25 11:02:01 +02:00
Nate Weibley
0551e001e2 Properly reflect flow control state if IOCTL fails (#4873)
The flow control state is improperly reflected as enabled if the arch/HAL rejects an IOCTL to turn it on. Mavlink::enable_flow_control updates _flow_control_enabled only if the IOCTL call does not fail.
2016-06-23 10:17:17 +02:00
Chris Lovett
534e10c96a Implement code review feedback. Add get_id_static to MavlinkStream items. Add implementation of MAV_CMD_SET_MESSAGE_INTERVAL, MAV_CMD_GET_MESSAGE_INTERVAL. Add deprecation message to REQUEST_DATA_STREAM. 2016-06-21 10:10:50 +02:00
Beat Küng
26b7ac3884 mavlink: remove an UDP remote port warning, print remote port in mode info 2016-06-15 09:56:34 +02:00
Julian Oes
67b2f68abd mavlink: improved, updated usage 2016-06-07 22:10:56 +02:00
Julian Oes
ec5b2adfc0 mavlink: don't try broadcast 0, and less printfs
This removes a bunch of unneeded printfs and prevents broadcasting
packets of size 0 which just trigger a warning.
2016-06-07 22:10:56 +02:00
Beat Küng
1be3c0fe48 mavlink_main.cpp: fix race conditions in 'mavlink stop-all'
This had multiple issues:
- linked list was modified while other instances were still running and
  accessing it (the used linked list is NOT thread-safe).
- Mavlink instance was deleted, but it was still in the linked list, and
  thus could still be dereferenced by other threads
- the instance was deleted, but it was still accessed by the 'stop-all'
  calling thread

What we do now is:
- wait for all threads to exit
- then remove the instances from the linked list and delete them
2016-06-07 10:05:59 +02:00
Beat Küng
1f55e23827 fix resource leak in mavlink_main.cpp: close the socket 2016-06-07 10:05:59 +02:00
Lorenz Meier
66db577c7d Tone down mavlink message 2016-06-05 14:37:47 +02:00
Lorenz Meier
ff4f27b05e MAVLink app: Add option to configure broadcast, default to off 2016-06-05 12:39:33 +02:00
Beat Küng
8c9b272545 mavlink udp: avoid spamming the console when disconnecting the Network or bcast addr not found (#4611) 2016-05-30 21:53:37 +02:00
Lorenz Meier
1b2043b929 MAVLink app: Allocate buffers only as they are needed 2016-05-29 16:14:33 +02:00
Lorenz Meier
7a0d43586f MAVLink app: Only start transmitting when boot is complete (#4666) 2016-05-28 09:57:07 +02:00
Lorenz Meier
c4da55e40f MAVLink app: Reduce excessive allocation 2016-05-22 15:03:22 +02:00
Daniel Agar
1ecdb0f6fb adjust stack sizes 2016-05-19 21:49:34 +02:00
Lorenz Meier
56e887c6c7 MAVLink app: Return result of network operation 2016-05-19 20:13:32 +02:00
Lorenz Meier
84800dfd87 MAVLink: Update complete app to support MAVLink 1 & MAVLink 2. Add MAV_PROTO_VER param to switch between them 2016-05-19 20:13:32 +02:00
Lorenz Meier
0a597d0d62 MAVLink: Update to version 2 compaat API 2016-05-19 20:13:32 +02:00
Lorenz Meier
6eccfe3d14 MAVLink 2.0: Take a first stab at integration, enable heartbeat packets 2016-05-19 20:13:32 +02:00
Daniel Agar
008354f935 testing cleanup 2016-05-13 13:01:41 +02:00
Daniel Agar
eae726e345 FW add mavlink NAV_CONTROLLER_OUTPUT 2016-05-13 12:56:04 +02:00