Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
d6fe2159
Commit
d6fe2159
authored
7 years ago
by
Dennis Mannhart
Committed by
Beat Küng
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
FlightTaskManualPosition: remove update method and old member variable setpoints
parent
a7f48596
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lib/FlightTasks/tasks/FlightTaskManualPosition.cpp
+18
-30
18 additions, 30 deletions
src/lib/FlightTasks/tasks/FlightTaskManualPosition.cpp
src/lib/FlightTasks/tasks/FlightTaskManualPosition.hpp
+3
-8
3 additions, 8 deletions
src/lib/FlightTasks/tasks/FlightTaskManualPosition.hpp
with
21 additions
and
38 deletions
src/lib/FlightTasks/tasks/FlightTaskManualPosition.cpp
+
18
−
30
View file @
d6fe2159
/****************************************************************************
*
* Copyright (c) 201
7
PX4 Development Team. All rights reserved.
* Copyright (c) 201
8
PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
...
...
@@ -50,15 +50,14 @@ FlightTaskManualPosition::FlightTaskManualPosition(control::SuperBlock *parent,
bool
FlightTaskManualPosition
::
activate
()
{
_pos_sp_xy
=
matrix
::
Vector2f
(
NAN
,
NAN
);
_vel_sp
_xy
=
matrix
::
Vector2f
(
0.0
f
,
0.0
f
)
;
return
FlightTaskManualAltitude
::
activate
()
;
bool
ret
=
FlightTaskManualAltitude
::
activate
(
);
_vel_sp
(
0
)
=
_vel_sp
(
1
)
=
0.0
f
;
return
ret
;
}
void
FlightTaskManualPosition
::
_scaleSticks
()
{
/* Use same scaling as for FlightTaskManualAltitude to
* get yaw and z */
/* Use same scaling as for FlightTaskManualAltitude */
FlightTaskManualAltitude
::
_scaleSticks
();
/* Constrain length of stick inputs to 1 for xy*/
...
...
@@ -71,47 +70,36 @@ void FlightTaskManualPosition::_scaleSticks()
}
/* Scale to velocity.*/
_
vel_sp_xy
=
stick_xy
*
_vel_xy_manual_max
.
get
();
matrix
::
Vector2f
vel_sp_xy
=
stick_xy
*
_vel_xy_manual_max
.
get
();
/* Rotate setpoint into local frame. */
matrix
::
Quatf
q_yaw
=
matrix
::
AxisAnglef
(
matrix
::
Vector3f
(
0.0
f
,
0.0
f
,
1.0
f
),
_yaw
);
matrix
::
Vector3f
vel_world
=
q_yaw
.
conjugate
(
matrix
::
Vector3f
(
_vel_sp_xy
(
0
),
_vel_sp_xy
(
1
),
0.0
f
));
_vel_sp_xy
=
matrix
::
Vector2f
(
vel_world
(
0
),
vel_world
(
1
));
matrix
::
Vector3f
vel_world
=
q_yaw
.
conjugate
(
matrix
::
Vector3f
(
vel_sp_xy
(
0
),
vel_sp_xy
(
1
),
0.0
f
));
_vel_sp
(
0
)
=
vel_world
(
0
);
_vel_sp
(
1
)
=
vel_world
(
1
);
}
void
FlightTaskManualPosition
::
_updateXYlock
()
{
/* If position lock is not active, position setpoint is set to NAN.*/
const
float
vel_xy_norm
=
Vector2f
(
&
_velocity
(
0
)).
length
();
const
bool
apply_brake
=
_vel_sp
_xy
.
length
()
<
FLT_EPSILON
;
const
bool
apply_brake
=
Vector2f
(
&
_vel_sp
(
0
))
.
length
()
<
FLT_EPSILON
;
const
bool
stopped
=
(
_vel_hold_thr_xy
.
get
()
<
FLT_EPSILON
||
vel_xy_norm
<
_vel_hold_thr_xy
.
get
());
if
(
apply_brake
&&
stopped
&&
!
PX4_ISFINITE
(
_pos_sp_xy
(
0
)))
{
_pos_sp_xy
=
matrix
::
Vector2f
(
&
_position
(
0
));
if
(
apply_brake
&&
stopped
&&
!
PX4_ISFINITE
(
_pos_sp
(
0
)))
{
_pos_sp
(
0
)
=
_position
(
0
);
_pos_sp
(
1
)
=
_position
(
1
);
}
else
if
(
!
apply_brake
)
{
/* Don't use position setpoint */
_pos_sp_xy
=
_pos_sp_xy
*
NAN
;
/* don't lock*/
_pos_sp
(
0
)
=
NAN
;
_pos_sp
(
1
)
=
NAN
;
}
}
void
FlightTaskManualPosition
::
_updateSetpoints
()
{
FlightTaskManualAltitude
::
_updateSetpoints
();
// get yaw and z setpoints
FlightTaskManualAltitude
::
_updateSetpoints
();
// needed to get yaw and setpoints in z-direction
_thr_sp
*=
NAN
;
// don't require any thrust setpoints
_updateXYlock
();
// check for position lock
}
bool
FlightTaskManualPosition
::
update
()
{
_scaleSticks
();
_updateSetpoints
();
_setPositionSetpoint
(
Vector3f
(
_pos_sp_xy
(
0
),
_pos_sp_xy
(
1
),
_pos_sp_z
));
_setVelocitySetpoint
(
Vector3f
(
_vel_sp_xy
(
0
),
_vel_sp_xy
(
1
),
_vel_sp_z
));
_setYawSetpoint
(
_yaw_sp
);
_setYawspeedSetpoint
(
_yaw_rate_sp
);
_setThrustSetpoint
(
Vector3f
(
NAN
,
NAN
,
NAN
));
return
true
;
}
This diff is collapsed.
Click to expand it.
src/lib/FlightTasks/tasks/FlightTaskManualPosition.hpp
+
3
−
8
View file @
d6fe2159
...
...
@@ -51,17 +51,12 @@ public:
bool
activate
()
override
;
bool
update
()
override
;
protected:
matrix
::
Vector2f
_vel_sp_xy
{};
/**< Scaled velocity setpoint from stick. NAN during position lock */
matrix
::
Vector2f
_pos_sp_xy
{};
/**< Position setpoint during lock. Otherwise NAN */
control
::
BlockParamFloat
_vel_xy_manual_max
;
/**< Maximum speed allowed horizontally */
control
::
BlockParamFloat
_acc_xy_max
;
/**< Maximum acceleration horizontally. Only used to compute lock time */
control
::
BlockParamFloat
_vel_xy_manual_max
;
/**< maximum speed allowed horizontally */
control
::
BlockParamFloat
_acc_xy_max
;
/**< maximum acceleration horizontally. Only used to compute lock time */
control
::
BlockParamFloat
_vel_hold_thr_xy
;
/**< velocity threshold to switch back into horizontal position hold */
void
_updateXYlock
();
/**<
A
pplies positon lock based on stick and velocity */
void
_updateXYlock
();
/**<
a
pplies positon lock based on stick and velocity */
void
_updateSetpoints
()
override
;
void
_scaleSticks
()
override
;
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment