position_hl_commander
– Simple controls built on HL Commander¶
The PositionHlCommander is used to make it easy to write scripts that move the Crazyflie around. Some sort of positioning support is required, for instance the Loco Positioning System. The implementation uses the High Level Commander and position setpoints.
The API contains a set of primitives that are easy to understand and use, such as “go forward” or “turn around”.
The PositionHlCommander can be used as context manager using the with keyword. In this mode of operation takeoff and landing is executed when the context is created/closed.
-
class
position_hl_commander.
PositionHlCommander
(hl_commander, func_set_param, x=0.0, y=0.0, z=0.0, default_velocity=0.5, default_height=0.5, controller=None, default_landing_height=0.0)[source]¶ The position High Level Commander
Construct an instance of a PositionHlCommander
- Parameters
hl_commander – Instance of HighLevelCommander class
func_set_param – Function object ‘set_param(name, value)’
x – Initial position, x
y – Initial position, y
z – Initial position, z
default_velocity – The default velocity to use
default_height – The default height to fly at
controller – Which underlying controller to use
default_landing_height – Landing height (zero if not specified); for landing on objects off the ground
-
back
(distance_m, velocity=None)[source]¶ Go backwards
- Parameters
distance_m – The distance to travel (meters)
velocity – The velocity of the motion (meters/second)
- Returns
-
down
(distance_m, velocity=None)[source]¶ Go down
- Parameters
distance_m – The distance to travel (meters)
velocity – The velocity of the motion (meters/second)
- Returns
-
forward
(distance_m, velocity=None)[source]¶ Go forward
- Parameters
distance_m – The distance to travel (meters)
velocity – The velocity of the motion (meters/second)
- Returns
-
go_to
(x, y, z=None, velocity=None)[source]¶ Go to a position
- Parameters
x – X coordinate
y – Y coordinate
z – Z coordinate
velocity – The velocity (meters/second)
- Returns
-
land
(velocity=None, landing_height=None)[source]¶ Go straight down and turn off the motors.
Do not call this function if you use the with keyword. Landing is done automatically when the context goes out of scope.
- Parameters
velocity – The velocity (meters/second) when going down
- Returns
-
left
(distance_m, velocity=None)[source]¶ Go left
- Parameters
distance_m – The distance to travel (meters)
velocity – The velocity of the motion (meters/second)
- Returns
-
move_distance
(distance_x_m, distance_y_m, distance_z_m, velocity=None)[source]¶ Move in a straight line. positive X is forward positive Y is left positive Z is up
- Parameters
distance_x_m – The distance to travel along the X-axis (meters)
distance_y_m – The distance to travel along the Y-axis (meters)
distance_z_m – The distance to travel along the Z-axis (meters)
velocity – The velocity of the motion (meters/second)
- Returns
-
right
(distance_m, velocity=None)[source]¶ Go right
- Parameters
distance_m – The distance to travel (meters)
velocity – The velocity of the motion (meters/second)
- Returns
-
set_default_height
(height)[source]¶ Set the default height to use in commands when no height is defined
- Parameters
height – The default height (meters)
- Returns
-
set_default_velocity
(velocity)[source]¶ Set the default velocity to use in commands when no velocity is defined :param velocity: The default velocity (meters/s) :return:
-
set_landing_height
(landing_height)[source]¶ Set the landing height to a specific value Use this function to land on objects that are at non-zero height
-
take_off
(height=None, velocity=None)[source]¶ Takes off, that is starts the motors, goes straight up and hovers. Do not call this function if you use the with keyword. Take off is done automatically when the context is created.
- Parameters
height – The height (meters) to hover at. None uses the default height set when constructed.
velocity – The velocity (meters/second) when taking off
- Returns