Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vtol_att_control: ack transition commands #8264

Merged
merged 1 commit into from
Nov 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion src/modules/vtol_att_control/vtol_att_control_main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2013, 2014 PX4 Development Team. All rights reserved.
* Copyright (c) 2013 - 2017 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -88,6 +88,7 @@ VtolAttitudeControl::VtolAttitudeControl() :
_vtol_vehicle_status_pub(nullptr),
_v_rates_sp_pub(nullptr),
_v_att_sp_pub(nullptr),
_v_cmd_ack_pub(nullptr),
_transition_command(vtol_vehicle_status_s::VEHICLE_VTOL_STATE_MC),
_abort_front_transition(false)

Expand Down Expand Up @@ -483,6 +484,31 @@ VtolAttitudeControl::handle_command()
// update transition command if necessary
if (_vehicle_cmd.command == vehicle_command_s::VEHICLE_CMD_DO_VTOL_TRANSITION) {
_transition_command = int(_vehicle_cmd.param1 + 0.5f);

// Report that we have received the command no matter what we actually do with it.
// This might not be optimal but is better than no response at all.

if (_vehicle_cmd.from_external) {
vehicle_command_ack_s command_ack = {
.timestamp = hrt_absolute_time(),
.result_param2 = 0,
.command = _vehicle_cmd.command,
.result = (uint8_t)vehicle_command_ack_s::VEHICLE_RESULT_ACCEPTED,
.from_external = false,
.result_param1 = 0,
.target_system = _vehicle_cmd.source_system,
.target_component = _vehicle_cmd.source_component
};

if (_v_cmd_ack_pub == nullptr) {
_v_cmd_ack_pub = orb_advertise_queue(ORB_ID(vehicle_command_ack), &command_ack,
vehicle_command_ack_s::ORB_QUEUE_LENGTH);

} else {
orb_publish(ORB_ID(vehicle_command_ack), _v_cmd_ack_pub, &command_ack);

}
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/modules/vtol_att_control/vtol_att_control_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
#include <uORB/topics/vehicle_attitude.h>
#include <uORB/topics/vehicle_attitude_setpoint.h>
#include <uORB/topics/vehicle_command.h>
#include <uORB/topics/vehicle_command_ack.h>
#include <uORB/topics/vehicle_control_mode.h>
#include <uORB/topics/vehicle_land_detected.h>
#include <uORB/topics/vehicle_local_position.h>
Expand Down Expand Up @@ -159,6 +160,7 @@ class VtolAttitudeControl
orb_advert_t _vtol_vehicle_status_pub;
orb_advert_t _v_rates_sp_pub;
orb_advert_t _v_att_sp_pub;
orb_advert_t _v_cmd_ack_pub;

//*******************data containers***********************************************************
struct vehicle_attitude_s _v_att; //vehicle attitude
Expand Down