MCPcopy Create free account
hub / github.com/bitcraze/crazyflie-lib-python / HighLevelCommander

Class HighLevelCommander

cflib/crazyflie/high_level_commander.py:39–201  ·  view source on GitHub ↗

Used for sending high level setpoints to the Crazyflie

Source from the content-addressed store, hash-verified

37
38
39class HighLevelCommander():
40 """
41 Used for sending high level setpoints to the Crazyflie
42 """
43
44 COMMAND_SET_GROUP_MASK = 0
45 COMMAND_STOP = 3
46 COMMAND_GO_TO = 4
47 COMMAND_START_TRAJECTORY = 5
48 COMMAND_DEFINE_TRAJECTORY = 6
49 COMMAND_TAKEOFF_2 = 7
50 COMMAND_LAND_2 = 8
51
52 ALL_GROUPS = 0
53
54 TRAJECTORY_LOCATION_MEM = 1
55 TRAJECTORY_TYPE_POLY4D = 0
56
57 def __init__(self, crazyflie=None):
58 """
59 Initialize the object.
60 """
61 self._cf = crazyflie
62
63 def set_group_mask(self, group_mask=ALL_GROUPS):
64 """
65 Set the group mask that the Crazyflie belongs to
66
67 :param group_mask: mask for which groups this CF belongs to
68 """
69 self._send_packet(struct.pack('<BB',
70 self.COMMAND_SET_GROUP_MASK,
71 group_mask))
72
73 def takeoff(self, absolute_height_m, duration_s, group_mask=ALL_GROUPS,
74 yaw=0.0):
75 """
76 vertical takeoff from current x-y position to given height
77
78 :param absolute_height_m: absolute (m)
79 :param duration_s: time it should take until target height is
80 reached (s)
81 :param group_mask: mask for which CFs this should apply to
82 :param yaw: yaw (rad). Use current yaw if set to None.
83 """
84 target_yaw = yaw
85 useCurrentYaw = False
86 if yaw is None:
87 target_yaw = 0.0
88 useCurrentYaw = True
89
90 self._send_packet(struct.pack('<BBff?f',
91 self.COMMAND_TAKEOFF_2,
92 group_mask,
93 absolute_height_m,
94 target_yaw,
95 useCurrentYaw,
96 duration_s))

Callers 1

__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected