mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 05:33:34 +08:00
orb_advert_t changed to void * and checks changed to nullptr
The existing orb_advert_t use thoughout the code sometimes tries to treat it as a file descriptor and there are checks for < 0 and ::close calls on orb_advert_t types which is an invalid use of an object pointer, which is what orb_advert_t really is. Initially I had changed the -1 initializations to 0 but it was suggested that this should be nullptr. That was a good recommendation but the definition of orb_advert_t had to change to void * because you cannot initialize a uintptr_t as nullptr. Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
committed by
Lorenz Meier
parent
180c8b0cb0
commit
1ca05aaa64
@@ -108,13 +108,13 @@ public:
|
||||
|
||||
private:
|
||||
static constexpr float _dt_max = 0.02;
|
||||
bool _task_should_exit = false; /**< if true, task should exit */
|
||||
bool _task_should_exit = false; /**< if true, task should exit */
|
||||
int _control_task = -1; /**< task handle for task */
|
||||
|
||||
int _sensors_sub = -1;
|
||||
int _params_sub = -1;
|
||||
int _global_pos_sub = -1;
|
||||
orb_advert_t _att_pub = 0;
|
||||
orb_advert_t _att_pub = nullptr;
|
||||
|
||||
struct {
|
||||
param_t w_acc;
|
||||
@@ -327,7 +327,7 @@ void AttitudeEstimatorQ::task_main() {
|
||||
memcpy(&att.R[0], R.data, sizeof(att.R));
|
||||
att.R_valid = true;
|
||||
|
||||
if (_att_pub == 0) {
|
||||
if (_att_pub == nullptr) {
|
||||
_att_pub = orb_advertise(ORB_ID(vehicle_attitude), &att);
|
||||
} else {
|
||||
orb_publish(ORB_ID(vehicle_attitude), _att_pub, &att);
|
||||
|
||||
@@ -640,7 +640,7 @@ int attitude_estimator_so3_thread_main(int argc, char *argv[])
|
||||
att.R_valid = true;
|
||||
|
||||
// Publish
|
||||
if (att_pub > 0) {
|
||||
if (att_pub != nullptr) {
|
||||
orb_publish(ORB_ID(vehicle_attitude), att_pub, &att);
|
||||
} else {
|
||||
warnx("NaN in roll/pitch/yaw estimate!");
|
||||
|
||||
@@ -180,7 +180,7 @@ BottleDrop::BottleDrop() :
|
||||
_command {},
|
||||
_global_pos {},
|
||||
ref {},
|
||||
_actuator_pub(0),
|
||||
_actuator_pub(nullptr),
|
||||
_actuators {},
|
||||
_drop_approval(false),
|
||||
_doors_opened(0),
|
||||
@@ -190,7 +190,7 @@ BottleDrop::BottleDrop() :
|
||||
_drop_position {},
|
||||
_drop_state(DROP_STATE_INIT),
|
||||
_onboard_mission {},
|
||||
_onboard_mission_pub(0)
|
||||
_onboard_mission_pub(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -321,12 +321,12 @@ BottleDrop::actuators_publish()
|
||||
_actuators.timestamp = hrt_absolute_time();
|
||||
|
||||
// lazily publish _actuators only once available
|
||||
if (_actuator_pub > 0) {
|
||||
if (_actuator_pub != nullptr) {
|
||||
return orb_publish(ORB_ID(actuator_controls_2), _actuator_pub, &_actuators);
|
||||
|
||||
} else {
|
||||
_actuator_pub = orb_advertise(ORB_ID(actuator_controls_2), &_actuators);
|
||||
if (_actuator_pub > 0) {
|
||||
if (_actuator_pub != nullptr) {
|
||||
return OK;
|
||||
} else {
|
||||
return -1;
|
||||
@@ -619,7 +619,7 @@ BottleDrop::task_main()
|
||||
_onboard_mission.count = 2;
|
||||
_onboard_mission.current_seq = 0;
|
||||
|
||||
if (_onboard_mission_pub > 0) {
|
||||
if (_onboard_mission_pub != nullptr) {
|
||||
orb_publish(ORB_ID(onboard_mission), _onboard_mission_pub, &_onboard_mission);
|
||||
|
||||
} else {
|
||||
@@ -791,7 +791,7 @@ BottleDrop::handle_command(struct vehicle_command_s *cmd)
|
||||
// Abort if mission is present
|
||||
_onboard_mission.current_seq = -1;
|
||||
|
||||
if (_onboard_mission_pub > 0) {
|
||||
if (_onboard_mission_pub != nullptr) {
|
||||
orb_publish(ORB_ID(onboard_mission), _onboard_mission_pub, &_onboard_mission);
|
||||
}
|
||||
|
||||
|
||||
@@ -687,7 +687,7 @@ bool handle_command(struct vehicle_status_s *status_local, const struct safety_s
|
||||
mavlink_log_info(mavlink_fd, "[cmd] home: %.7f, %.7f, %.2f", home->lat, home->lon, (double)home->alt);
|
||||
|
||||
/* announce new home position */
|
||||
if (*home_pub > 0) {
|
||||
if (*home_pub != nullptr) {
|
||||
orb_publish(ORB_ID(home_position), *home_pub, home);
|
||||
|
||||
} else {
|
||||
@@ -796,7 +796,7 @@ static void commander_set_home_position(orb_advert_t &homePub, home_position_s &
|
||||
mavlink_log_info(mavlink_fd, "home: %.7f, %.7f, %.2f", home.lat, home.lon, (double)home.alt);
|
||||
|
||||
/* announce new home position */
|
||||
if (homePub > 0) {
|
||||
if (homePub != nullptr) {
|
||||
orb_publish(ORB_ID(home_position), homePub, &home);
|
||||
|
||||
} else {
|
||||
@@ -934,7 +934,7 @@ int commander_thread_main(int argc, char *argv[])
|
||||
/* publish initial state */
|
||||
status_pub = orb_advertise(ORB_ID(vehicle_status), &status);
|
||||
|
||||
if (status_pub == 0) {
|
||||
if (status_pub == nullptr) {
|
||||
warnx("ERROR: orb_advertise for topic vehicle_status failed (uorb app running?).\n");
|
||||
warnx("exiting.");
|
||||
px4_task_exit(ERROR);
|
||||
@@ -952,12 +952,12 @@ int commander_thread_main(int argc, char *argv[])
|
||||
armed_pub = orb_advertise(ORB_ID(actuator_armed), &armed);
|
||||
|
||||
/* home position */
|
||||
orb_advert_t home_pub = 0;
|
||||
orb_advert_t home_pub = nullptr;
|
||||
struct home_position_s home;
|
||||
memset(&home, 0, sizeof(home));
|
||||
|
||||
/* init mission state, do it here to allow navigator to use stored mission even if mavlink failed to start */
|
||||
orb_advert_t mission_pub = 0;
|
||||
orb_advert_t mission_pub = nullptr;
|
||||
mission_s mission;
|
||||
|
||||
if (dm_read(DM_KEY_MISSION_STATE, 0, &mission, sizeof(mission_s)) == sizeof(mission_s)) {
|
||||
|
||||
@@ -482,7 +482,7 @@ static transition_result_t disable_publication(const int mavlink_fd)
|
||||
/**
|
||||
* Transition from one hil state to another
|
||||
*/
|
||||
transition_result_t hil_state_transition(hil_state_t new_state, int status_pub, struct vehicle_status_s *current_status, const int mavlink_fd)
|
||||
transition_result_t hil_state_transition(hil_state_t new_state, orb_advert_t status_pub, struct vehicle_status_s *current_status, const int mavlink_fd)
|
||||
{
|
||||
transition_result_t ret = TRANSITION_DENIED;
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ transition_result_t arming_state_transition(struct vehicle_status_s *current_sta
|
||||
|
||||
transition_result_t main_state_transition(struct vehicle_status_s *current_state, main_state_t new_main_state);
|
||||
|
||||
transition_result_t hil_state_transition(hil_state_t new_state, int status_pub, struct vehicle_status_s *current_state, const int mavlink_fd);
|
||||
transition_result_t hil_state_transition(hil_state_t new_state, orb_advert_t status_pub, struct vehicle_status_s *current_state, const int mavlink_fd);
|
||||
|
||||
bool set_nav_state(struct vehicle_status_s *status, const bool data_link_loss_enabled, const bool mission_finished, const bool stay_in_failsafe);
|
||||
|
||||
|
||||
@@ -129,11 +129,11 @@ AttitudePositionEstimatorEKF::AttitudePositionEstimatorEKF() :
|
||||
_armedSub(-1),
|
||||
|
||||
/* publications */
|
||||
_att_pub(0),
|
||||
_global_pos_pub(0),
|
||||
_local_pos_pub(0),
|
||||
_estimator_status_pub(0),
|
||||
_wind_pub(0),
|
||||
_att_pub(nullptr),
|
||||
_global_pos_pub(nullptr),
|
||||
_local_pos_pub(nullptr),
|
||||
_estimator_status_pub(nullptr),
|
||||
_wind_pub(nullptr),
|
||||
|
||||
_att({}),
|
||||
_gyro({}),
|
||||
@@ -469,7 +469,7 @@ int AttitudePositionEstimatorEKF::check_filter_state()
|
||||
|
||||
|
||||
|
||||
if (_estimator_status_pub > 0) {
|
||||
if (_estimator_status_pub != nullptr) {
|
||||
orb_publish(ORB_ID(estimator_status), _estimator_status_pub, &rep);
|
||||
|
||||
} else {
|
||||
@@ -797,7 +797,7 @@ void AttitudePositionEstimatorEKF::publishAttitude()
|
||||
_att.rate_offsets[2] = _ekf->states[12] / _ekf->dtIMUfilt;
|
||||
|
||||
/* lazily publish the attitude only once available */
|
||||
if (_att_pub > 0) {
|
||||
if (_att_pub != nullptr) {
|
||||
/* publish the attitude setpoint */
|
||||
orb_publish(ORB_ID(vehicle_attitude), _att_pub, &_att);
|
||||
|
||||
@@ -830,7 +830,7 @@ void AttitudePositionEstimatorEKF::publishLocalPosition()
|
||||
_local_pos.yaw = _att.yaw;
|
||||
|
||||
/* lazily publish the local position only once available */
|
||||
if (_local_pos_pub > 0) {
|
||||
if (_local_pos_pub != nullptr) {
|
||||
/* publish the attitude setpoint */
|
||||
orb_publish(ORB_ID(vehicle_local_position), _local_pos_pub, &_local_pos);
|
||||
|
||||
@@ -878,7 +878,7 @@ void AttitudePositionEstimatorEKF::publishGlobalPosition()
|
||||
_global_pos.epv = _gps.epv;
|
||||
|
||||
/* lazily publish the global position only once available */
|
||||
if (_global_pos_pub > 0) {
|
||||
if (_global_pos_pub != nullptr) {
|
||||
/* publish the global position */
|
||||
orb_publish(ORB_ID(vehicle_global_position), _global_pos_pub, &_global_pos);
|
||||
|
||||
@@ -900,7 +900,7 @@ void AttitudePositionEstimatorEKF::publishWindEstimate()
|
||||
_wind.covariance_east = _ekf->P[15][15];
|
||||
|
||||
/* lazily publish the wind estimate only once available */
|
||||
if (_wind_pub > 0) {
|
||||
if (_wind_pub != nullptr) {
|
||||
/* publish the wind estimate */
|
||||
orb_publish(ORB_ID(wind_estimate), _wind_pub, &_wind);
|
||||
|
||||
|
||||
@@ -337,10 +337,10 @@ FixedwingAttitudeControl::FixedwingAttitudeControl() :
|
||||
_vehicle_status_sub(-1),
|
||||
|
||||
/* publications */
|
||||
_rate_sp_pub(0),
|
||||
_attitude_sp_pub(0),
|
||||
_actuators_0_pub(0),
|
||||
_actuators_2_pub(0),
|
||||
_rate_sp_pub(nullptr),
|
||||
_attitude_sp_pub(nullptr),
|
||||
_actuators_0_pub(nullptr),
|
||||
_actuators_2_pub(nullptr),
|
||||
|
||||
_rates_sp_id(0),
|
||||
_actuators_id(0),
|
||||
@@ -907,11 +907,11 @@ FixedwingAttitudeControl::task_main()
|
||||
att_sp.thrust = throttle_sp;
|
||||
|
||||
/* lazily publish the setpoint only once available */
|
||||
if (_attitude_sp_pub > 0 && !_vehicle_status.is_rotary_wing) {
|
||||
if (_attitude_sp_pub != nullptr && !_vehicle_status.is_rotary_wing) {
|
||||
/* publish the attitude setpoint */
|
||||
orb_publish(ORB_ID(vehicle_attitude_setpoint), _attitude_sp_pub, &att_sp);
|
||||
|
||||
} else if (_attitude_sp_pub < 0 && !_vehicle_status.is_rotary_wing) {
|
||||
} else if (_attitude_sp_pub != nullptr && !_vehicle_status.is_rotary_wing) {
|
||||
/* advertise and publish */
|
||||
_attitude_sp_pub = orb_advertise(ORB_ID(vehicle_attitude_setpoint), &att_sp);
|
||||
}
|
||||
@@ -1045,7 +1045,7 @@ FixedwingAttitudeControl::task_main()
|
||||
|
||||
_rates_sp.timestamp = hrt_absolute_time();
|
||||
|
||||
if (_rate_sp_pub > 0) {
|
||||
if (_rate_sp_pub != nullptr) {
|
||||
/* publish the attitude rates setpoint */
|
||||
orb_publish(_rates_sp_id, _rate_sp_pub, &_rates_sp);
|
||||
} else if (_rates_sp_id) {
|
||||
@@ -1078,13 +1078,13 @@ FixedwingAttitudeControl::task_main()
|
||||
_vcontrol_mode.flag_control_manual_enabled)
|
||||
{
|
||||
/* publish the actuator controls */
|
||||
if (_actuators_0_pub > 0) {
|
||||
if (_actuators_0_pub != nullptr) {
|
||||
orb_publish(_actuators_id, _actuators_0_pub, &_actuators);
|
||||
} else if (_actuators_id) {
|
||||
_actuators_0_pub= orb_advertise(_actuators_id, &_actuators);
|
||||
}
|
||||
|
||||
if (_actuators_2_pub > 0) {
|
||||
if (_actuators_2_pub != nullptr) {
|
||||
/* publish the actuator controls*/
|
||||
orb_publish(ORB_ID(actuator_controls_2), _actuators_2_pub, &_actuators_airframe);
|
||||
|
||||
|
||||
@@ -434,9 +434,9 @@ FixedwingPositionControl::FixedwingPositionControl() :
|
||||
_sensor_combined_sub(-1),
|
||||
|
||||
/* publications */
|
||||
_attitude_sp_pub(0),
|
||||
_tecs_status_pub(0),
|
||||
_nav_capabilities_pub(0),
|
||||
_attitude_sp_pub(nullptr),
|
||||
_tecs_status_pub(nullptr),
|
||||
_nav_capabilities_pub(nullptr),
|
||||
|
||||
/* states */
|
||||
_att(),
|
||||
@@ -855,7 +855,7 @@ FixedwingPositionControl::calculate_gndspeed_undershoot(const math::Vector<2> &c
|
||||
|
||||
void FixedwingPositionControl::navigation_capabilities_publish()
|
||||
{
|
||||
if (_nav_capabilities_pub > 0) {
|
||||
if (_nav_capabilities_pub != nullptr) {
|
||||
orb_publish(ORB_ID(navigation_capabilities), _nav_capabilities_pub, &_nav_capabilities);
|
||||
} else {
|
||||
_nav_capabilities_pub = orb_advertise(ORB_ID(navigation_capabilities), &_nav_capabilities);
|
||||
@@ -1463,7 +1463,7 @@ FixedwingPositionControl::task_main()
|
||||
_att_sp.timestamp = hrt_absolute_time();
|
||||
|
||||
/* lazily publish the setpoint only once available */
|
||||
if (_attitude_sp_pub > 0) {
|
||||
if (_attitude_sp_pub != nullptr) {
|
||||
/* publish the attitude setpoint */
|
||||
orb_publish(ORB_ID(vehicle_attitude_setpoint), _attitude_sp_pub, &_att_sp);
|
||||
|
||||
@@ -1607,7 +1607,7 @@ void FixedwingPositionControl::tecs_update_pitch_throttle(float alt_sp, float v_
|
||||
t.energyDistributionRateSp = s.ptch;
|
||||
t.energyDistributionRate = s.iptch;
|
||||
|
||||
if (_tecs_status_pub > 0) {
|
||||
if (_tecs_status_pub != nullptr) {
|
||||
orb_publish(ORB_ID(tecs_status), _tecs_status_pub, &t);
|
||||
} else {
|
||||
_tecs_status_pub = orb_advertise(ORB_ID(tecs_status), &t);
|
||||
|
||||
@@ -72,7 +72,7 @@ void LandDetector::start()
|
||||
// advertise the first land detected uORB
|
||||
_landDetected.timestamp = hrt_absolute_time();
|
||||
_landDetected.landed = false;
|
||||
_landDetectedPub = orb_advertise(ORB_ID(vehicle_land_detected), &_landDetected);
|
||||
_landDetectedPub = (uintptr_t)orb_advertise(ORB_ID(vehicle_land_detected), &_landDetected);
|
||||
|
||||
// initialize land detection algorithm
|
||||
initialize();
|
||||
@@ -91,7 +91,7 @@ void LandDetector::start()
|
||||
_landDetected.landed = landDetected;
|
||||
|
||||
// publish the land detected broadcast
|
||||
orb_publish(ORB_ID(vehicle_land_detected), _landDetectedPub, &_landDetected);
|
||||
orb_publish(ORB_ID(vehicle_land_detected), (orb_advert_t)_landDetectedPub, &_landDetected);
|
||||
}
|
||||
|
||||
// limit loop rate
|
||||
|
||||
@@ -93,7 +93,7 @@ protected:
|
||||
before triggering a land */
|
||||
|
||||
protected:
|
||||
orb_advert_t _landDetectedPub; /**< publisher for position in local frame */
|
||||
uintptr_t _landDetectedPub; /**< publisher for position in local frame */
|
||||
struct vehicle_land_detected_s _landDetected; /**< local vehicle position */
|
||||
|
||||
private:
|
||||
|
||||
@@ -149,7 +149,7 @@ MavlinkMissionManager::update_active_mission(int dataman_id, unsigned count, int
|
||||
_current_seq = seq;
|
||||
|
||||
/* mission state saved successfully, publish offboard_mission topic */
|
||||
if (_offboard_mission_pub == 0) {
|
||||
if (_offboard_mission_pub == nullptr) {
|
||||
_offboard_mission_pub = orb_advertise(ORB_ID(offboard_mission), &mission);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -162,7 +162,7 @@ MavlinkParametersManager::handle_message(const mavlink_message_t *msg)
|
||||
}
|
||||
_rc_param_map.timestamp = hrt_absolute_time();
|
||||
|
||||
if (_rc_param_map_pub == 0) {
|
||||
if (_rc_param_map_pub == nullptr) {
|
||||
_rc_param_map_pub = orb_advertise(ORB_ID(rc_parameter_map), &_rc_param_map);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -95,34 +95,34 @@ MavlinkReceiver::MavlinkReceiver(Mavlink *parent) :
|
||||
hil_local_pos{},
|
||||
hil_land_detector{},
|
||||
_control_mode{},
|
||||
_global_pos_pub(0),
|
||||
_local_pos_pub(0),
|
||||
_attitude_pub(0),
|
||||
_gps_pub(0),
|
||||
_sensors_pub(0),
|
||||
_gyro_pub(0),
|
||||
_accel_pub(0),
|
||||
_mag_pub(0),
|
||||
_baro_pub(0),
|
||||
_airspeed_pub(0),
|
||||
_battery_pub(0),
|
||||
_cmd_pub(0),
|
||||
_flow_pub(0),
|
||||
_distance_sensor_pub(0),
|
||||
_offboard_control_mode_pub(0),
|
||||
_actuator_controls_pub(0),
|
||||
_global_vel_sp_pub(0),
|
||||
_att_sp_pub(0),
|
||||
_rates_sp_pub(0),
|
||||
_force_sp_pub(0),
|
||||
_pos_sp_triplet_pub(0),
|
||||
_vicon_position_pub(0),
|
||||
_vision_position_pub(0),
|
||||
_telemetry_status_pub(0),
|
||||
_rc_pub(0),
|
||||
_manual_pub(0),
|
||||
_land_detector_pub(0),
|
||||
_time_offset_pub(0),
|
||||
_global_pos_pub(nullptr),
|
||||
_local_pos_pub(nullptr),
|
||||
_attitude_pub(nullptr),
|
||||
_gps_pub(nullptr),
|
||||
_sensors_pub(nullptr),
|
||||
_gyro_pub(nullptr),
|
||||
_accel_pub(nullptr),
|
||||
_mag_pub(nullptr),
|
||||
_baro_pub(nullptr),
|
||||
_airspeed_pub(nullptr),
|
||||
_battery_pub(nullptr),
|
||||
_cmd_pub(nullptr),
|
||||
_flow_pub(nullptr),
|
||||
_distance_sensor_pub(nullptr),
|
||||
_offboard_control_mode_pub(nullptr),
|
||||
_actuator_controls_pub(nullptr),
|
||||
_global_vel_sp_pub(nullptr),
|
||||
_att_sp_pub(nullptr),
|
||||
_rates_sp_pub(nullptr),
|
||||
_force_sp_pub(nullptr),
|
||||
_pos_sp_triplet_pub(nullptr),
|
||||
_vicon_position_pub(nullptr),
|
||||
_vision_position_pub(nullptr),
|
||||
_telemetry_status_pub(nullptr),
|
||||
_rc_pub(nullptr),
|
||||
_manual_pub(nullptr),
|
||||
_land_detector_pub(nullptr),
|
||||
_time_offset_pub(nullptr),
|
||||
_control_mode_sub(orb_subscribe(ORB_ID(vehicle_control_mode))),
|
||||
_hil_frames(0),
|
||||
_old_timestamp(0),
|
||||
@@ -314,7 +314,7 @@ MavlinkReceiver::handle_message_command_long(mavlink_message_t *msg)
|
||||
vcmd.source_component = msg->compid;
|
||||
vcmd.confirmation = cmd_mavlink.confirmation;
|
||||
|
||||
if (_cmd_pub == 0) {
|
||||
if (_cmd_pub == nullptr) {
|
||||
_cmd_pub = orb_advertise(ORB_ID(vehicle_command), &vcmd);
|
||||
|
||||
} else {
|
||||
@@ -370,7 +370,7 @@ MavlinkReceiver::handle_message_command_int(mavlink_message_t *msg)
|
||||
vcmd.source_system = msg->sysid;
|
||||
vcmd.source_component = msg->compid;
|
||||
|
||||
if (_cmd_pub == 0) {
|
||||
if (_cmd_pub == nullptr) {
|
||||
_cmd_pub = orb_advertise(ORB_ID(vehicle_command), &vcmd);
|
||||
|
||||
} else {
|
||||
@@ -410,7 +410,7 @@ MavlinkReceiver::handle_message_optical_flow_rad(mavlink_message_t *msg)
|
||||
float zeroval = 0.0f;
|
||||
rotate_3f(flow_rot, f.pixel_flow_x_integral, f.pixel_flow_y_integral, zeroval);
|
||||
|
||||
if (_flow_pub == 0) {
|
||||
if (_flow_pub == nullptr) {
|
||||
_flow_pub = orb_advertise(ORB_ID(optical_flow), &f);
|
||||
|
||||
} else {
|
||||
@@ -430,7 +430,7 @@ MavlinkReceiver::handle_message_optical_flow_rad(mavlink_message_t *msg)
|
||||
d.orientation = 8;
|
||||
d.covariance = 0.0;
|
||||
|
||||
if (_distance_sensor_pub < 0) {
|
||||
if (_distance_sensor_pub == nullptr) {
|
||||
_distance_sensor_pub = orb_advertise_multi(ORB_ID(distance_sensor), &d,
|
||||
&_orb_class_instance, ORB_PRIO_HIGH);
|
||||
} else {
|
||||
@@ -461,7 +461,7 @@ MavlinkReceiver::handle_message_hil_optical_flow(mavlink_message_t *msg)
|
||||
f.sensor_id = flow.sensor_id;
|
||||
f.gyro_temperature = flow.temperature;
|
||||
|
||||
if (_flow_pub == 0) {
|
||||
if (_flow_pub == nullptr) {
|
||||
_flow_pub = orb_advertise(ORB_ID(optical_flow), &f);
|
||||
|
||||
} else {
|
||||
@@ -481,7 +481,7 @@ MavlinkReceiver::handle_message_hil_optical_flow(mavlink_message_t *msg)
|
||||
d.orientation = 8;
|
||||
d.covariance = 0.0;
|
||||
|
||||
if (_distance_sensor_pub < 0) {
|
||||
if (_distance_sensor_pub == nullptr) {
|
||||
_distance_sensor_pub = orb_advertise_multi(ORB_ID(distance_sensor), &d,
|
||||
&_orb_class_instance, ORB_PRIO_HIGH);
|
||||
} else {
|
||||
@@ -515,7 +515,7 @@ MavlinkReceiver::handle_message_set_mode(mavlink_message_t *msg)
|
||||
vcmd.source_component = msg->compid;
|
||||
vcmd.confirmation = 1;
|
||||
|
||||
if (_cmd_pub == 0) {
|
||||
if (_cmd_pub == nullptr) {
|
||||
_cmd_pub = orb_advertise(ORB_ID(vehicle_command), &vcmd);
|
||||
|
||||
} else {
|
||||
@@ -544,7 +544,7 @@ MavlinkReceiver::handle_message_distance_sensor(mavlink_message_t *msg)
|
||||
|
||||
/// TODO Add sensor rotation according to MAV_SENSOR_ORIENTATION enum
|
||||
|
||||
if (_distance_sensor_pub < 0) {
|
||||
if (_distance_sensor_pub == nullptr) {
|
||||
_distance_sensor_pub = orb_advertise_multi(ORB_ID(distance_sensor), &d,
|
||||
&_orb_class_instance, ORB_PRIO_HIGH);
|
||||
|
||||
@@ -570,7 +570,7 @@ MavlinkReceiver::handle_message_vicon_position_estimate(mavlink_message_t *msg)
|
||||
vicon_position.pitch = pos.pitch;
|
||||
vicon_position.yaw = pos.yaw;
|
||||
|
||||
if (_vicon_position_pub == 0) {
|
||||
if (_vicon_position_pub == nullptr) {
|
||||
_vicon_position_pub = orb_advertise(ORB_ID(vehicle_vicon_position), &vicon_position);
|
||||
|
||||
} else {
|
||||
@@ -605,7 +605,7 @@ MavlinkReceiver::handle_message_set_position_target_local_ned(mavlink_message_t
|
||||
|
||||
offboard_control_mode.timestamp = hrt_absolute_time();
|
||||
|
||||
if (_offboard_control_mode_pub == 0) {
|
||||
if (_offboard_control_mode_pub == nullptr) {
|
||||
_offboard_control_mode_pub = orb_advertise(ORB_ID(offboard_control_mode), &offboard_control_mode);
|
||||
|
||||
} else {
|
||||
@@ -630,7 +630,7 @@ MavlinkReceiver::handle_message_set_position_target_local_ned(mavlink_message_t
|
||||
force_sp.y = set_position_target_local_ned.afy;
|
||||
force_sp.z = set_position_target_local_ned.afz;
|
||||
//XXX: yaw
|
||||
if (_force_sp_pub == 0) {
|
||||
if (_force_sp_pub == nullptr) {
|
||||
_force_sp_pub = orb_advertise(ORB_ID(vehicle_force_setpoint), &force_sp);
|
||||
} else {
|
||||
orb_publish(ORB_ID(vehicle_force_setpoint), _force_sp_pub, &force_sp);
|
||||
@@ -697,7 +697,7 @@ MavlinkReceiver::handle_message_set_position_target_local_ned(mavlink_message_t
|
||||
//XXX handle global pos setpoints (different MAV frames)
|
||||
|
||||
|
||||
if (_pos_sp_triplet_pub == 0) {
|
||||
if (_pos_sp_triplet_pub == nullptr) {
|
||||
_pos_sp_triplet_pub = orb_advertise(ORB_ID(position_setpoint_triplet),
|
||||
&pos_sp_triplet);
|
||||
} else {
|
||||
@@ -740,7 +740,7 @@ MavlinkReceiver::handle_message_set_actuator_control_target(mavlink_message_t *m
|
||||
|
||||
offboard_control_mode.timestamp = hrt_absolute_time();
|
||||
|
||||
if (_offboard_control_mode_pub == 0) {
|
||||
if (_offboard_control_mode_pub == nullptr) {
|
||||
_offboard_control_mode_pub = orb_advertise(ORB_ID(offboard_control_mode), &offboard_control_mode);
|
||||
} else {
|
||||
orb_publish(ORB_ID(offboard_control_mode), _offboard_control_mode_pub, &offboard_control_mode);
|
||||
@@ -763,7 +763,7 @@ MavlinkReceiver::handle_message_set_actuator_control_target(mavlink_message_t *m
|
||||
actuator_controls.control[i] = set_actuator_control_target.controls[i];
|
||||
}
|
||||
|
||||
if (_actuator_controls_pub == 0) {
|
||||
if (_actuator_controls_pub == nullptr) {
|
||||
_actuator_controls_pub = orb_advertise(ORB_ID(actuator_controls_0), &actuator_controls);
|
||||
} else {
|
||||
orb_publish(ORB_ID(actuator_controls_0), _actuator_controls_pub, &actuator_controls);
|
||||
@@ -804,7 +804,7 @@ MavlinkReceiver::handle_message_vision_position_estimate(mavlink_message_t *msg)
|
||||
vision_position.q[2] = q(2);
|
||||
vision_position.q[3] = q(3);
|
||||
|
||||
if (_vision_position_pub == 0) {
|
||||
if (_vision_position_pub == nullptr) {
|
||||
_vision_position_pub = orb_advertise(ORB_ID(vision_position_estimate), &vision_position);
|
||||
|
||||
} else {
|
||||
@@ -857,7 +857,7 @@ MavlinkReceiver::handle_message_set_attitude_target(mavlink_message_t *msg)
|
||||
|
||||
_offboard_control_mode.timestamp = hrt_absolute_time();
|
||||
|
||||
if (_offboard_control_mode_pub == 0) {
|
||||
if (_offboard_control_mode_pub == nullptr) {
|
||||
_offboard_control_mode_pub = orb_advertise(ORB_ID(offboard_control_mode), &_offboard_control_mode);
|
||||
|
||||
} else {
|
||||
@@ -892,7 +892,7 @@ MavlinkReceiver::handle_message_set_attitude_target(mavlink_message_t *msg)
|
||||
_att_sp.thrust = set_attitude_target.thrust;
|
||||
}
|
||||
|
||||
if (_att_sp_pub == 0) {
|
||||
if (_att_sp_pub == nullptr) {
|
||||
_att_sp_pub = orb_advertise(ORB_ID(vehicle_attitude_setpoint), &_att_sp);
|
||||
} else {
|
||||
orb_publish(ORB_ID(vehicle_attitude_setpoint), _att_sp_pub, &_att_sp);
|
||||
@@ -912,7 +912,7 @@ MavlinkReceiver::handle_message_set_attitude_target(mavlink_message_t *msg)
|
||||
_rates_sp.thrust = set_attitude_target.thrust;
|
||||
}
|
||||
|
||||
if (_att_sp_pub == 0) {
|
||||
if (_att_sp_pub == nullptr) {
|
||||
_rates_sp_pub = orb_advertise(ORB_ID(vehicle_rates_setpoint), &_rates_sp);
|
||||
} else {
|
||||
orb_publish(ORB_ID(vehicle_rates_setpoint), _rates_sp_pub, &_rates_sp);
|
||||
@@ -948,7 +948,7 @@ MavlinkReceiver::handle_message_radio_status(mavlink_message_t *msg)
|
||||
tstatus.system_id = msg->sysid;
|
||||
tstatus.component_id = msg->compid;
|
||||
|
||||
if (_telemetry_status_pub == 0) {
|
||||
if (_telemetry_status_pub == nullptr) {
|
||||
_telemetry_status_pub = orb_advertise(telemetry_status_orb_id[_mavlink->get_channel()], &tstatus);
|
||||
|
||||
} else {
|
||||
@@ -974,7 +974,7 @@ MavlinkReceiver::handle_message_manual_control(mavlink_message_t *msg)
|
||||
|
||||
// warnx("pitch: %.2f, roll: %.2f, yaw: %.2f, throttle: %.2f", (double)manual.x, (double)manual.y, (double)manual.r, (double)manual.z);
|
||||
|
||||
if (_manual_pub == 0) {
|
||||
if (_manual_pub == nullptr) {
|
||||
_manual_pub = orb_advertise(ORB_ID(manual_control_setpoint), &manual);
|
||||
|
||||
} else {
|
||||
@@ -1001,7 +1001,7 @@ MavlinkReceiver::handle_message_heartbeat(mavlink_message_t *msg)
|
||||
tstatus.timestamp = hrt_absolute_time();
|
||||
tstatus.heartbeat_time = tstatus.timestamp;
|
||||
|
||||
if (_telemetry_status_pub == 0) {
|
||||
if (_telemetry_status_pub == nullptr) {
|
||||
_telemetry_status_pub = orb_advertise(telemetry_status_orb_id[_mavlink->get_channel()], &tstatus);
|
||||
|
||||
} else {
|
||||
@@ -1105,7 +1105,7 @@ MavlinkReceiver::handle_message_timesync(mavlink_message_t *msg)
|
||||
|
||||
tsync_offset.offset_ns = _time_offset ;
|
||||
|
||||
if (_time_offset_pub == 0) {
|
||||
if (_time_offset_pub == nullptr) {
|
||||
_time_offset_pub = orb_advertise(ORB_ID(time_offset), &tsync_offset);
|
||||
|
||||
} else {
|
||||
@@ -1135,7 +1135,7 @@ MavlinkReceiver::handle_message_hil_sensor(mavlink_message_t *msg)
|
||||
airspeed.indicated_airspeed_m_s = ias;
|
||||
airspeed.true_airspeed_m_s = tas;
|
||||
|
||||
if (_airspeed_pub == 0) {
|
||||
if (_airspeed_pub == nullptr) {
|
||||
_airspeed_pub = orb_advertise(ORB_ID(airspeed), &airspeed);
|
||||
|
||||
} else {
|
||||
@@ -1157,7 +1157,7 @@ MavlinkReceiver::handle_message_hil_sensor(mavlink_message_t *msg)
|
||||
gyro.z = imu.zgyro;
|
||||
gyro.temperature = imu.temperature;
|
||||
|
||||
if (_gyro_pub == 0) {
|
||||
if (_gyro_pub == nullptr) {
|
||||
_gyro_pub = orb_advertise(ORB_ID(sensor_gyro), &gyro);
|
||||
|
||||
} else {
|
||||
@@ -1179,7 +1179,7 @@ MavlinkReceiver::handle_message_hil_sensor(mavlink_message_t *msg)
|
||||
accel.z = imu.zacc;
|
||||
accel.temperature = imu.temperature;
|
||||
|
||||
if (_accel_pub == 0) {
|
||||
if (_accel_pub == nullptr) {
|
||||
_accel_pub = orb_advertise(ORB_ID(sensor_accel), &accel);
|
||||
|
||||
} else {
|
||||
@@ -1200,7 +1200,7 @@ MavlinkReceiver::handle_message_hil_sensor(mavlink_message_t *msg)
|
||||
mag.y = imu.ymag;
|
||||
mag.z = imu.zmag;
|
||||
|
||||
if (_mag_pub == 0) {
|
||||
if (_mag_pub == nullptr) {
|
||||
/* publish to the first mag topic */
|
||||
_mag_pub = orb_advertise(ORB_ID(sensor_mag), &mag);
|
||||
|
||||
@@ -1219,7 +1219,7 @@ MavlinkReceiver::handle_message_hil_sensor(mavlink_message_t *msg)
|
||||
baro.altitude = imu.pressure_alt;
|
||||
baro.temperature = imu.temperature;
|
||||
|
||||
if (_baro_pub == 0) {
|
||||
if (_baro_pub == nullptr) {
|
||||
_baro_pub = orb_advertise(ORB_ID(sensor_baro), &baro);
|
||||
|
||||
} else {
|
||||
@@ -1275,7 +1275,7 @@ MavlinkReceiver::handle_message_hil_sensor(mavlink_message_t *msg)
|
||||
hil_sensors.differential_pressure_timestamp = timestamp;
|
||||
|
||||
/* publish combined sensor topic */
|
||||
if (_sensors_pub == 0) {
|
||||
if (_sensors_pub == nullptr) {
|
||||
_sensors_pub = orb_advertise(ORB_ID(sensor_combined), &hil_sensors);
|
||||
|
||||
} else {
|
||||
@@ -1294,7 +1294,7 @@ MavlinkReceiver::handle_message_hil_sensor(mavlink_message_t *msg)
|
||||
hil_battery_status.current_a = 10.0f;
|
||||
hil_battery_status.discharged_mah = -1.0f;
|
||||
|
||||
if (_battery_pub == 0) {
|
||||
if (_battery_pub == nullptr) {
|
||||
_battery_pub = orb_advertise(ORB_ID(battery_status), &hil_battery_status);
|
||||
|
||||
} else {
|
||||
@@ -1348,7 +1348,7 @@ MavlinkReceiver::handle_message_hil_gps(mavlink_message_t *msg)
|
||||
hil_gps.fix_type = gps.fix_type;
|
||||
hil_gps.satellites_used = gps.satellites_visible; //TODO: rename mavlink_hil_gps_t sats visible to used?
|
||||
|
||||
if (_gps_pub == 0) {
|
||||
if (_gps_pub == nullptr) {
|
||||
_gps_pub = orb_advertise(ORB_ID(vehicle_gps_position), &hil_gps);
|
||||
|
||||
} else {
|
||||
@@ -1373,7 +1373,7 @@ MavlinkReceiver::handle_message_hil_state_quaternion(mavlink_message_t *msg)
|
||||
airspeed.indicated_airspeed_m_s = hil_state.ind_airspeed * 1e-2f;
|
||||
airspeed.true_airspeed_m_s = hil_state.true_airspeed * 1e-2f;
|
||||
|
||||
if (_airspeed_pub == 0) {
|
||||
if (_airspeed_pub == nullptr) {
|
||||
_airspeed_pub = orb_advertise(ORB_ID(airspeed), &airspeed);
|
||||
|
||||
} else {
|
||||
@@ -1406,7 +1406,7 @@ MavlinkReceiver::handle_message_hil_state_quaternion(mavlink_message_t *msg)
|
||||
hil_attitude.pitchspeed = hil_state.pitchspeed;
|
||||
hil_attitude.yawspeed = hil_state.yawspeed;
|
||||
|
||||
if (_attitude_pub == 0) {
|
||||
if (_attitude_pub == nullptr) {
|
||||
_attitude_pub = orb_advertise(ORB_ID(vehicle_attitude), &hil_attitude);
|
||||
|
||||
} else {
|
||||
@@ -1430,7 +1430,7 @@ MavlinkReceiver::handle_message_hil_state_quaternion(mavlink_message_t *msg)
|
||||
hil_global_pos.eph = 2.0f;
|
||||
hil_global_pos.epv = 4.0f;
|
||||
|
||||
if (_global_pos_pub == 0) {
|
||||
if (_global_pos_pub == nullptr) {
|
||||
_global_pos_pub = orb_advertise(ORB_ID(vehicle_global_position), &hil_global_pos);
|
||||
|
||||
} else {
|
||||
@@ -1471,7 +1471,7 @@ MavlinkReceiver::handle_message_hil_state_quaternion(mavlink_message_t *msg)
|
||||
hil_local_pos.xy_global = true;
|
||||
hil_local_pos.z_global = true;
|
||||
|
||||
if (_local_pos_pub == 0) {
|
||||
if (_local_pos_pub == nullptr) {
|
||||
_local_pos_pub = orb_advertise(ORB_ID(vehicle_local_position), &hil_local_pos);
|
||||
|
||||
} else {
|
||||
@@ -1486,7 +1486,7 @@ MavlinkReceiver::handle_message_hil_state_quaternion(mavlink_message_t *msg)
|
||||
hil_land_detector.landed = landed;
|
||||
hil_land_detector.timestamp = hrt_absolute_time();
|
||||
|
||||
if (_land_detector_pub == 0) {
|
||||
if (_land_detector_pub == nullptr) {
|
||||
_land_detector_pub = orb_advertise(ORB_ID(vehicle_land_detected), &hil_land_detector);
|
||||
|
||||
} else {
|
||||
@@ -1509,7 +1509,7 @@ MavlinkReceiver::handle_message_hil_state_quaternion(mavlink_message_t *msg)
|
||||
accel.z = hil_state.zacc;
|
||||
accel.temperature = 25.0f;
|
||||
|
||||
if (_accel_pub == 0) {
|
||||
if (_accel_pub == nullptr) {
|
||||
_accel_pub = orb_advertise(ORB_ID(sensor_accel), &accel);
|
||||
|
||||
} else {
|
||||
@@ -1528,7 +1528,7 @@ MavlinkReceiver::handle_message_hil_state_quaternion(mavlink_message_t *msg)
|
||||
hil_battery_status.current_a = 10.0f;
|
||||
hil_battery_status.discharged_mah = -1.0f;
|
||||
|
||||
if (_battery_pub == 0) {
|
||||
if (_battery_pub == nullptr) {
|
||||
_battery_pub = orb_advertise(ORB_ID(battery_status), &hil_battery_status);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -314,10 +314,10 @@ MulticopterAttitudeControl::MulticopterAttitudeControl() :
|
||||
_vehicle_status_sub(-1),
|
||||
|
||||
/* publications */
|
||||
_att_sp_pub(0),
|
||||
_v_rates_sp_pub(0),
|
||||
_actuators_0_pub(0),
|
||||
_controller_status_pub(0),
|
||||
_att_sp_pub(nullptr),
|
||||
_v_rates_sp_pub(nullptr),
|
||||
_actuators_0_pub(nullptr),
|
||||
_controller_status_pub(nullptr),
|
||||
_rates_sp_id(0),
|
||||
_actuators_id(0),
|
||||
|
||||
@@ -822,7 +822,7 @@ MulticopterAttitudeControl::task_main()
|
||||
_v_rates_sp.thrust = _thrust_sp;
|
||||
_v_rates_sp.timestamp = hrt_absolute_time();
|
||||
|
||||
if (_v_rates_sp_pub > 0) {
|
||||
if (_v_rates_sp_pub != nullptr) {
|
||||
orb_publish(_rates_sp_id, _v_rates_sp_pub, &_v_rates_sp);
|
||||
|
||||
} else if (_rates_sp_id) {
|
||||
@@ -843,7 +843,7 @@ MulticopterAttitudeControl::task_main()
|
||||
_v_rates_sp.thrust = _thrust_sp;
|
||||
_v_rates_sp.timestamp = hrt_absolute_time();
|
||||
|
||||
if (_v_rates_sp_pub > 0) {
|
||||
if (_v_rates_sp_pub != nullptr) {
|
||||
orb_publish(_rates_sp_id, _v_rates_sp_pub, &_v_rates_sp);
|
||||
|
||||
} else if (_rates_sp_id) {
|
||||
@@ -877,7 +877,7 @@ MulticopterAttitudeControl::task_main()
|
||||
_controller_status.timestamp = hrt_absolute_time();
|
||||
|
||||
if (!_actuators_0_circuit_breaker_enabled) {
|
||||
if (_actuators_0_pub > 0) {
|
||||
if (_actuators_0_pub != nullptr) {
|
||||
orb_publish(_actuators_id, _actuators_0_pub, &_actuators);
|
||||
perf_end(_controller_latency_perf);
|
||||
|
||||
@@ -888,7 +888,7 @@ MulticopterAttitudeControl::task_main()
|
||||
}
|
||||
|
||||
/* publish controller status */
|
||||
if(_controller_status_pub > 0) {
|
||||
if(_controller_status_pub != nullptr) {
|
||||
orb_publish(ORB_ID(mc_att_ctrl_status),_controller_status_pub, &_controller_status);
|
||||
} else {
|
||||
_controller_status_pub = orb_advertise(ORB_ID(mc_att_ctrl_status), &_controller_status);
|
||||
|
||||
@@ -307,9 +307,9 @@ MulticopterPositionControl::MulticopterPositionControl() :
|
||||
_global_vel_sp_sub(-1),
|
||||
|
||||
/* publications */
|
||||
_att_sp_pub(0),
|
||||
_local_pos_sp_pub(0),
|
||||
_global_vel_sp_pub(0),
|
||||
_att_sp_pub(nullptr),
|
||||
_local_pos_sp_pub(nullptr),
|
||||
_global_vel_sp_pub(nullptr),
|
||||
|
||||
_ref_alt(0.0f),
|
||||
_ref_timestamp(0),
|
||||
@@ -1023,7 +1023,7 @@ MulticopterPositionControl::task_main()
|
||||
_att_sp.timestamp = hrt_absolute_time();
|
||||
|
||||
/* publish attitude setpoint */
|
||||
if (_att_sp_pub > 0) {
|
||||
if (_att_sp_pub != nullptr) {
|
||||
orb_publish(ORB_ID(vehicle_attitude_setpoint), _att_sp_pub, &_att_sp);
|
||||
|
||||
} else {
|
||||
@@ -1057,7 +1057,7 @@ MulticopterPositionControl::task_main()
|
||||
_global_vel_sp.vz = _vel_sp(2);
|
||||
|
||||
/* publish velocity setpoint */
|
||||
if (_global_vel_sp_pub > 0) {
|
||||
if (_global_vel_sp_pub != nullptr) {
|
||||
orb_publish(ORB_ID(vehicle_global_velocity_setpoint), _global_vel_sp_pub, &_global_vel_sp);
|
||||
|
||||
} else {
|
||||
@@ -1342,7 +1342,7 @@ MulticopterPositionControl::task_main()
|
||||
_local_pos_sp.vz = _vel_sp(2);
|
||||
|
||||
/* publish local position setpoint */
|
||||
if (_local_pos_sp_pub > 0) {
|
||||
if (_local_pos_sp_pub != nullptr) {
|
||||
orb_publish(ORB_ID(vehicle_local_position_setpoint), _local_pos_sp_pub, &_local_pos_sp);
|
||||
} else {
|
||||
_local_pos_sp_pub = orb_advertise(ORB_ID(vehicle_local_position_setpoint), &_local_pos_sp);
|
||||
@@ -1418,7 +1418,7 @@ MulticopterPositionControl::task_main()
|
||||
if (!(_control_mode.flag_control_offboard_enabled &&
|
||||
!(_control_mode.flag_control_position_enabled ||
|
||||
_control_mode.flag_control_velocity_enabled))) {
|
||||
if (_att_sp_pub > 0) {
|
||||
if (_att_sp_pub != nullptr) {
|
||||
orb_publish(ORB_ID(vehicle_attitude_setpoint), _att_sp_pub, &_att_sp);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -69,7 +69,7 @@ static const int ERROR = -1;
|
||||
|
||||
Geofence::Geofence() :
|
||||
SuperBlock(NULL, "GF"),
|
||||
_fence_pub(0),
|
||||
_fence_pub(nullptr),
|
||||
_home_pos{},
|
||||
_home_pos_set(false),
|
||||
_last_horizontal_range_warning(0),
|
||||
@@ -317,7 +317,7 @@ Geofence::addPoint(int argc, char *argv[])
|
||||
void
|
||||
Geofence::publishFence(unsigned vertices)
|
||||
{
|
||||
if (_fence_pub == 0) {
|
||||
if (_fence_pub == nullptr) {
|
||||
_fence_pub = orb_advertise(ORB_ID(fence), &vertices);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -108,10 +108,10 @@ Navigator::Navigator() :
|
||||
_onboard_mission_sub(-1),
|
||||
_offboard_mission_sub(-1),
|
||||
_param_update_sub(-1),
|
||||
_pos_sp_triplet_pub(0),
|
||||
_mission_result_pub(0),
|
||||
_geofence_result_pub(0),
|
||||
_att_sp_pub(0),
|
||||
_pos_sp_triplet_pub(nullptr),
|
||||
_mission_result_pub(nullptr),
|
||||
_geofence_result_pub(nullptr),
|
||||
_att_sp_pub(nullptr),
|
||||
_vstatus{},
|
||||
_control_mode{},
|
||||
_global_pos{},
|
||||
@@ -563,7 +563,7 @@ Navigator::publish_position_setpoint_triplet()
|
||||
_pos_sp_triplet.nav_state = _vstatus.nav_state;
|
||||
|
||||
/* lazily publish the position setpoint triplet only once available */
|
||||
if (_pos_sp_triplet_pub > 0) {
|
||||
if (_pos_sp_triplet_pub != nullptr) {
|
||||
orb_publish(ORB_ID(position_setpoint_triplet), _pos_sp_triplet_pub, &_pos_sp_triplet);
|
||||
|
||||
} else {
|
||||
@@ -641,7 +641,7 @@ void
|
||||
Navigator::publish_mission_result()
|
||||
{
|
||||
/* lazily publish the mission result only once available */
|
||||
if (_mission_result_pub > 0) {
|
||||
if (_mission_result_pub != nullptr) {
|
||||
/* publish mission result */
|
||||
orb_publish(ORB_ID(mission_result), _mission_result_pub, &_mission_result);
|
||||
|
||||
@@ -663,7 +663,7 @@ Navigator::publish_geofence_result()
|
||||
{
|
||||
|
||||
/* lazily publish the geofence result only once available */
|
||||
if (_geofence_result_pub > 0) {
|
||||
if (_geofence_result_pub != nullptr) {
|
||||
/* publish mission result */
|
||||
orb_publish(ORB_ID(geofence_result), _geofence_result_pub, &_geofence_result);
|
||||
|
||||
@@ -677,7 +677,7 @@ void
|
||||
Navigator::publish_att_sp()
|
||||
{
|
||||
/* lazily publish the attitude sp only once available */
|
||||
if (_att_sp_pub > 0) {
|
||||
if (_att_sp_pub != nullptr) {
|
||||
/* publish att sp*/
|
||||
orb_publish(ORB_ID(vehicle_attitude_setpoint), _att_sp_pub, &_att_sp);
|
||||
|
||||
|
||||
@@ -343,7 +343,7 @@ int position_estimator_inav_thread_main(int argc, char *argv[])
|
||||
|
||||
/* advertise */
|
||||
orb_advert_t vehicle_local_position_pub = orb_advertise(ORB_ID(vehicle_local_position), &local_pos);
|
||||
orb_advert_t vehicle_global_position_pub = 0;
|
||||
orb_advert_t vehicle_global_position_pub = NULL;
|
||||
|
||||
struct position_estimator_inav_params params;
|
||||
struct position_estimator_inav_param_handles pos_inav_param_handles;
|
||||
@@ -1158,7 +1158,7 @@ int position_estimator_inav_thread_main(int argc, char *argv[])
|
||||
global_pos.eph = eph;
|
||||
global_pos.epv = epv;
|
||||
|
||||
if (vehicle_global_position_pub == 0) {
|
||||
if (vehicle_global_position_pub == NULL) {
|
||||
vehicle_global_position_pub = orb_advertise(ORB_ID(vehicle_global_position), &global_pos);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -517,13 +517,13 @@ Sensors::Sensors() :
|
||||
_manual_control_sub(-1),
|
||||
|
||||
/* publications */
|
||||
_sensor_pub(0),
|
||||
_manual_control_pub(0),
|
||||
_actuator_group_3_pub(0),
|
||||
_rc_pub(0),
|
||||
_battery_pub(0),
|
||||
_airspeed_pub(0),
|
||||
_diff_pres_pub(0),
|
||||
_sensor_pub(nullptr),
|
||||
_manual_control_pub(nullptr),
|
||||
_actuator_group_3_pub(nullptr),
|
||||
_rc_pub(nullptr),
|
||||
_battery_pub(nullptr),
|
||||
_airspeed_pub(nullptr),
|
||||
_diff_pres_pub(nullptr),
|
||||
|
||||
/* performance counters */
|
||||
_loop_perf(perf_alloc(PC_ELAPSED, "sensor task update")),
|
||||
@@ -1295,7 +1295,7 @@ Sensors::diff_pres_poll(struct sensor_combined_s &raw)
|
||||
_airspeed.air_temperature_celsius = air_temperature_celsius;
|
||||
|
||||
/* announce the airspeed if needed, just publish else */
|
||||
if (_airspeed_pub > 0) {
|
||||
if (_airspeed_pub != nullptr) {
|
||||
orb_publish(ORB_ID(airspeed), _airspeed_pub, &_airspeed);
|
||||
|
||||
} else {
|
||||
@@ -1770,7 +1770,7 @@ Sensors::adc_poll(struct sensor_combined_s &raw)
|
||||
_diff_pres.temperature = -1000.0f;
|
||||
|
||||
/* announce the airspeed if needed, just publish else */
|
||||
if (_diff_pres_pub > 0) {
|
||||
if (_diff_pres_pub != nullptr) {
|
||||
orb_publish(ORB_ID(differential_pressure), _diff_pres_pub, &_diff_pres);
|
||||
|
||||
} else {
|
||||
@@ -1784,7 +1784,7 @@ Sensors::adc_poll(struct sensor_combined_s &raw)
|
||||
|
||||
if (_battery_status.voltage_filtered_v > BATT_V_IGNORE_THRESHOLD) {
|
||||
/* announce the battery status if needed, just publish else */
|
||||
if (_battery_pub > 0) {
|
||||
if (_battery_pub != nullptr) {
|
||||
orb_publish(ORB_ID(battery_status), _battery_pub, &_battery_status);
|
||||
|
||||
} else {
|
||||
@@ -1983,7 +1983,7 @@ Sensors::rc_poll()
|
||||
_rc.timestamp = rc_input.timestamp_last_signal;
|
||||
|
||||
/* publish rc_channels topic even if signal is invalid, for debug */
|
||||
if (_rc_pub > 0) {
|
||||
if (_rc_pub != nullptr) {
|
||||
orb_publish(ORB_ID(rc_channels), _rc_pub, &_rc);
|
||||
|
||||
} else {
|
||||
@@ -2018,7 +2018,7 @@ Sensors::rc_poll()
|
||||
manual.offboard_switch = get_rc_sw2pos_position (rc_channels_s::RC_CHANNELS_FUNCTION_OFFBOARD, _parameters.rc_offboard_th, _parameters.rc_offboard_inv);
|
||||
|
||||
/* publish manual_control_setpoint topic */
|
||||
if (_manual_control_pub > 0) {
|
||||
if (_manual_control_pub != nullptr) {
|
||||
orb_publish(ORB_ID(manual_control_setpoint), _manual_control_pub, &manual);
|
||||
|
||||
} else {
|
||||
@@ -2041,7 +2041,7 @@ Sensors::rc_poll()
|
||||
actuator_group_3.control[7] = manual.aux3;
|
||||
|
||||
/* publish actuator_controls_3 topic */
|
||||
if (_actuator_group_3_pub > 0) {
|
||||
if (_actuator_group_3_pub != nullptr) {
|
||||
orb_publish(ORB_ID(actuator_controls_3), _actuator_group_3_pub, &actuator_group_3);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -165,10 +165,10 @@ private:
|
||||
_accel(1),
|
||||
_mpu(1),
|
||||
_baro(1),
|
||||
_sensor_combined_pub(-1)
|
||||
_sensor_combined_pub(nullptr)
|
||||
#ifndef __PX4_QURT
|
||||
,
|
||||
_manual_control_sp_pub(-1),
|
||||
_manual_control_sp_pub(nullptr),
|
||||
_actuator_outputs_sub(-1),
|
||||
_vehicle_attitude_sub(-1),
|
||||
_sensor{},
|
||||
|
||||
@@ -157,7 +157,7 @@ void Simulator::handle_message(mavlink_message_t *msg) {
|
||||
fill_sensors_from_imu_msg(&_sensor, &imu);
|
||||
|
||||
// publish message
|
||||
if(_sensor_combined_pub == 0) {
|
||||
if(_sensor_combined_pub == nullptr) {
|
||||
_sensor_combined_pub = orb_advertise(ORB_ID(sensor_combined), &_sensor);
|
||||
} else {
|
||||
orb_publish(ORB_ID(sensor_combined), _sensor_combined_pub, &_sensor);
|
||||
@@ -171,7 +171,7 @@ void Simulator::handle_message(mavlink_message_t *msg) {
|
||||
fill_manual_control_sp_msg(&_manual_control_sp, &man_ctrl_sp);
|
||||
|
||||
// publish message
|
||||
if(_manual_control_sp_pub == 0) {
|
||||
if(_manual_control_sp_pub == nullptr) {
|
||||
_manual_control_sp_pub = orb_advertise(ORB_ID(manual_control_setpoint), &_manual_control_sp);
|
||||
} else {
|
||||
orb_publish(ORB_ID(manual_control_setpoint), _manual_control_sp_pub, &_manual_control_sp);
|
||||
|
||||
@@ -130,7 +130,7 @@ const UT_icd param_icd = {sizeof(struct param_wbuf_s), NULL, NULL, NULL};
|
||||
ORB_DEFINE(parameter_update, struct parameter_update_s);
|
||||
|
||||
/** parameter update topic handle */
|
||||
static orb_advert_t param_topic = 0;
|
||||
static orb_advert_t param_topic = NULL;
|
||||
|
||||
static void param_set_used_internal(param_t param);
|
||||
|
||||
@@ -233,7 +233,7 @@ param_notify_changes(void)
|
||||
* If we don't have a handle to our topic, create one now; otherwise
|
||||
* just publish.
|
||||
*/
|
||||
if (param_topic == 0) {
|
||||
if (param_topic == NULL) {
|
||||
param_topic = orb_advertise(ORB_ID(parameter_update), &pup);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
*/
|
||||
PublicationBase(const struct orb_metadata *meta) :
|
||||
_meta(meta),
|
||||
_handle(-1) {
|
||||
_handle(nullptr) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
* @param data The uORB message struct we are updating.
|
||||
*/
|
||||
void update(void * data) {
|
||||
if (_handle > 0) {
|
||||
if (_handle != nullptr) {
|
||||
orb_publish(getMeta(), getHandle(), data);
|
||||
} else {
|
||||
setHandle(orb_advertise(getMeta(), data));
|
||||
@@ -83,11 +83,10 @@ public:
|
||||
* Deconstructor
|
||||
*/
|
||||
virtual ~PublicationBase() {
|
||||
orb_unsubscribe(getHandle());
|
||||
}
|
||||
// accessors
|
||||
const struct orb_metadata *getMeta() { return _meta; }
|
||||
int getHandle() { return _handle; }
|
||||
orb_advert_t getHandle() { return _handle; }
|
||||
protected:
|
||||
// accessors
|
||||
void setHandle(orb_advert_t handle) { _handle = handle; }
|
||||
|
||||
@@ -135,7 +135,7 @@ __BEGIN_DECLS
|
||||
* a file-descriptor-based handle would not otherwise be in scope for the
|
||||
* publisher.
|
||||
*/
|
||||
typedef uintptr_t orb_advert_t;
|
||||
typedef void * orb_advert_t;
|
||||
|
||||
/**
|
||||
* Advertise as the publisher of a topic.
|
||||
|
||||
@@ -73,11 +73,11 @@ class uORB::Manager
|
||||
* @param data A pointer to the initial data to be published.
|
||||
* For topics updated by interrupt handlers, the advertisement
|
||||
* must be performed from non-interrupt context.
|
||||
* @return ERROR on error, otherwise returns a handle
|
||||
* @return nullptr on error, otherwise returns an object pointer
|
||||
* that can be used to publish to the topic.
|
||||
* If the topic in question is not known (due to an
|
||||
* ORB_DEFINE with no corresponding ORB_DECLARE)
|
||||
* this function will return -1 and set errno to ENOENT.
|
||||
* this function will return nullptr and set errno to ENOENT.
|
||||
*/
|
||||
orb_advert_t orb_advertise(const struct orb_metadata *meta, const void *data);
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ orb_advert_t uORB::Manager::orb_advertise_multi(const struct orb_metadata *meta,
|
||||
fd = node_open(PUBSUB, meta, data, true, instance, priority);
|
||||
if (fd == ERROR) {
|
||||
warnx("node_open as advertiser failed.");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* get the advertiser handle and close the node */
|
||||
@@ -102,14 +102,14 @@ orb_advert_t uORB::Manager::orb_advertise_multi(const struct orb_metadata *meta,
|
||||
px4_close(fd);
|
||||
if (result == ERROR) {
|
||||
warnx("px4_ioctl ORBIOCGADVERTISER failed. fd = %d", fd);
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* the advertiser must perform an initial publish to initialise the object */
|
||||
result = orb_publish(meta, advertiser, data);
|
||||
if (result == ERROR) {
|
||||
warnx("orb_publish failed");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return advertiser;
|
||||
|
||||
@@ -192,7 +192,7 @@ int uORBTest::UnitTest::test()
|
||||
test_note("try multi-topic support");
|
||||
|
||||
int instance0;
|
||||
int pfd0 = orb_advertise_multi(ORB_ID(orb_multitest), &t, &instance0, ORB_PRIO_MAX);
|
||||
orb_advert_t pfd0 = orb_advertise_multi(ORB_ID(orb_multitest), &t, &instance0, ORB_PRIO_MAX);
|
||||
|
||||
test_note("advertised");
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ void UavcanEscController::orb_pub_timer_cb(const uavcan::TimerEvent&)
|
||||
_esc_status.counter += 1;
|
||||
_esc_status.esc_connectiontype = ESC_CONNECTION_TYPE_CAN;
|
||||
|
||||
if (_esc_status_pub > 0) {
|
||||
if (_esc_status_pub != nullptr) {
|
||||
(void)orb_publish(ORB_ID(esc_status), _esc_status_pub, &_esc_status);
|
||||
} else {
|
||||
_esc_status_pub = orb_advertise(ORB_ID(esc_status), &_esc_status);
|
||||
|
||||
@@ -88,7 +88,7 @@ private:
|
||||
|
||||
bool _armed = false;
|
||||
esc_status_s _esc_status = {};
|
||||
orb_advert_t _esc_status_pub = -1;
|
||||
orb_advert_t _esc_status_pub = nullptr;
|
||||
|
||||
/*
|
||||
* libuavcan related things
|
||||
|
||||
@@ -48,7 +48,7 @@ const char *const UavcanGnssBridge::NAME = "gnss";
|
||||
UavcanGnssBridge::UavcanGnssBridge(uavcan::INode &node) :
|
||||
_node(node),
|
||||
_sub_fix(node),
|
||||
_report_pub(0)
|
||||
_report_pub(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ void UavcanGnssBridge::gnss_fix_sub_cb(const uavcan::ReceivedDataStructure<uavca
|
||||
|
||||
report.satellites_used = msg.sats_used;
|
||||
|
||||
if (_report_pub > 0) {
|
||||
if (_report_pub != nullptr) {
|
||||
orb_publish(ORB_ID(vehicle_gps_position), _report_pub, &report);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -89,7 +89,7 @@ class UavcanCDevSensorBridgeBase : public IUavcanSensorBridge, public device::CD
|
||||
struct Channel
|
||||
{
|
||||
int node_id = -1;
|
||||
orb_advert_t orb_advert = -1;
|
||||
orb_advert_t orb_advert = nullptr;
|
||||
int class_instance = -1;
|
||||
int orb_instance = -1;
|
||||
};
|
||||
|
||||
@@ -230,10 +230,10 @@ VtolAttitudeControl::VtolAttitudeControl() :
|
||||
_battery_status_sub(-1),
|
||||
|
||||
//init publication handlers
|
||||
_actuators_0_pub(0),
|
||||
_actuators_1_pub(0),
|
||||
_vtol_vehicle_status_pub(0),
|
||||
_v_rates_sp_pub(0),
|
||||
_actuators_0_pub(nullptr),
|
||||
_actuators_1_pub(nullptr),
|
||||
_vtol_vehicle_status_pub(nullptr),
|
||||
_v_rates_sp_pub(nullptr),
|
||||
|
||||
_loop_perf(perf_alloc(PC_ELAPSED, "vtol_att_control")),
|
||||
_nonfinite_input_perf(perf_alloc(PC_COUNT, "vtol att control nonfinite input"))
|
||||
@@ -716,7 +716,7 @@ void VtolAttitudeControl::task_main()
|
||||
|
||||
while (!_task_should_exit) {
|
||||
/*Advertise/Publish vtol vehicle status*/
|
||||
if (_vtol_vehicle_status_pub > 0) {
|
||||
if (_vtol_vehicle_status_pub != nullptr) {
|
||||
orb_publish(ORB_ID(vtol_vehicle_status), _vtol_vehicle_status_pub, &_vtol_vehicle_status);
|
||||
|
||||
} else {
|
||||
@@ -788,14 +788,14 @@ void VtolAttitudeControl::task_main()
|
||||
if(_v_control_mode.flag_control_attitude_enabled ||
|
||||
_v_control_mode.flag_control_rates_enabled)
|
||||
{
|
||||
if (_actuators_0_pub > 0) {
|
||||
if (_actuators_0_pub != nullptr) {
|
||||
orb_publish(ORB_ID(actuator_controls_0), _actuators_0_pub, &_actuators_out_0);
|
||||
|
||||
} else {
|
||||
_actuators_0_pub = orb_advertise(ORB_ID(actuator_controls_0), &_actuators_out_0);
|
||||
}
|
||||
|
||||
if (_actuators_1_pub > 0) {
|
||||
if (_actuators_1_pub != nullptr) {
|
||||
orb_publish(ORB_ID(actuator_controls_1), _actuators_1_pub, &_actuators_out_1);
|
||||
|
||||
} else {
|
||||
@@ -825,14 +825,14 @@ void VtolAttitudeControl::task_main()
|
||||
_v_control_mode.flag_control_rates_enabled ||
|
||||
_v_control_mode.flag_control_manual_enabled)
|
||||
{
|
||||
if (_actuators_0_pub > 0) {
|
||||
if (_actuators_0_pub != nullptr) {
|
||||
orb_publish(ORB_ID(actuator_controls_0), _actuators_0_pub, &_actuators_out_0);
|
||||
|
||||
} else {
|
||||
_actuators_0_pub = orb_advertise(ORB_ID(actuator_controls_0), &_actuators_out_0);
|
||||
}
|
||||
|
||||
if (_actuators_1_pub > 0) {
|
||||
if (_actuators_1_pub != nullptr) {
|
||||
orb_publish(ORB_ID(actuator_controls_1), _actuators_1_pub, &_actuators_out_1);
|
||||
|
||||
} else {
|
||||
@@ -843,7 +843,7 @@ void VtolAttitudeControl::task_main()
|
||||
}
|
||||
|
||||
// publish the attitude rates setpoint
|
||||
if(_v_rates_sp_pub > 0) {
|
||||
if(_v_rates_sp_pub != nullptr) {
|
||||
orb_publish(ORB_ID(vehicle_rates_setpoint),_v_rates_sp_pub,&_v_rates_sp);
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user