Implement Pacakge delivery via Gripper during mission

This feature allows user to use a Gripper type pacakge delivery
mechanism on a drone to trigger the delivery during a mission via the
mission item `DO_GRIPPER`.

This is a minimal change that is intended to have simplest pacakge
delivery feature on PX4, however the future scope would extend this
feature out of Navigator, and rather move towards a federated PX4
(flight-mode flexibility) architecture. But until then, this will serve
the purpose.

Update Tools/sitl_gazebo submodule to remove sdf file overwrite error

- There was an error happening due to .sdf file being overwritten, it
was caused by a wrongfully added. sdf file.
- This update pulls in the PR commit: https://github.com/Auterion/sitl_gazebo/pull/147

Initial cut on supporing PAYLOAD_PLACE mission item

Tidy and comment on navigation.h to clarify mission item definition

- Convert vehicle command ack subscription data type to
SubscriptionData, to not care about having a dedicated struct for
copying the latest data
- Tidy and comment on navigation.h to clarify the definition of
mission_item_s, which is confusing as it is an intergration of MAVLink
Standard into PX4's internal Mission Item structure

Rename mission_block's mission item reached function & cleanup navigator

- Isolated Handle Vehicle Commands function inside the Navigator
- Rename mission_block's mission item reached function to 'reached or
completed', as the navigation command can also be an action (e.g.
DO_SET_SERVO, which doesn't make sense to refer to as 'reached' when we
have successfully done executed the command)

Include MAVLink PR commit to include payload_drop message

More changes to add payload_drop MAVLink message support

- Comitting for testing purposes

Add mission item payload_drop to vehicle command payload drop link

- Now with a mission item with the nav_cmd set to 'payload drop', the
appropriate 'payload drop' vehicle command will be issued

Make Payload drop executable via Mission Plan

Implement payload_drop module to simulate payload delivery

- Simple module that acknowledges the payload drop vehicle command after
certain time, to simulate a successful delivery

Additional changes - payload drop module not working yet

