simulation: SITL outputs from 0..1

Instead of sending actuator controls from -1..1 for SITL, we should send
0..1 like we already do for HIL. This will enable negative thrust in the
future, e.g. for pusher props that spin backwards, or for vehicles with
variable pitch propellers.
This commit is contained in:
Julian Oes
2016-10-28 23:56:46 +02:00
committed by Lorenz Meier
parent 0a043365ec
commit 62603bee45
5 changed files with 93 additions and 17 deletions
+10 -1
View File
@@ -241,7 +241,8 @@ private:
_flow_pub(nullptr),
_dist_pub(nullptr),
_battery_pub(nullptr),
_initialized(false)
_initialized(false),
_system_type(0)
#ifndef __PX4_QURT
,
_rc_channels_pub(nullptr),
@@ -257,6 +258,11 @@ private:
_vehicle_status{}
#endif
{
// We need to know the type for the correct mapping from
// actuator controls to the hil actuator message.
param_t param_system_type = param_find("MAV_TYPE");
param_get(param_system_type, &_system_type);
for (unsigned i = 0; i < (sizeof(_actuator_outputs_sub) / sizeof(_actuator_outputs_sub[0])); i++)
{
_actuator_outputs_sub[i] = -1;
@@ -299,6 +305,9 @@ private:
// Lib used to do the battery calculations.
Battery _battery;
// For param MAV_TYPE
int32_t _system_type;
// class methods
int publish_sensor_topics(mavlink_hil_sensor_t *imu);
int publish_flow_topic(mavlink_hil_optical_flow_t *flow);