navigator: adapt offboard class to new NavigatorMode API

This commit is contained in:
Julian Oes 2014-07-07 18:18:13 +02:00
parent 530e70bc46
commit 3b06a74074
2 changed files with 19 additions and 24 deletions

View File

@ -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()

View File

@ -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();