mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-03 04:21:36 +08:00
FlightTasks: added wrappers for filling setpoint vectors, made time dependent example
This commit is contained in:
@@ -55,13 +55,13 @@ public:
|
|||||||
* @param TODO
|
* @param TODO
|
||||||
* @return 0 on success, >0 on error otherwise
|
* @return 0 on success, >0 on error otherwise
|
||||||
*/
|
*/
|
||||||
int update(manual_control_setpoint_s *manual_control_setpoint, vehicle_local_position_s *vehicle_local_position) { return 0; };
|
int update(manual_control_setpoint_s *manual_control_setpoint, vehicle_local_position_s *vehicle_local_position) { return Orbit.update(NULL, NULL); };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call to get result of the task execution
|
* Call to get result of the task execution
|
||||||
* @return pointer to
|
* @return pointer to
|
||||||
*/
|
*/
|
||||||
const vehicle_local_position_setpoint_s *get_local_position_setpoint() const { return Orbit.get_local_position_setpoint(); };
|
const vehicle_local_position_setpoint_s *get_position_setpoint() const { return Orbit.get_position_setpoint(); };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -47,12 +47,7 @@
|
|||||||
class FlightTask
|
class FlightTask
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FlightTask()
|
FlightTask() {};
|
||||||
{
|
|
||||||
vehicle_local_position_setpoint.x = 1;
|
|
||||||
vehicle_local_position_setpoint.y = 2;
|
|
||||||
vehicle_local_position_setpoint.z = -3;
|
|
||||||
};
|
|
||||||
virtual ~FlightTask() {};
|
virtual ~FlightTask() {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,10 +74,33 @@ public:
|
|||||||
* Call to get result of the task execution
|
* Call to get result of the task execution
|
||||||
* @return pointer to
|
* @return pointer to
|
||||||
*/
|
*/
|
||||||
const vehicle_local_position_setpoint_s *get_local_position_setpoint() const { return &vehicle_local_position_setpoint; };
|
const vehicle_local_position_setpoint_s *get_position_setpoint() const { return &_vehicle_position_setpoint; };
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
void _set_position_setpoint(const matrix::Vector3f position_setpoint)
|
||||||
|
{
|
||||||
|
_vehicle_position_setpoint.x = position_setpoint(0);
|
||||||
|
_vehicle_position_setpoint.y = position_setpoint(1);
|
||||||
|
_vehicle_position_setpoint.z = position_setpoint(2);
|
||||||
|
};
|
||||||
|
|
||||||
|
void _set_velocity_setpoint(const matrix::Vector3f velocity_setpoint)
|
||||||
|
{
|
||||||
|
_vehicle_position_setpoint.vx = velocity_setpoint(0);
|
||||||
|
_vehicle_position_setpoint.vy = velocity_setpoint(1);
|
||||||
|
_vehicle_position_setpoint.vz = velocity_setpoint(2);
|
||||||
|
};
|
||||||
|
|
||||||
|
void _set_acceleration_setpoint(const matrix::Vector3f acceleration_setpoint)
|
||||||
|
{
|
||||||
|
_vehicle_position_setpoint.acc_x = acceleration_setpoint(0);
|
||||||
|
_vehicle_position_setpoint.acc_y = acceleration_setpoint(1);
|
||||||
|
_vehicle_position_setpoint.acc_z = acceleration_setpoint(2);
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
vehicle_local_position_setpoint_s vehicle_local_position_setpoint;
|
vehicle_local_position_setpoint_s _vehicle_position_setpoint;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -53,7 +53,11 @@ public:
|
|||||||
* Call once on the event where you switch to the task
|
* Call once on the event where you switch to the task
|
||||||
* @return 0 on success, >0 on error otherwise
|
* @return 0 on success, >0 on error otherwise
|
||||||
*/
|
*/
|
||||||
virtual int activate() { return 0; };
|
virtual int activate()
|
||||||
|
{
|
||||||
|
_set_position_setpoint(matrix::Vector3f());
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call once on the event of switching away from the task
|
* Call once on the event of switching away from the task
|
||||||
@@ -66,8 +70,12 @@ public:
|
|||||||
* @param TODO
|
* @param TODO
|
||||||
* @return 0 on success, >0 on error otherwise
|
* @return 0 on success, >0 on error otherwise
|
||||||
*/
|
*/
|
||||||
virtual int update(manual_control_setpoint_s *manual_control_setpoint,
|
virtual int update(manual_control_setpoint_s *manual_control_setpoint, vehicle_local_position_s *vehicle_position)
|
||||||
vehicle_local_position_s *vehicle_local_position) { return 0; };
|
{
|
||||||
|
float time = hrt_absolute_time() / 1e6;
|
||||||
|
_set_position_setpoint(matrix::Vector3f(0.1f * time, 0.f, -2.f));
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user