Implement MAV_CMD_DO_CHANGE_SPEED throttle

This commit is contained in:
sander
2016-06-23 09:08:35 +02:00
committed by Roman
parent 7f8c183d99
commit 37531c018a
5 changed files with 46 additions and 1 deletions
+8
View File
@@ -127,7 +127,14 @@ MissionBlock::is_mission_item_reached()
_navigator->set_cruising_speed(_mission_item.params[1]);
} else {
_navigator->set_cruising_speed();
/* if no speed target was given try to set throttle */
if (_mission_item.params[2] > 0.0f) {
_navigator->set_cruising_throttle(_mission_item.params[2] / 100);
} else {
_navigator->set_cruising_throttle();
}
}
return true;
default:
@@ -367,6 +374,7 @@ MissionBlock::mission_item_to_position_setpoint(const struct mission_item_s *ite
sp->acceptance_radius = item->acceptance_radius;
sp->disable_mc_yaw_control = false;
sp->cruising_speed = _navigator->get_cruising_speed();
sp->cruising_throttle = _navigator->get_cruising_throttle();
switch (item->nav_cmd) {
case NAV_CMD_IDLE:
+15
View File
@@ -178,6 +178,19 @@ public:
*/
void set_cruising_speed(float speed=-1.0f) { _mission_cruising_speed = speed; }
/**
* Get the target throttle
*
* @return the desired throttle for this mission
*/
float get_cruising_throttle();
/**
* Set the target throttle
*/
void set_cruising_throttle(float percent=-1.0f) { _mission_throttle = percent; }
/**
* Get the acceptance radius given the mission item preset radius
*
@@ -277,8 +290,10 @@ private:
control::BlockParamFloat _param_cruising_speed_hover;
control::BlockParamFloat _param_cruising_speed_plane;
control::BlockParamFloat _param_cruising_throttle_plane;
float _mission_cruising_speed;
float _mission_throttle;
/**
* Retrieve global position
+12
View File
@@ -159,6 +159,7 @@ Navigator::Navigator() :
_param_rcloss_act(this, "RCL_ACT"),
_param_cruising_speed_hover(this, "MPC_XY_CRUISE", false),
_param_cruising_speed_plane(this, "FW_AIRSPD_TRIM", false),
_param_cruising_throttle_plane(this, "FW_THR_CRUISE", false),
_mission_cruising_speed(-1.0f)
{
/* Create a list of our possible navigation types */
@@ -725,6 +726,17 @@ Navigator::get_cruising_speed()
}
}
float
Navigator::get_cruising_throttle()
{
/* Return the mission-requested cruise speed, or -1 */
if (_mission_throttle > 0.0f) {
return _mission_throttle;
} else {
return _param_cruising_throttle_plane.get();
}
}
float
Navigator::get_acceptance_radius(float mission_item_radius)
{