200 Commits

Author SHA1 Message Date
Daniel Agar
2142459027 Revert "simulator: remove hack for diff_pressure noise"
This reverts commit 4a71984f77249230787b7d263d866d6cfa78a7ac.
2019-04-29 10:46:38 -04:00
Julian Oes
4a71984f77 simulator: remove hack for diff_pressure noise
The noise for airspeed is now applied on the Gazebo side and we can
remove this hack.
2019-04-28 18:22:21 -04:00
Mark Sauder
74bc6870ed simulator: uorb and initialization cleanup (#11825)
* Cherry pick the vehicle_imu PR #9756 src/modules/simulator directory work to submit as standalone PR.

* Modify the accelsim init method mag_report usage to match usage in measure() and mag_measure() methods in the class.

* Incorporate review comments in the accelsim.cpp init() method and also make the same modifications in gyrosim.cpp.

* Delete unneeded mag_report initialization from accelsim init() method.

* Deprecate unneeded measure() call from accelsim.cpp init() and gyrosim.cpp init().
2019-04-16 08:29:53 +02:00
bresch
6c823903bc Parameter update - Rename variables in modules/simulator
using parameter_update.py script
2019-04-03 15:38:50 +02:00
mcsauder
a6315d4e6e Delete Simulator class subscription vars that are not used and add orb_unsubscribe() calls. 2019-03-18 10:00:39 +01:00
mcsauder
d12cec81ba Add const specifier to remaining methods utilizing mavlink_message_t and similar message pointer types. 2019-03-07 08:22:44 +01:00
mcsauder
278fddb585 Cut case MAVLINK_MSG_ID_ODOMETRY content and paste into handle_message_odometry() method. 2019-03-07 08:22:44 +01:00
mcsauder
3918d0ce0a Cut case MAVLINK_MSG_ID_VISION_POSITION_ESTIMATE content and paste into handle_message_vision_position_estimate() method. Add const specifier to publish_odometry_topic() method. 2019-03-07 08:22:44 +01:00
mcsauder
c3acd3bad3 Delete unnecessary curly braces in simulator_mavlink.cpp 2019-03-07 08:22:44 +01:00
mcsauder
e43a0bbf1d Cut case MAVLINK_MSG_ID_RC_CHANNELS content and paste into handle_message_rc_channels() method. 2019-03-07 08:22:44 +01:00
mcsauder
801cbc856e Cut case MAVLINK_MSG_ID_HIL_GPS content and paste into handle_message_hil_gps() method. 2019-03-07 08:22:44 +01:00
mcsauder
b705bf6b1c Cut case MAVLINK_MSG_ID_HIL_SENSOR content and paste into handle_message_hil_sensor() method. 2019-03-07 08:22:44 +01:00
mcsauder
0bd5d6caff Refactor set_publish() logic so that a default false value is not (re)set each loop in simulator_mapvlink.cpp and provide a default argument to set_publish() in simulator.h. 2019-03-05 09:16:31 +01: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
Gabriel Moreno
fc7c7ac206 simulator: fix to set system and component IDs as defined in params
The simulator had hardcoded component ID and system ID (sysID was 0), ignoring what was set up in the params MAV_SYS_ID and MAV_COMP_ID. This caused an issue with multi-vehicle simulations that that rely on sysID to identify the vehicles.

Signed-off-by: Gabriel Moreno <gabrielm@cs.cmu.edu>
2019-03-03 10:41:47 +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
mcsauder
b0a79996ae Cut case MAVLINK_MSG_ID_HIL_STATE_QUATERNION content and paste into handle_message_hil_state_quaternion() method. 2019-02-28 19:24:50 +01:00
mcsauder
8b42045546 Cut case MAVLINK_MSG_ID_HIL_OPTICAL_FLOW content and paste into handle_message_hil_optical_flow() method. 2019-02-28 19:24:50 +01:00
mcsauder
24e55e4d4d Cut case MAVLINK_MSG_ID_DISTANCE_SENSOR content and paste into handle_message_distance_sensor() method. 2019-02-28 19:24:50 +01:00
mcsauder
411db781eb Cut case MAVLINK_MSG_ID_LANDING_TARGET content and paste into handle_message_landing_target() method. 2019-02-28 19:24:50 +01:00
Oleg Kalachev
0b4751d031 simulator_mavlink: fix DISTANCE_SENSOR.covariance field handling 2019-02-22 18:31:27 +00:00
Oleg Kalachev
fbc8d01a7e Rename distance_sensor.covariance to variance 2019-02-22 18:31:27 +00:00
Daniel Agar
d7ba8cc3f0
simulator mavlink don't send_controls() until ready (#11426) 2019-02-11 10:50:24 -05:00
Daniel Agar
7c3999e00e
update mavlink and sitl_gazebo to latest with odometry velocity covariance 2019-02-10 16:32:59 -05:00
Matthias Grob
664674c36b simulator_mavlink: zero initializer instead of memset
Needed a clear scope inside a case for irlock_reports.
2019-02-05 10:09:15 -05:00
Matthias Grob
73f4706597 simulator_mavlink: consistent system call scope operator 2019-02-05 10:09:15 -05:00
Matthias Grob
1e14b10dee simulator_mavlink: take care of battery percentage rounding errors
In 5bb9babc206068e9ee67e1489433be94482a402f I made MAVLink send a
rounded up integer instead of rounded down. This makes sense in practice
because the low battery reactions happen exactly when the reported number
switches in the UI. But here we want to provoke an exact 50% in the UI so
we stop counting at 49.9%, it get's rounded up and we see the expected
result.
2019-01-14 19:30:36 +01:00
Matthias Grob
a89e550f3c simulator_mavlink: switch battery max and min to fix simultion
In 3e6e1f5c2b042accca72346273fc1755dd7670fa the simulated battery
percentage was reversed. I'm assuming because of the possibly
missleading variable name. Now I'm fixing it by switching the
maximum and minimum voltage such that the name is not misleading anymore
but it still works as expected.
2019-01-14 19:30:36 +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
a1fc44d1f0 simulator: fix noise in airspeed
It turns out the noise of the airspeed depends on the least significant
bit of time which is now always 0 because time is quite regular with
lockstep. Therefore, we need a better source for the randomness. I chose
to use the sign of the y-gyro and it seems to work.
2018-12-22 10:32:18 +01:00
Julian Oes
1b685de70d simulator: raise timeout
This is not suposed to ever trigger anyway.
2018-12-22 10:32:18 +01:00
Julian Oes
8b2c47523f simulator: set socket options after opening socket 2018-12-22 10:32:18 +01:00
Julian Oes
e4af97b11b simulator: fix printf format 2018-12-22 10:32:18 +01:00
Julian Oes
564cae86b5 simulator: remove doubled tcgetattr call 2018-12-22 10:32:18 +01:00
Julian Oes
8a5e0558e4 simulator: improve a couple of error messages 2018-12-22 10:32:18 +01:00
Julian Oes
f36f85010c simulator: fix casting warning on Windows 2018-12-22 10:32:18 +01:00
Julian Oes
22b584b3b4 simulator: fix TCP connection init on macOS
When `connect()` fails, the state of the socket is unspecified and we
need to close the it and create it again.

It turns out retrying connect worked on Linux but it didn't on macOS.
2018-12-22 10:32:18 +01:00
Julian Oes
107606e757 simulator: set device_ids when publishing directly
Without setting the device_id, the preflight checks fail because the
calibration is not found.
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
a7e93bc2da simulator: removed leftover (wrong) comment 2018-12-22 10:32:18 +01:00
Julian Oes
3e6e1f5c2b POSIX: use lockstep_scheduler to fake time
This integrates the lockstep_scheduler, so that the system time is set
by the mavlink HIL_SENSOR message.

This means that the speed factor is removed and the speed is entirely
given by the simulator.
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
Daniel Agar
571364c617 delete baro_report (alias for sensor_baro_s) 2018-11-06 07:43:43 +08:00
Daniel Agar
acc24da0c2 delete gyro_report (alias for sensor_gyro_s) 2018-11-06 07:43:43 +08:00
Daniel Agar
2a83a40491 delete accel_report (alias for sensor_accel_s) 2018-11-06 07:43:43 +08:00
MaEtUgR
4f0e090e88 drv_rc_input: replace useless rc_input_values define 2018-09-21 16:26:27 +02:00
TSC21
095cdeb4b0 add a local frame of reference field to vehicle_odometry 2018-09-18 09:52:33 +02:00
TSC21
cc73f214d1 add covariance matrices index aliases 2018-09-18 09:52:33 +02:00
TSC21
6329f1a38a small fix on cov passing loop 2018-09-18 09:52:33 +02:00
TSC21
746250d86d use static_assert over covariance matrices URT array size 2018-09-18 09:52:33 +02:00