64 Commits

Author SHA1 Message Date
Peter Blom
a4745c6825 Simulator: Fix for arg count increase breaking remote host option.
The number of arguments was increased by one, see: 1719ff9892

Because the above commit was merged before https://github.com/PX4/PX4-Autopilot/pull/15443 . It broke support for the remote host option.

This has been fixed in this commit by increasing all argv's by one.

Signed-off-by: Peter Blom <peterblom.mail@gmail.com>
2021-01-28 08:32:14 +01:00
Muesli_Reep
fe7908feb0
Simulator: Added remote host option (#15443)
* Added an option to the Simulator module to connect to remote Gazebo servers.

This is usefull when the Gazebo simulation is running on a different host than the PX4 instance.
For example, we are running instances of PX4 with a companion application in multiple Dockers, for swarming simulations, which then connect to a remote Gazebo server.

A "-t" input argument has been added and can be called from the rcS startup script as: simulator start -t "192.168.178.122" $simulator_tcp_port

* _tcp_remote_ipaddr defaults to nullptr. This way testing against nullptr it can be determined if localhost or remote host is desired by the user.
* Documented the option in usage().

Signed-off-by: Peter Blom <peterblom.mail@gmail.com>
2021-01-10 18:37:37 +01:00
Julian Oes
1719ff9892 simulator: fix after px4_task_spawn_cmd change
argv[0] now contains the task name, so everything moves by one.
2020-12-14 09:26:18 +01:00
Daniel Agar
971b1e4b4d sensors: move mag aggregation to new VehicleMagnetometer WorkItem
- purge all reminaing magnetometer IOCTL usage
 - mag calibration add off diagonal (soft iron) scale factors
2020-08-21 10:12:13 -04:00
Daniel Agar
f55ed0992c
accel and gyro calibration refactor and cleanup
- remove all remaining IOCTLs for accel and gyro and handle all calibration entirely in sensors module with parameters
 - sensor_accel and sensor_gyro are now always raw sensor data
 - calibration procedures no longer need to first clear existing values before starting
 - temperature calibration (TC) remove all scale (SCL) parameters
    - gyro and baro scale are completely unused
    - regular accel calibration scale can be used (CAL_ACC*_xSCALE) instead of TC scale
2020-06-17 22:50:09 -04:00
Daniel Agar
e34bdb4be9
move IMU integration out of drivers to sensors hub to handle accel/gyro sync
- IMU integration move from drivers (PX4Accelerometer/PX4Gyroscope) to sensors/vehicle_imu 
 - sensors: voted_sensors_update now consumes vehicle_imu
 - delete sensor_accel_integrated, sensor_gyro_integrated
 - merge sensor_accel_status/sensor_gyro_status into vehicle_imu_status
 - sensors status output minor improvements (ordering, whitespace, show selected sensor device id and instance)
2020-05-30 11:07:54 -04:00
Daniel Agar
de4f594937 DriverFramework purge
The bulk of this change was tightly coupled and needed to be deleted in one pass. Some of the smaller changes were things that broke as a result of the initial purge and subsequently fixed by further eradicating unnecessary platform differences. Finally, I deleted any dead code I came across in the related files I touched while going through everything.

 - DriverFramework (src/lib/DriverFramework submodule) completely removed
 - added dspal submodule in qurt platform (was brought in via DriverFramework)
 - all df wrapper drivers removed
 - all boards using df wrapper drivers updated to use in tree equivalents
 - unused empty arch/board.h on posix and qurt removed
 - unused IOCTLs removed (pub block, priv, etc)
 - Integrator delete methods only used from df wrapper drivers
 - commander: sensor calibration use "NuttX version" everywhere for now
 - sensors: update to px4_{open, read, close} instead of DevMgr wrapper (adc open for analog differential pressure)
 - battery_status: update to px4_{open, read, close} instead of DevMgr wrapper (adc open for analog differential pressure)
 - cdev cleanup conflicting typedefs and names with actual OS (pollevent_t, etc)
 - load_mon and top remove from linux boards (unused)
 - delete unused PX4_MAIN_FUNCTION
 - delete unused getreg32 macro
 - delete unused SIOCDEVPRIVATE define
 - named each platform tasks consistently
 - posix list_devices and list_topics removed (list_files now shows all virtual files)
2020-01-13 14:07:03 -05:00
Daniel Agar
d32a80df3a
simulator: replace gpssim with simple orb publication
- this is one of the last pieces of the system that still depend on DriverFramework
 - add new SIM_GPS_NOISE_X parameter for optionally increasing the GPS noise multiplier (was previously a gpssim command line option)
 - add SIM_x_BLOCK parameters to block sensor publication
   - SIM_GPS_BLOCK
   - SIM_ACCEL_BLOCK
   - SIM_GYRO_BLOCK
   - SIM_MAG_BLOCK
   - SIM_BARO_BLOCK
   - SIM_DPRES_BLOCK
2020-01-09 10:30:20 -05:00
Daniel Agar
aaf5670e7d
deprecate df_bmp280_wrapper and replace with in tree bmp280
- deprecate DriverFramework bmp280 driver (df_bmp280_wrapper)
 - update beaglebone blue and snapdragon flight eagle boards to use in tree bmp280
 - update posix (really just linux) and qurt I2C wrappers
 - tested on beaglebone blue
2020-01-05 13:33:12 -05:00
Julian Oes
8817f172ea simulator: cleanup and wait for startup
Unfortunately this commit contains two things:
1. Some cleanup and renaiming.
2. An additional wait until lockstep has been initialized.
   By waiting until HIL_SENSOR messages arrive including timestamps we
   stop the startup script and prevent other modules from running until
   time is set up. This should resolve some busy waiting by various
   modules and prevent races on initialization (e.g. the landing state
   being subscribed by mavlink before being published by the land
   detector).
2019-12-26 10:16:58 +01:00
Lorenz Meier
acd18adc18 Tests: Speed up boot
The previous boot configuration took at minimum one second to boot. This is in particular significant in tests when the system is often started and stopped
2019-12-23 23:08:05 +01:00
Beat Küng
3198610f85 src/platforms: move all headers to platforms/common/include/px4_platform_common
and remove the px4_ prefix, except for px4_config.h.

command to update includes:
for k in app.h atomic.h cli.h console_buffer.h defines.h getopt.h i2c.h init.h log.h micro_hal.h module.h module_params.h param.h param_macros.h posix.h sem.h sem.hpp shmem.h shutdown.h tasks.h time.h workqueue.h; do for i in $(grep -rl 'include <px4_'$k src platforms boards); do sed -i 's/#include <px4_'$k'/#include <px4_platform_common\/'$k/ $i; done; done
for in $(grep -rl 'include <px4_config.h' src platforms boards); do sed -i 's/#include <px4_config.h/#include <px4_platform_common\/px4_config.h'/ $i; done

Transitional headers for submodules are added (px4_{defines,log,time}.h)
2019-10-30 11:48:47 +01:00
Daniel Agar
c8e59c4e39 parameter_update use uORB::Subscription consistently 2019-09-29 10:49:03 -04:00
Daniel Agar
43e3fc707d
simulator move to PX4Accelerometer, PX4Gyroscope, PX4Magnetometer, PX4Barometer helpers (#12081) 2019-05-30 21:07:26 -04:00
mcsauder
6e0fc150c0 Create Simulator::set_publish() method and Simulator::_publish member variable to allow redefinition of the Simulator::handle_message() prototype to match MavlinkReceiver::handle_message(). 2019-03-05 09:16:31 +01:00
mcsauder
1eced05359 Rename Simulator class private methods names to match snake case of other private class methods. 2019-02-28 19:26:45 +01:00
Julian
3e87013936 simulator: fix TCP on Cygwin-Windows
It turns out that `sendto` does not work for TCP on Cygwin-Windows,
instead we need to use `send`. This required some refactoring since we
need to have the internet protocol and the port stored as a member
variable.

This should fix that lockstep SITL simulation was not working on
Windows.
2018-12-27 07:49:12 +01:00
Julian Oes
73578a593f simulator: bring -t argument back
The -t argument had been deleted because I didn't realize that it was
actually being used. Therefore, this brings it back and we now use -c
for TCP.
2018-12-22 10:32:18 +01:00
Julian Oes
6d7fb232dd simulator: added TCP, general cleanup, lockstep
This adds the option to connect over UDP or TCP for mavlink to the
SITL simulator.

Also, this includes a bunch of general cleanup and refactoring of the
simulator interface code. For instance sending of mavlink messages was
put into separate functions and unneccessary comments were removed.

Also, this now sets the timestamp sent by the SITL simulator in the
HIL_SENSOR message in order to enable lockstep.
2018-12-22 10:32:18 +01:00
Julian Oes
5b9dea5604 Replacing usleep with px4_usleep
This is a step towards isolating time from the system.
2018-12-22 10:32:18 +01:00
Beat Küng
e6b9806ee1 SITL: add multi-vehicle support to rcS
This also removes the HIGHRES_IMU mavlink stream to the GCS. I don't see
why it's needed and it adds noticeable CPU load.
2018-08-13 21:50:14 -04:00
Lorenz Meier
7223780563 Simulator: Make battery discharging configurable. 2017-08-20 20:37:31 +02:00
Beat Küng
b0439836f6 refactor drv_led.h: rename to drv_board_led.h
This makes it clear that it's used to control the board LED's, not external
LED's.
2017-03-12 00:08:35 +01:00
Beat Küng
b1e27f4395 simulator: handle ctrl-c during startup correctly
This makes sure the px4 process does not hang when Ctrl-C is pressed
during startup.
2017-03-10 11:28:41 +01:00
Daniel Agar
e927f3e040 clang-tidy modernize-use-nullptr 2017-02-01 22:15:50 -05:00
korotkoves
1a992c2d02 fix code style for Travis 2016-05-13 13:24:30 +02:00
korotkoves
22e3ce7d7a simulator udp port from command line 2016-05-13 13:23:20 +02:00
Lorenz Meier
8e62c9eb8d Use delay API 2016-02-05 00:53:22 +01:00
Lorenz Meier
f57eff5433 Bump internal sim thread priority. Output warning if sim packets are spaced more than 10 ms apart, giving some hints what is at miss with the system 2015-12-01 13:02:17 +01:00
Lorenz Meier
58d5fdc853 Simulator: All app names are lowercase! 2015-12-01 12:01:31 +01:00
Mark Charlebois
3f20d78dfe Fixed code style
Signed-off-by: Mark Charlebois <charlebm@gmail.com>
2015-11-16 14:01:39 -08:00
Mark Charlebois
dbe3b0e52b Re-enabling code to handle DF framework
Updated to latest DriverFramework and changed ioctl args to
unsigned int from void *.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
2015-11-16 13:51:39 -08:00
Lorenz Meier
30d0dab8e6 Simulator: Fix code style 2015-09-20 11:35:52 +02:00
Lorenz Meier
0597c57c32 Simulator: Provide better and more user-facing feedback 2015-09-12 15:44:40 +02:00
Lorenz Meier
a1f93f52b0 Merge pull request #2811 from mcharleb/qurt_rebase_updates-3
Qurt rebase updates 3
2015-09-05 11:55:03 +02:00
tumbili
0fe272c9b3 support simulated airspeed 2015-09-04 22:34:28 +02:00
Mark Charlebois
54bae34a2c Build fixes for qurt after rebase on PX4 master
Removed the re-definitions of the usage method in the posix/main.cpp file.
Added qurt_external_hook interface to call externally linked module.
Fixed code format to comply with PX4 style.
Added usage information to main app and handled cases for unknown arguments.
Fixed the orb_priority interface to use int32_t instead of int.
Fixes to get hil working with led changes.
Added the config_eagle_adsp.mk file and update the make files to to use new
include/lib paths

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
2015-09-04 11:09:29 -07:00
Lorenz Meier
5a1af860ab Sim: Enforce boot order is correct, sim starts first 2015-07-04 08:09:12 -07:00
Lorenz Meier
32bf4dc773 simulator: Add output so user knows that the simulator / system is waiting for data 2015-07-04 07:25:08 -07:00
Mark Charlebois
c611749b4f Simulator: modified -p to publish individual sensor data
The simulator was changed to publish the sensor data that is read
by the sensors module when the -p flag is passed.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
2015-07-01 18:20:14 -07:00
Mark Charlebois
d66b6ea701 POSIX: px4_getpid() fix
Since the PX4 code uses both px4_task and pthread APIs,
px4_getpid() must be save to call from either context.

On posix, this means we have to always return the pthread ID.

Reverted simulator change of pthread to px4_task

There may have been side effects if this was build for a target that
has process/task scoped file descriptors. It is now safe to call
px4_getpid() from this pthread context with this change for the
posix build for px4_getpid().

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
2015-06-15 08:25:57 -07:00
Mark Charlebois
7e7513bc15 POSIX: change pthreads to px4_tasks in simulator
The simulator was using pthread APIs directly so calls to px4_getpid()
would fail since the task ID was not known. Changed simulator to use
px4_task_spawn_cmd.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
2015-06-13 16:44:29 -07:00
tumbili
5c013af574 save gps data so driver can read 2015-06-08 22:21:59 -07:00
tumbili
f0a3210e94 major simulator rework:
- wait for first message from jMAVSim
  before sending data
- publish raw rc data coming from PIXHAWK (temporary)
- send some interesting messages to jMAVSim
- prepare sensor data for sim drivers to read
2015-06-08 22:21:58 -07:00
Mark Charlebois
2d85578599 Gyrosim: Fixed constant looping
Gyrosim would call measure continuously because the write_checked_reg
was failing. There is no need to check faked reg writes in the
simulator so that code was removed.

The delay that was added to the simulator to pace the gyrosim reads
was also removed now that the source of the problem was determined.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
2015-05-28 11:20:30 -07:00
Mark Charlebois
f1f562a94d POSIX: Fixed orb_advertise failure
There were an insufficient number of devmap entries allocated and
when they ran out, new orb_advertise requests would fail.

Also added a new logging macro for the Linux build to show the
calling pthread if enabled.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
2015-05-21 15:35:11 -07:00
Mark Charlebois
ffdc9d629c POSIX: Improved logging
The warnx and warn calls map to PX4_WARN.
Calls to errx or err genrtate a compile error.

The px4_log.h file implements a new log format:

For DEBUG and INFO:
<level> <msg>

For ERROR and WARN:
<level> <msg> (file filepath line linenum)

The verbosity can be changed by setting the macro to use
either linux_log or linux_log_verbose in px4_log.h

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
2015-05-19 09:19:24 -07:00
Mark Charlebois
d0bf4ab449 Simulator: refactored mavlink additions
QuRT does not support UDP so moved the mavlink specific code
to a new file that is not built for the qurt target

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
2015-05-11 19:25:11 -07:00
Mark Charlebois
2d32395bc0 Merge branch 'qurt' into linux 2015-05-11 16:07:53 -07:00
Mark Charlebois
a99f916bdf POSIX: Changed px4_debug.h to px4_log.h
Also changed use of printf to PX4_WARN or PX4_INFO in posix and
qurt tests.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
2015-05-11 16:04:39 -07:00