aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulian Oes <julian@oes.ch>2014-07-07 18:18:13 +0200
committerJulian Oes <julian@oes.ch>2014-07-07 18:18:13 +0200
commit3b06a74074f71c0700c6e7e9b56954213142aaeb (patch)
treee9e6a5507105c9dbe093ffad974f6762b0f8095a /src
parent530e70bc4697a7e436a4cc9557ce38e139ee2795 (diff)
downloadpx4-firmware-3b06a74074f71c0700c6e7e9b56954213142aaeb.tar.gz
px4-firmware-3b06a74074f71c0700c6e7e9b56954213142aaeb.tar.bz2
px4-firmware-3b06a74074f71c0700c6e7e9b56954213142aaeb.zip
navigator: adapt offboard class to new NavigatorMode API
Diffstat (limited to 'src')
-rw-r--r--src/modules/navigator/offboard.cpp27
-rw-r--r--src/modules/navigator/offboard.h16
2 files changed, 19 insertions, 24 deletions
diff --git a/src/modules/navigator/offboard.cpp b/src/modules/navigator/offboard.cpp
index ef7d11a03..dcb5c6000 100644
--- a/src/modules/navigator/offboard.cpp
+++ b/src/modules/navigator/offboard.cpp
@@ -67,17 +67,27 @@ Offboard::~Offboard()
{
}
-bool
-Offboard::on_active(struct position_setpoint_triplet_s *pos_sp_triplet)
+void
+Offboard::on_inactive()
+{
+}
+
+void
+Offboard::on_activation()
+{
+}
+
+void
+Offboard::on_active()
{
+ struct position_setpoint_triplet_s *pos_sp_triplet = _navigator->get_position_setpoint_triplet();
+
bool updated;
orb_check(_navigator->get_offboard_control_sp_sub(), &updated);
if (updated) {
update_offboard_control_setpoint();
}
- bool changed = false;
-
/* copy offboard setpoints to the corresponding topics */
if (_navigator->get_control_mode()->flag_control_position_enabled
&& _offboard_control_sp.mode == OFFBOARD_CONTROL_MODE_DIRECT_POSITION) {
@@ -91,7 +101,7 @@ Offboard::on_active(struct position_setpoint_triplet_s *pos_sp_triplet)
pos_sp_triplet->current.valid = true;
pos_sp_triplet->current.position_valid = true;
- changed = true;
+ _navigator->set_position_setpoint_triplet_updated();
} else if (_navigator->get_control_mode()->flag_control_velocity_enabled
&& _offboard_control_sp.mode == OFFBOARD_CONTROL_MODE_DIRECT_VELOCITY) {
@@ -105,16 +115,11 @@ Offboard::on_active(struct position_setpoint_triplet_s *pos_sp_triplet)
pos_sp_triplet->current.valid = true;
pos_sp_triplet->current.velocity_valid = true;
- changed = true;
+ _navigator->set_position_setpoint_triplet_updated();
}
- return changed;
}
-void
-Offboard::on_inactive()
-{
-}
void
Offboard::update_offboard_control_setpoint()
diff --git a/src/modules/navigator/offboard.h b/src/modules/navigator/offboard.h
index 4d415dddb..66b923bdb 100644
--- a/src/modules/navigator/offboard.h
+++ b/src/modules/navigator/offboard.h
@@ -54,25 +54,15 @@ class Navigator;
class Offboard : public NavigatorMode
{
public:
- /**
- * Constructor
- */
Offboard(Navigator *navigator, const char *name);
- /**
- * Destructor
- */
~Offboard();
- /**
- * This function is called while the mode is inactive
- */
virtual void on_inactive();
- /**
- * This function is called while the mode is active
- */
- virtual bool on_active(struct position_setpoint_triplet_s *pos_sp_triplet);
+ virtual void on_activation();
+
+ virtual void on_active();
private:
void update_offboard_control_setpoint();