forked from Archive/PX4-Autopilot
Using a vector to store navigation modes
This commit is contained in:
parent
3b39a8a789
commit
9bb8b12f43
|
@ -40,6 +40,8 @@
|
||||||
#ifndef NAVIGATOR_H
|
#ifndef NAVIGATOR_H
|
||||||
#define NAVIGATOR_H
|
#define NAVIGATOR_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <systemlib/perf_counter.h>
|
#include <systemlib/perf_counter.h>
|
||||||
|
|
||||||
#include <controllib/blocks.hpp>
|
#include <controllib/blocks.hpp>
|
||||||
|
@ -153,6 +155,8 @@ private:
|
||||||
Loiter _loiter; /**< class that handles loiter */
|
Loiter _loiter; /**< class that handles loiter */
|
||||||
RTL _rtl; /**< class that handles RTL */
|
RTL _rtl; /**< class that handles RTL */
|
||||||
|
|
||||||
|
std::vector<NavigatorMode*> _navigation_mode_vector;
|
||||||
|
|
||||||
bool _is_in_loiter; /**< flags if current position SP can be used to loiter */
|
bool _is_in_loiter; /**< flags if current position SP can be used to loiter */
|
||||||
bool _update_triplet; /**< flags if position SP triplet needs to be published */
|
bool _update_triplet; /**< flags if position SP triplet needs to be published */
|
||||||
|
|
||||||
|
|
|
@ -125,6 +125,11 @@ Navigator::Navigator() :
|
||||||
_param_loiter_radius(this, "LOITER_RAD"),
|
_param_loiter_radius(this, "LOITER_RAD"),
|
||||||
_param_takeoff_acceptance_radius(this, "TF_ACC_RAD")
|
_param_takeoff_acceptance_radius(this, "TF_ACC_RAD")
|
||||||
{
|
{
|
||||||
|
/* Create a list of our possible navigation types */
|
||||||
|
_navigation_mode_vector.push_back(&_mission);
|
||||||
|
_navigation_mode_vector.push_back(&_loiter);
|
||||||
|
_navigation_mode_vector.push_back(&_rtl);
|
||||||
|
|
||||||
updateParams();
|
updateParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,23 +368,13 @@ Navigator::task_main()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: make list of modes and loop through it */
|
/* iterate through navigation modes and set active/inactive for each */
|
||||||
if (_navigation_mode == &_mission) {
|
for(unsigned int i = 0; i < _navigation_mode_vector.size(); i++) {
|
||||||
_update_triplet = _mission.on_active(&_pos_sp_triplet);
|
if (_navigation_mode == _navigation_mode_vector[i]) {
|
||||||
|
_update_triplet = _navigation_mode_vector[i]->on_active(&_pos_sp_triplet);
|
||||||
} else {
|
} else {
|
||||||
_mission.on_inactive();
|
_navigation_mode_vector[i]->on_inactive();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_navigation_mode == &_rtl) {
|
|
||||||
_update_triplet = _rtl.on_active(&_pos_sp_triplet);
|
|
||||||
} else {
|
|
||||||
_rtl.on_inactive();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_navigation_mode == &_loiter) {
|
|
||||||
_update_triplet = _loiter.on_active(&_pos_sp_triplet);
|
|
||||||
} else {
|
|
||||||
_loiter.on_inactive();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if nothing is running, set position setpoint triplet invalid */
|
/* if nothing is running, set position setpoint triplet invalid */
|
||||||
|
|
Loading…
Reference in New Issue