Skip to content

Commit

Permalink
add precloiter
Browse files Browse the repository at this point in the history
  • Loading branch information
asimopunov committed Apr 12, 2024
1 parent 926e787 commit 3fa4d8a
Show file tree
Hide file tree
Showing 15 changed files with 794 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/modules/mavlink/mavlink_mission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1601,6 +1601,11 @@ MavlinkMissionManager::parse_mavlink_mission_item(const mavlink_mission_item_t *
case MAV_CMD_DO_SET_ACTUATOR:
mission_item->nav_cmd = (NAV_CMD)mavlink_mission_item->command;
break;
case MAV_CMD_DO_PRECISION_HOLD:

mission_item->nav_cmd = NAV_CMD_DO_PRECISION_HOLD;
mission_item->params[0] = mavlink_mission_item->param1; // Height above target
break;

default:
mission_item->nav_cmd = NAV_CMD_INVALID;
Expand Down Expand Up @@ -1691,6 +1696,8 @@ MavlinkMissionManager::format_mavlink_mission_item(const struct mission_item_s *
case NAV_CMD_SET_CAMERA_ZOOM:
case NAV_CMD_SET_CAMERA_FOCUS:
case NAV_CMD_DO_VTOL_TRANSITION:
:
case MAV_CMD_DO_PRECISION_HOLD:
break;

default:
Expand Down
1 change: 1 addition & 0 deletions src/modules/muorb/apps/libfc-sensor-api
Submodule libfc-sensor-api added at ca16e9
1 change: 1 addition & 0 deletions src/modules/navigator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ set(NAVIGATOR_SOURCES
takeoff.cpp
land.cpp
precland.cpp
precloiter.cpp
mission_feasibility_checker.cpp
geofence.cpp)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ bool FeasibilityChecker::checkMissionItemValidity(mission_item_s &mission_item,
mission_item.nav_cmd != NAV_CMD_SET_CAMERA_MODE &&
mission_item.nav_cmd != NAV_CMD_SET_CAMERA_ZOOM &&
mission_item.nav_cmd != NAV_CMD_SET_CAMERA_FOCUS &&
mission_item.nav_cmd != NAV_CMD_DO_VTOL_TRANSITION) {
mission_item.nav_cmd != NAV_CMD_DO_VTOL_TRANSITION &&
mission_item.nav_cmd != NAV_CMD_DO_PRECISION_HOLD) {

mavlink_log_critical(_mavlink_log_pub, "Mission rejected: item %i: unsupported cmd: %d\t",
(int)(current_index + 1),
Expand Down
2 changes: 1 addition & 1 deletion src/modules/navigator/mission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void Mission::setActiveMissionItems()
handleLanding(new_work_item_type, next_mission_items, num_found_items);

// TODO Precision land needs to be refactored: https://github.com/PX4/Firmware/issues/14320
if (new_work_item_type != WorkItemType::WORK_ITEM_TYPE_PRECISION_LAND) {
if (new_work_item_type != WorkItemType::WORK_ITEM_TYPE_PRECISION_LAND && new_work_item_type != WorkItemType::WORK_ITEM_TYPE_PRECISION_LOITER) {
mission_item_to_position_setpoint(_mission_item, &pos_sp_triplet->current);
}

Expand Down
13 changes: 13 additions & 0 deletions src/modules/navigator/mission_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ MissionBase::on_inactivation()
_navigator->get_precland()->on_inactivation();
}

:
if (_navigator->get_precloiter()->is_activated()) {
_navigator->get_precloiter()->on_inactivation();
}

/* reset so current mission item gets restarted if mission was paused */
_work_item_type = WorkItemType::WORK_ITEM_TYPE_DEFAULT;

Expand Down Expand Up @@ -352,6 +357,14 @@ MissionBase::on_active()
} else if (_navigator->get_precland()->is_activated()) {
_navigator->get_precland()->on_inactivation();
}

:
if (_work_item_type == WorkItemType::WORK_ITEM_TYPE_PRECISION_LOITER) {
_navigator->get_precloiter()->on_active();

} else if (_navigator->get_precloiter()->is_activated()) {
_navigator->get_precloiter()->on_inactivation();
}
}

void MissionBase::update_mission()
Expand Down
3 changes: 2 additions & 1 deletion src/modules/navigator/mission_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ class MissionBase : public MissionBlock, public ModuleParams
WORK_ITEM_TYPE_ALIGN_HEADING, /**< align for next waypoint */
WORK_ITEM_TYPE_TRANSITION_AFTER_TAKEOFF,
WORK_ITEM_TYPE_MOVE_TO_LAND_AFTER_TRANSITION,
WORK_ITEM_TYPE_PRECISION_LAND
WORK_ITEM_TYPE_PRECISION_LAND,
WORK_ITEM_TYPE_PRECISION_LOITER
} _work_item_type{WorkItemType::WORK_ITEM_TYPE_DEFAULT}; /**< current type of work to do (sub mission item) */

enum class MissionType {
Expand Down
9 changes: 8 additions & 1 deletion src/modules/navigator/mission_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,14 @@ MissionBlock::is_mission_item_reached_or_completed()
_time_wp_reached = now;
}
}

:
} else if (_mission_item.nav_cmd == NAV_CMD_DO_PRECISION_HOLD) {
// Check if the precloiter item has finished
if (!_navigator->get_precloiter()->is_activated()) {
_waypoint_position_reached = true;
_waypoint_yaw_reached = true;
_time_wp_reached = now;
}
} else {

float acceptance_radius = _navigator->get_acceptance_radius();
Expand Down
1 change: 1 addition & 0 deletions src/modules/navigator/navigation.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ enum NAV_CMD {
NAV_CMD_DO_SET_CAM_TRIGG_INTERVAL = 214,
NAV_CMD_DO_SET_CAM_TRIGG_DIST = 206,
NAV_CMD_OBLIQUE_SURVEY = 260,
NAV_CMD_DO_PRECISION_HOLD = 303,
NAV_CMD_SET_CAMERA_MODE = 530,
NAV_CMD_SET_CAMERA_ZOOM = 531,
NAV_CMD_SET_CAMERA_FOCUS = 532,
Expand Down
5 changes: 4 additions & 1 deletion src/modules/navigator/navigator.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "geofence.h"
#include "land.h"
#include "precland.h"
#include "precloiter.h"
#include "loiter.h"
#include "mission.h"
#include "navigator_mode.h"
Expand Down Expand Up @@ -90,7 +91,7 @@ using namespace time_literals;
/**
* Number of navigation modes that need on_active/on_inactive calls
*/
#define NAVIGATOR_MODE_ARRAY_SIZE 8
#define NAVIGATOR_MODE_ARRAY_SIZE 8 //TODO fix

class Navigator : public ModuleBase<Navigator>, public ModuleParams
{
Expand Down Expand Up @@ -163,6 +164,7 @@ class Navigator : public ModuleBase<Navigator>, public ModuleParams
vehicle_status_s *get_vstatus() { return &_vstatus; }

PrecLand *get_precland() { return &_precland; } /**< allow others, e.g. Mission, to use the precision land block */
PrecLoiter *get_precloiter() { return &_precloiter; } /**< allow others, e.g. Mission, to use the precision loiter block */

const vehicle_roi_s &get_vroi() { return _vroi; }

Expand Down Expand Up @@ -350,6 +352,7 @@ class Navigator : public ModuleBase<Navigator>, public ModuleParams
#endif //CONFIG_MODE_NAVIGATOR_VTOL_TAKEOFF
Land _land; /**< class for handling land commands */
PrecLand _precland; /**< class for handling precision land commands */
PrecLoiter _precloiter; /**< class for handling precision loiter commands */
RTL _rtl; /**< class that handles RTL */
AdsbConflict _adsb_conflict; /**< class that handles ADSB conflict avoidance */

Expand Down
2 changes: 2 additions & 0 deletions src/modules/navigator/navigator_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Navigator::Navigator() :
#endif //CONFIG_MODE_NAVIGATOR_VTOL_TAKEOFF
_land(this),
_precland(this),
_precloiter(this),
_rtl(this)
{
/* Create a list of our possible navigation types */
Expand All @@ -92,6 +93,7 @@ Navigator::Navigator() :
#if CONFIG_MODE_NAVIGATOR_VTOL_TAKEOFF
_navigation_mode_array[6] = &_vtol_takeoff;
#endif //CONFIG_MODE_NAVIGATOR_VTOL_TAKEOFF
_navigation_mode_array[7] = &_precloiter;

/* iterate through navigation modes and initialize _mission_item for each */
for (unsigned int i = 0; i < NAVIGATOR_MODE_ARRAY_SIZE; i++) {
Expand Down
Loading

0 comments on commit 3fa4d8a

Please sign in to comment.