Skip to content

Commit

Permalink
HITL: remove unused airspeed subsciption from gzsim
Browse files Browse the repository at this point in the history
HITL: add support for actuator test
  • Loading branch information
haitomatic committed Aug 21, 2024
1 parent 78ff8c8 commit b925819
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
10 changes: 0 additions & 10 deletions src/modules/mavlink/mavlink_receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
* @author Thomas Gubler <[email protected]>
*/

#include <lib/airspeed/airspeed.h>
#include <lib/conversion/rotation.h>
#include <lib/systemlib/px4_macros.h>

Expand Down Expand Up @@ -2661,15 +2660,6 @@ MavlinkReceiver::handle_message_hil_state_quaternion(mavlink_message_t *msg)
const double dt = math::constrain((timestamp_sample - _hil_timestamp_prev) * 1e-6, 0.001, 0.1);
_hil_timestamp_prev = timestamp_sample;

/* airspeed */
airspeed_s airspeed{};
airspeed.timestamp_sample = timestamp_sample;
airspeed.indicated_airspeed_m_s = hil_state.ind_airspeed * 1e-2f;
airspeed.true_airspeed_m_s = hil_state.true_airspeed * 1e-2f;
airspeed.air_temperature_celsius = 15.f;
airspeed.timestamp = hrt_absolute_time();
_airspeed_pub.publish(airspeed);

/* Receive attitude quaternion from gz-sim and publish vehicle attitude
* groundtruth and angular velocity ground truth
*/
Expand Down
2 changes: 0 additions & 2 deletions src/modules/mavlink/mavlink_receiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
#include <uORB/SubscriptionInterval.hpp>
#include <uORB/topics/actuator_armed.h>
#include <uORB/topics/actuator_outputs.h>
#include <uORB/topics/airspeed.h>
#include <uORB/topics/autotune_attitude_control_status.h>
#include <uORB/topics/battery_status.h>
#include <uORB/topics/camera_status.h>
Expand Down Expand Up @@ -288,7 +287,6 @@ class MavlinkReceiver : public ModuleParams
uint16_t _mavlink_status_last_packet_rx_drop_count{0};

// ORB publications
uORB::Publication<airspeed_s> _airspeed_pub{ORB_ID(airspeed)};
uORB::Publication<battery_status_s> _battery_pub{ORB_ID(battery_status)};
uORB::Publication<camera_status_s> _camera_status_pub{ORB_ID(camera_status)};
uORB::Publication<cellular_status_s> _cellular_status_pub{ORB_ID(cellular_status)};
Expand Down
10 changes: 10 additions & 0 deletions src/modules/mavlink/streams/HIL_ACTUATOR_CONTROLS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <lib/mixer_module/mixer_module.hpp>
#include <px4_platform_common/module_params.h>
#include <uORB/topics/actuator_outputs.h>
#include <uORB/topics/actuator_test.h>
#include <uORB/topics/vehicle_control_mode.h>
#include <uORB/topics/vehicle_status.h>
#include <uORB/topics/esc_status.h>
Expand Down Expand Up @@ -84,6 +85,7 @@ class MavlinkStreamHILActuatorControls : public MavlinkStream, ModuleParams
}

uORB::Subscription _act_sub{ORB_ID(actuator_outputs)};
uORB::Subscription _act_test_sub{ORB_ID(actuator_test)};
uORB::Subscription _vehicle_status_sub{ORB_ID(vehicle_status)};
uORB::Subscription _rover_thrust_sub;
uORB::Subscription _rover_torque_sub;
Expand Down Expand Up @@ -219,6 +221,14 @@ class MavlinkStreamHILActuatorControls : public MavlinkStream, ModuleParams
}
}

actuator_test_s actuator_test;

if (_act_test_sub.copy(&actuator_test)) {
if (actuator_test.action != 0) {
msg.mode |= MAV_MODE_FLAG_TEST_ENABLED;
}
}

// [custom use of flag] depending on OutputFunction, if output function is motor type, set bit in bitfield
uint64_t flags = 0;

Expand Down

0 comments on commit b925819

Please sign in to comment.