mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 09:43: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
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user