- Need to do more thread stuff to make it work :(

Fix Payload Drop enum mismatch in vehicle_command enums

- First functional Payload Drop Implementation MVP
- Simple Ack & resuming mission from Navigator tested successfully

Hold the position while executing payload drop mission item

- Still the position hold is not solid, maybe I am missing something in
the position setpoint part and all the internal implications of
Navigator :(

Add DO_WINCH command support

Some fixes after rebase on develop branch

- Some missed brackets
- Some comment edits, etc

Add DO_WINCH command support

- Still has a problem of flying away from the waypoint while the
DO_WINCH is being executed, probably position setpoint related stuff :(

Apply braking of the vehicle for DO_WINCH command

- Copies the behavior of NAV_CMD_DELAY, which executes a smooth, braking
behavior when executing the delay because of the braking condition in
`set_mission_items` function
- This will not apply to Fixed wings
- The payload deploy getting triggered may be too early, as right now as
soon as the vehicle approaches the waypoint within the acceptance
threshold, the payload gets deployed

Add DO_GRIPPER support

Implement Gripper actual Hardware triggering support

- Currently not working, possibly in the mixer there's a bug
- Implemented the publishing of actuator_controls_1 uORB topic
- Implemented the test command for the payload_drop module, to test the
grpiper functionality
- Edited px4board file to include the payload_drop module
- Added Holybro X500 V2 airframe file, to enable testing on X500 V2
- Created new Quad X Payload Delivery mixer, which maps the actuator
controls 1 topic's data into the MAIN pin 5 output

Make Payload Drop Gripper Work

- Initialization of the Gripper position to CLOSED on Constructor of the
payload_drop module
- Setting the OPEN and CLOSED value to the appropriate actuator controls
input

Set vehicle_command_ack message's timestamp correctly

- By not setting the timestamp, the ack commands were not correctly
graphed in PlotJuggler!

Rename payload drop module to payload deliverer

- I think it's a more complex name (harder to type), but more generic

Add Gripper class (WIP)

Add Gripper class functionalities

- Add gripper uORB message
- Add gripper state machine

Use Gripper class as main interface in payload_deliverer

- Utilizes Gripper class functions for doing Gripper functionality

Remove mixer based package delivery trigger logic

- Remove custom mixer files that mapped actuator controls to outputs
statically

Additional improvements of the payload_deliverer

Fix payload_deliverer module not starting

- _task_id wasn't geting set appropriately in task_spawn function, which
led to runtime failure

Add Gripper Function to mixer_module

- Still not showing up as function mapping in QGC, needs fix

Add parameters to control gripper behavior

- Now user can enable / disable gripper
- Also select which type of gripper to use

Applying review from nuno

Remove timeout fetching from mission item and use gripper's timeout

- Previously, it was planned to use a custom DO_GRIPPER and DO_WINCH
MAVLink message definitions with information on timeout, but since now
we are using original message definition, only relevant timeout
information is defined in the payload_deliverer class

- This change brings in the timeout parameter to the Navigator, which
then sets the timeout in the mission_block class level, which then
processes the timeout logic

Make payload deployment work for Allmend test :P

Support gripper open/close test commands in payload_deliverer

Move enum definition for GRIPPER_ACTION to vehicle_command.msg

Remove double call for ` ${R}etc/init.d/rc.vehicle_setup`

- Was introduced during the rebase
- Was causing module already running & uORB topic can't be advertised
errors

Fix format via `make format` command

Modify S500 airframe file to use for control allocation usage

- Added Control allocation related parameters as default to not have it
reset every time the airframe is selected

Implement mission specific payload deploy timeout and more changes

Switch payload_deliverer to run on work queue

Remove unnecessary files

- Airframe changes from enabling control allocation are removed

Address review comments

- Remove debug messages
- Remove unnecessary or verbose comments & code
- Properly call parameter_update() function

Switch payload_deliverer to scheduled interval work item & refactor

- Switch to Schedeuled on Interval Work Item, as previous vehicle
command subscription callback based behavior led to vehicle comamnd ack
not being sent accordingly (since the Run() wouldn't be called unless
there's a new vehicle command), leading to ack command not being sent
out
- Also, old vehicle commands were getting fetched due to the
subscription callback as well, which was removed with this patch
- Fix the wrong population of floating point param2 field of vehicle
command by int8_t type gripper action by creating dedicated function
- Refactor and add comments to increase readability

Add gripper::grabbing() method and handle this in parameter update

- Previously, the intermediate state 'grabbing' was not considered, and
when the parameter update was called after the first initialization of
the gripper, the grab() function was being called again, which would
produce unnecessary duplicate vehicle command.
- Also replaced direct .grab() access to sending vehicle comamnd, which
unifies the gripper actuation mechanism through vehicle commands.

Navigator: Change SubscriptionData to Subscription to reduce memory usage

- Also removed unused vehicle command ack sub

PayloadDeliverer: Remove unnecessary changes & Bring back vehicle_command sub cb
This commit is contained in:
Junwoo Hwang
2022-09-07 08:11:52 +02:00
committed by Beat Küng
parent e115095f70
commit 2542b1bb26
38 changed files with 1167 additions and 80 deletions
+14 -15
View File
@@ -216,8 +216,8 @@ Mission::on_active()
{
check_mission_valid(false);
/* check if anything has changed */
bool mission_sub_updated = _mission_sub.updated();
/* Check if stored mission plan has changed */
const bool mission_sub_updated = _mission_sub.updated();
if (mission_sub_updated) {
_navigator->reset_triplets();
@@ -245,7 +245,7 @@ Mission::on_active()
}
/* lets check if we reached the current mission item */
if (_mission_type != MISSION_TYPE_NONE && is_mission_item_reached()) {
if (_mission_type != MISSION_TYPE_NONE && is_mission_item_reached_or_completed()) {
/* If we just completed a takeoff which was inserted before the right waypoint,
there is no need to report that we reached it because we didn't. */
if (_work_item_type != WORK_ITEM_TYPE_TAKEOFF) {
@@ -668,7 +668,6 @@ Mission::set_mission_items()
_mission_type = MISSION_TYPE_MISSION;
} else {
/* no mission available or mission finished, switch to loiter */
if (_mission_type != MISSION_TYPE_NONE) {
if (_navigator->get_land_detected()->landed) {
@@ -1114,9 +1113,6 @@ Mission::set_mission_items()
}
/*********************************** set setpoints and check next *********************************************/
position_setpoint_triplet_s *pos_sp_triplet = _navigator->get_position_setpoint_triplet();
// The logic in this section establishes the tracking between the current waypoint
// which we are approaching and the next waypoint, which will tell us in which direction
// we will change our trajectory right after reaching it.
@@ -1125,8 +1121,9 @@ Mission::set_mission_items()
// we are searching around the current mission item in the list to find the closest
// gate and the closest waypoint. We then store them separately.
// Check if the mission item is a gate
// along the current trajectory
position_setpoint_triplet_s *pos_sp_triplet = _navigator->get_position_setpoint_triplet();
// Check if the mission item is a gate along the current trajectory
if (item_contains_gate(_mission_item)) {
// The mission item is a gate, let's check if the next item in the list provides
@@ -1179,10 +1176,8 @@ Mission::set_mission_items()
set_current_mission_item();
}
// If the mission item under evaluation contains a gate,
// then we need to check if we have a next position item so
// the controller can fly the correct line between the
// current and next setpoint
// If the mission item under evaluation contains a gate, we need to check if we have a next position item so
// the controller can fly the correct line between the current and next setpoint
if (item_contains_gate(_mission_item)) {
if (has_after_next_position_item) {
/* got next mission item, update setpoint triplet */
@@ -1194,9 +1189,13 @@ Mission::set_mission_items()
}
} else {
/* allow the vehicle to decelerate before reaching a wp with a hold time */
// Allow a rotary wing vehicle to decelerate before reaching a wp with a hold time or a timeout
// This is done by setting the position triplet's next position's valid flag to false,
// which makes the FlightTask disregard the next position
// TODO: Setting the next waypoint's validity flag to handle braking / correct waypoint behavior
// seems hacky, handle this more properly.
const bool brake_for_hold = _navigator->get_vstatus()->vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING
&& get_time_inside(_mission_item) > FLT_EPSILON;
&& (get_time_inside(_mission_item) > FLT_EPSILON || item_has_timeout(_mission_item));
if (_mission_item.autocontinue && !brake_for_hold) {
/* try to process next mission item */
+8 -2
View File
@@ -33,7 +33,9 @@
/**
* @file mission.h
*
* Navigator mode to access missions
* Mission mode class that handles everything related to executing a mission.
* This class gets included as one of the 'modes' in the Navigator, along with other
* modes like RTL, Loiter, etc.
*
* @author Julian Oes <julian@oes.ch>
* @author Thomas Gubler <thomasgubler@gmail.com>
@@ -118,7 +120,10 @@ private:
void advance_mission();
/**
* Set new mission items
* @brief Configures mission items in current setting
*
* Configure the mission items depending on current mission item index and settings such
* as terrain following, etc.
*/
void set_mission_items();
@@ -273,6 +278,7 @@ private:
bool _mission_waypoints_changed{false};
bool _mission_changed{false}; /** < true if the mission changed since the mission mode was active */
// Work Item corresponds to the sub-mode set on the "MAV_CMD_DO_SET_MODE" MAVLink message
enum work_item_type {
WORK_ITEM_TYPE_DEFAULT, /**< default mission item */
WORK_ITEM_TYPE_TAKEOFF, /**< takeoff before moving to waypoint */
+87 -22
View File
@@ -70,24 +70,15 @@ MissionBlock::MissionBlock(Navigator *navigator) :
}
bool
MissionBlock::is_mission_item_reached()
MissionBlock::is_mission_item_reached_or_completed()
{
/* handle non-navigation or indefinite waypoints */
hrt_abstime now = hrt_absolute_time();
const hrt_abstime now = hrt_absolute_time();
// Handle indefinite waypoints and action commands
switch (_mission_item.nav_cmd) {
// Action Commands that doesn't have timeout completes instantaneously
case NAV_CMD_DO_SET_SERVO:
return true;
case NAV_CMD_LAND: /* fall through */
case NAV_CMD_VTOL_LAND:
return _navigator->get_land_detected()->landed;
case NAV_CMD_IDLE: /* fall through */
case NAV_CMD_LOITER_UNLIMITED:
return false;
case NAV_CMD_DO_LAND_START:
case NAV_CMD_DO_TRIGGER_CONTROL:
case NAV_CMD_DO_DIGICAM_CONTROL:
@@ -114,6 +105,15 @@ MissionBlock::is_mission_item_reached()
case NAV_CMD_DO_SET_HOME:
return true;
// Indefinite Waypoints
case NAV_CMD_LAND: /* fall through */
case NAV_CMD_VTOL_LAND:
return _navigator->get_land_detected()->landed;
case NAV_CMD_IDLE: /* fall through */
case NAV_CMD_LOITER_UNLIMITED:
return false;
case NAV_CMD_DO_VTOL_TRANSITION:
if (int(_mission_item.params[0]) == 3) {
@@ -146,11 +146,49 @@ MissionBlock::is_mission_item_reached()
_time_wp_reached = now;
}
break;
case NAV_CMD_DO_WINCH: {
const float payload_deploy_elasped_time_s = (now - _payload_deployed_time) *
1E-6f; // TODO: Add proper microseconds_to_seconds function
if (_payload_deploy_ack_successful) {
PX4_DEBUG("Winch Deploy Ack received! Resuming mission");
return true;
} else if (payload_deploy_elasped_time_s > _payload_deploy_timeout_s) {
PX4_DEBUG("Winch Deploy Timed out, resuming mission!");
return true;
}
// We are still waiting for the acknowledgement / execution of deploy
return false;
}
case NAV_CMD_DO_GRIPPER: {
const float payload_deploy_elasped_time_s = (now - _payload_deployed_time) * 1E-6f;
if (_payload_deploy_ack_successful) {
PX4_DEBUG("Gripper Deploy Ack received! Resuming mission");
return true;
} else if (payload_deploy_elasped_time_s > _payload_deploy_timeout_s) {
PX4_DEBUG("Gripper Deploy Timed out, resuming mission!");
return true;
}
// We are still waiting for the acknowledgement / execution of deploy
return false;
}
default:
/* do nothing, this is a 3D waypoint */
break;
}
// Update the 'waypoint position reached' status
if (!_navigator->get_land_detected()->landed && !_waypoint_position_reached) {
float dist = -1.0f;
@@ -198,13 +236,13 @@ MissionBlock::is_mission_item_reached()
} else if (_mission_item.nav_cmd == NAV_CMD_TAKEOFF
&& _navigator->get_vstatus()->vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROVER) {
/* for takeoff mission items use the parameter for the takeoff acceptance radius */
// Accept takeoff waypoint to be reached if the distance in 2D plane is within acceptance radius
if (dist_xy >= 0.0f && dist_xy <= _navigator->get_acceptance_radius()) {
_waypoint_position_reached = true;
}
} else if (_mission_item.nav_cmd == NAV_CMD_TAKEOFF) {
/* for takeoff mission items use the parameter for the takeoff acceptance radius */
// For takeoff mission items use the parameter for the takeoff acceptance radius
if (dist >= 0.0f && dist <= _navigator->get_acceptance_radius()
&& dist_z <= _navigator->get_altitude_acceptance_radius()) {
_waypoint_position_reached = true;
@@ -373,8 +411,7 @@ MissionBlock::is_mission_item_reached()
}
}
/* Check if the requested yaw setpoint is reached (only for rotary wing flight). */
// Update the 'waypoint position reached' status (only for rotary wing flight)
if (_waypoint_position_reached && !_waypoint_yaw_reached) {
if (_navigator->get_vstatus()->vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING
@@ -410,7 +447,7 @@ MissionBlock::is_mission_item_reached()
}
}
/* Once the waypoint and yaw setpoint have been reached we can start the loiter time countdown */
// Handle Loiter/Delay Timeout if the waypoint position and yaw setpoint got reached
if (_waypoint_position_reached && _waypoint_yaw_reached) {
bool time_inside_reached = false;
@@ -533,6 +570,23 @@ MissionBlock::issue_command(const mission_item_s &item)
_actuator_pub.publish(actuators);
} else if (item.nav_cmd == NAV_CMD_DO_WINCH ||
item.nav_cmd == NAV_CMD_DO_GRIPPER) {
// Initiate Payload Deployment
vehicle_command_s vcmd = {};
vcmd.command = item.nav_cmd;
vcmd.param1 = item.params[0];
vcmd.param2 = item.params[1];
vcmd.param3 = item.params[2];
vcmd.param4 = item.params[3];
vcmd.param5 = static_cast<double>(item.params[4]);
vcmd.param6 = static_cast<double>(item.params[5]);
_navigator->publish_vehicle_cmd(&vcmd);
// Reset payload deploy flag & data to get ready to receive deployment ack result
_payload_deploy_ack_successful = false;
_payload_deployed_time = hrt_absolute_time();
} else {
// This is to support legacy DO_MOUNT_CONTROL as part of a mission.
@@ -540,8 +594,8 @@ MissionBlock::issue_command(const mission_item_s &item)
_navigator->acquire_gimbal_control();
}
// we're expecting a mission command item here so assign the "raw" inputs to the command
// (MAV_FRAME_MISSION mission item)
// Mission item's NAV_CMD enums directly map to the according vehicle command
// So set the raw value directly (MAV_FRAME_MISSION mission item)
vehicle_command_s vcmd = {};
vcmd.command = item.nav_cmd;
vcmd.param1 = item.params[0];
@@ -581,6 +635,17 @@ MissionBlock::get_time_inside(const mission_item_s &item) const
return 0.0f;
}
// TODO: get_time_inside and item_has_timeout is quite redundant. Separate them out
// Problem arises from the fact that DO_WINCH and DO_GRIPPER *should be an instantaneous command,
// and shouldn't have a timeout defined as it is a DO_* command. It should rather be defined as CONDITION_GRIPPER
// or so, and have a function named 'item_is_conditional'
// Reference: https://mavlink.io/en/services/mission.html#mavlink_commands
bool
MissionBlock::item_has_timeout(const mission_item_s &item)
{
return item.nav_cmd == NAV_CMD_DO_WINCH || item.nav_cmd == NAV_CMD_DO_GRIPPER;
}
bool
MissionBlock::item_contains_position(const mission_item_s &item)
{
@@ -609,7 +674,7 @@ MissionBlock::item_contains_marker(const mission_item_s &item)
bool
MissionBlock::mission_item_to_position_setpoint(const mission_item_s &item, position_setpoint_s *sp)
{
/* don't change the setpoint for non-position items */
// Don't change the setpoint for non-position items
if (!item_contains_position(item)) {
return false;
}
+63 -6
View File
@@ -33,7 +33,8 @@
/**
* @file mission_block.h
*
* Helper class to use mission items
* Base class for Mission class and special flight modes like
* RTL, Land, Loiter, Takeoff, Geofence, etc.
*
* @author Julian Oes <julian@oes.ch>
*/
@@ -74,6 +75,11 @@ public:
*/
static bool item_contains_position(const mission_item_s &item);
/**
* Returns true if the mission item is not an instant action, but has a delay / timeout
*/
bool item_has_timeout(const mission_item_s &item);
/**
* Check if the mission item contains a gate condition
*
@@ -88,12 +94,42 @@ public:
*/
static bool item_contains_marker(const mission_item_s &item);
/**
* @brief Set the payload deployment successful flag object
*
* Function is accessed in Navigator (navigator_main.cpp) to flag when a successful
* payload deployment ack command has been received. Which in turn allows the mission item
* to continue to the next in the 'is_mission_item_reached_or_completed' function below
*/
void set_payload_depolyment_successful_flag(bool payload_deploy_result)
{
_payload_deploy_ack_successful = payload_deploy_result;
}
/**
* @brief Set the payload deployment timeout
*
* Accessed in Navigator to set the appropriate timeout to wait for while waiting for a successful
* payload delivery acknowledgement. If the payload deployment takes longer than timeout, mission will
* continue into the next item automatically.
*
* @param timeout_s Timeout in seconds
*/
void set_payload_deployment_timeout(const float timeout_s)
{
_payload_deploy_timeout_s = timeout_s;
}
protected:
/**
* Check if mission item has been reached
* @return true if successfully reached
* Check if mission item has been reached (for Waypoint based mission items) or Completed (Action based mission items)
*
* Mission Item's 'nav_cmd' can be either Waypoint or Action based. In order to check whether current mission item's
* execution was successful, we need to check either the waypoint was 'reached' or the action was 'completed'.
*
* @return true if successfully reached or completed
*/
bool is_mission_item_reached();
bool is_mission_item_reached_or_completed();
/**
* Reset all reached flags
@@ -140,18 +176,39 @@ protected:
*/
void mission_apply_limitation(mission_item_s &item);
/**
* @brief Issue a command for mission items with a nav_cmd that specifies an action
*
* Execute the specified command inside the mission item. The action depends on the nav_cmd
* value (which correlates to the MAVLink's MAV_CMD enum values) and the params defined in the
* mission item.
*
* This is used for commands like MAV_CMD_DO* in MAVLink, where immediate actions are defined.
* For more information, refer to: https://mavlink.io/en/services/mission.html#mavlink_commands
*
* @param item Mission item to execute
*/
void issue_command(const mission_item_s &item);
float get_time_inside(const mission_item_s &item) const ;
/**
* [s] Get the time to stay that's specified in the mission item
*/
float get_time_inside(const mission_item_s &item) const;
float get_absolute_altitude_for_item(const mission_item_s &mission_item) const;
mission_item_s _mission_item{};
mission_item_s _mission_item{}; // Current mission item that is being executed
bool _waypoint_position_reached{false};
bool _waypoint_yaw_reached{false};
hrt_abstime _time_wp_reached{0};
/* Payload Deploy internal states are used by two NAV_CMDs: DO_WINCH and DO_GRIPPER */
bool _payload_deploy_ack_successful{false}; // Flag to keep track of whether we received an acknowledgement for a successful payload deployment
hrt_abstime _payload_deployed_time{0}; // Last payload deployment start time to handle timeouts
float _payload_deploy_timeout_s{0.0f}; // Timeout for payload deployment in Mission class, to prevent endless loop if successful deployment ack is never received
// Used for MAV_CMD_DO_SET_SERVO command of a Mission item
uORB::Publication<actuator_controls_s> _actuator_pub{ORB_ID(actuator_controls_2)};
};
@@ -250,6 +250,8 @@ MissionFeasibilityChecker::checkMissionItemValidity(const mission_s &mission)
missionitem.nav_cmd != NAV_CMD_VTOL_LAND &&
missionitem.nav_cmd != NAV_CMD_DELAY &&
missionitem.nav_cmd != NAV_CMD_CONDITION_GATE &&
missionitem.nav_cmd != NAV_CMD_DO_WINCH &&
missionitem.nav_cmd != NAV_CMD_DO_GRIPPER &&
missionitem.nav_cmd != NAV_CMD_DO_JUMP &&
missionitem.nav_cmd != NAV_CMD_DO_CHANGE_SPEED &&
missionitem.nav_cmd != NAV_CMD_DO_SET_HOME &&
+11
View File
@@ -156,3 +156,14 @@ PARAM_DEFINE_FLOAT(MIS_YAW_TMT, -1.0f);
* @group Mission
*/
PARAM_DEFINE_FLOAT(MIS_YAW_ERR, 12.0f);
/**
* Timeout for a successful payload deployment acknowledgement
*
* @unit s
* @min 0
* @decimal 1
* @increment 1
* @group Mission
*/
PARAM_DEFINE_FLOAT(MIS_PD_TO, 5.0f);
+22 -19
View File
@@ -33,7 +33,9 @@
/**
* @file navigation.h
*
* Definition of a mission consisting of mission items.
*
* @author Thomas Gubler <thomasgubler@student.ethz.ch>
* @author Julian Oes <joes@student.ethz.ch>
* @author Lorenz Meier <lm@inf.ethz.ch>
@@ -82,6 +84,7 @@ enum NAV_CMD {
NAV_CMD_DO_DIGICAM_CONTROL = 203,
NAV_CMD_DO_MOUNT_CONFIGURE = 204,
NAV_CMD_DO_MOUNT_CONTROL = 205,
NAV_CMD_DO_GRIPPER = 211,
NAV_CMD_DO_SET_CAM_TRIGG_INTERVAL = 214,
NAV_CMD_DO_SET_CAM_TRIGG_DIST = 206,
NAV_CMD_OBLIQUE_SURVEY = 260,
@@ -102,6 +105,7 @@ enum NAV_CMD {
NAV_CMD_FENCE_CIRCLE_INCLUSION = 5003,
NAV_CMD_FENCE_CIRCLE_EXCLUSION = 5004,
NAV_CMD_CONDITION_GATE = 4501,
NAV_CMD_DO_WINCH = 42600,
NAV_CMD_INVALID = UINT16_MAX /* ensure that casting a large number results in a specific error */
};
@@ -126,34 +130,31 @@ enum NAV_FRAME {
NAV_FRAME_GLOBAL_TERRAIN_ALT_INT = 11
};
/**
* @addtogroup topics
* @{
*/
/**
* Global position setpoint in WGS84 coordinates.
*
* This is the position the MAV is heading towards. If it is of type loiter,
* the MAV is circling around it with the given loiter radius in meters.
*
* Corresponds to one of the DM_KEY_WAYPOINTS_OFFBOARD_* dataman items
*/
// Mission Item structure
// We explicitly handle struct padding to ensure consistency between in memory and on disk formats across different platforms, toolchains, etc
// The use of #pragma pack is avoided to prevent the possibility of unaligned memory accesses.
#if (__GNUC__ >= 5) || __clang__
// Disabled in GCC 4.X as the warning doesn't seem to "pop" correctly
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wpadded"
#endif // GCC >= 5 || Clang
/**
* Mission Item structure
*
* We explicitly handle struct padding to ensure consistency between in memory and on disk formats
* across different platforms, toolchains, etc. The use of #pragma pack is avoided to prevent the
* possibility of unaligned memory accesses.
*/
struct mission_item_s {
double lat; /**< latitude in degrees */
double lon; /**< longitude in degrees */
// Union to support both Mission Item categories in MAVLink such as:
// 1. With Global coordinate (param5 ~ 7 corresponds to lat, lon and altitude)
// 2. Without global coordinate (when frame = MAV_FRAME_MISSION)
// Note: the structure and definition of params depends on the nav_cmd, which is
// compatible with MAVLink's MAV_CMD enum definitions.
union {
// Navigation command parameters
struct {
union {
float time_inside; /**< time that the MAV should stay inside the radius before advancing in seconds */
@@ -166,7 +167,9 @@ struct mission_item_s {
float ___lon_float; /**< padding */
float altitude; /**< altitude in meters (AMSL) */
};
float params[7]; /**< array to store mission command values for MAV_FRAME_MISSION ***/
// Non-Navigation command parameters (implicit)
float params[7]; /**< array to store mission command values with no global coordinates (frame = MAV_FRAME_MISSION) */
};
uint16_t nav_cmd; /**< navigation command */
+11 -5
View File
@@ -118,6 +118,14 @@ public:
*/
void load_fence_from_file(const char *filename);
/**
* @brief Publish a given specified vehicle command
*
* Sets the target_component of the vehicle command accordingly depending on the
* vehicle command value (e.g. For Camera control, sets target system component id)
*
* @param vcmd Vehicle command to execute
*/
void publish_vehicle_cmd(vehicle_command_s *vcmd);
/**
@@ -373,9 +381,7 @@ private:
perf_counter_t _loop_perf; /**< loop performance counter */
Geofence _geofence; /**< class that handles the geofence */
GeofenceBreachAvoidance _gf_breach_avoidance;
hrt_abstime _last_geofence_check = 0;
bool _geofence_violation_warning_sent{false}; /**< prevents spaming to mavlink */
@@ -430,6 +436,7 @@ private:
void publish_vehicle_command_ack(const vehicle_command_s &cmd, uint8_t result);
bool geofence_allows_position(const vehicle_global_position_s &pos);
DEFINE_PARAMETERS(
(ParamFloat<px4::params::NAV_LOITER_RAD>) _param_nav_loiter_rad, /**< loiter radius for fixedwing */
(ParamFloat<px4::params::NAV_ACC_RAD>) _param_nav_acc_rad, /**< acceptance for takeoff */
@@ -442,14 +449,13 @@ private:
(ParamFloat<px4::params::NAV_TRAFF_A_RADU>) _param_nav_traff_a_radu, /**< avoidance Distance Unmanned*/
(ParamFloat<px4::params::NAV_TRAFF_A_RADM>) _param_nav_traff_a_radm, /**< avoidance Distance Manned*/
// non-navigator parameters
// Mission (MIS_*)
// non-navigator parameters: Mission (MIS_*)
(ParamFloat<px4::params::MIS_LTRMIN_ALT>) _param_mis_ltrmin_alt,
(ParamFloat<px4::params::MIS_TAKEOFF_ALT>) _param_mis_takeoff_alt,
(ParamBool<px4::params::MIS_TAKEOFF_REQ>) _param_mis_takeoff_req,
(ParamFloat<px4::params::MIS_YAW_TMT>) _param_mis_yaw_tmt,
(ParamFloat<px4::params::MIS_YAW_ERR>) _param_mis_yaw_err,
(ParamFloat<px4::params::MIS_PD_TO>) _param_mis_payload_delivery_timeout,
(ParamFloat<px4::params::LNDMC_ALT_MAX>) _param_lndmc_alt_max
)
};
+8 -1
View File
@@ -98,6 +98,9 @@ Navigator::Navigator() :
_mission_sub = orb_subscribe(ORB_ID(mission));
_vehicle_status_sub = orb_subscribe(ORB_ID(vehicle_status));
// Update the timeout used in mission_block (which can't hold it's own parameters)
_mission.set_payload_deployment_timeout(_param_mis_payload_delivery_timeout.get());
reset_triplets();
}
@@ -128,6 +131,8 @@ void Navigator::params_update()
if (_handle_mpc_acc_hor != PARAM_INVALID) {
param_get(_handle_mpc_acc_hor, &_param_mpc_acc_hor);
}
_mission.set_payload_deployment_timeout(_param_mis_payload_delivery_timeout.get());
}
void Navigator::run()
@@ -203,7 +208,7 @@ void Navigator::run()
}
}
// check for parameter updates
/* check for parameter updates */
if (_parameter_update_sub.updated()) {
// clear update
parameter_update_s pupdate;
@@ -217,8 +222,10 @@ void Navigator::run()
_position_controller_status_sub.update();
_home_pos_sub.update(&_home_pos);
// Handle Vehicle commands
while (_vehicle_command_sub.updated()) {
const unsigned last_generation = _vehicle_command_sub.get_last_generation();
vehicle_command_s cmd{};
_vehicle_command_sub.copy(&cmd);
+1 -1
View File
@@ -298,7 +298,7 @@ void RTL::on_activation()
void RTL::on_active()
{
if (_rtl_state != RTL_STATE_LANDED && is_mission_item_reached()) {
if (_rtl_state != RTL_STATE_LANDED && is_mission_item_reached_or_completed()) {
advance_rtl();
set_rtl_item();
}
+1 -1
View File
@@ -62,7 +62,7 @@ Takeoff::on_active()
// reset the position
set_takeoff_position();
} else if (is_mission_item_reached() && !_navigator->get_mission_result()->finished) {
} else if (is_mission_item_reached_or_completed() && !_navigator->get_mission_result()->finished) {
_navigator->get_mission_result()->finished = true;
_navigator->set_mission_result_updated();
+1 -1
View File
@@ -62,7 +62,7 @@ VtolTakeoff::on_activation()
void
VtolTakeoff::on_active()
{
if (is_mission_item_reached()) {
if (is_mission_item_reached_or_completed()) {
reset_mission_item_reached();
switch (_takeoff_state) {