用于广播指令给所有机器人,以及容纳所有Crazyflie对象的服务器类。 更多...
Public 成员函数 | |
__init__ (self, crazyflies_yaml="../launch/crazyflies.yaml", num=1, ids=None, mode=7) | |
构造函数,初始化CrazyflieServer。 | |
init_poses (self) | |
初始化飞行器的起始位置列表。 | |
emergency (self) | |
紧急停止所有飞行器,切断电源并忽略后续指令。 | |
takeoff (self, targetHeight, duration, groupMask=0) | |
广播指令让所有匹配groupMask的飞行器起飞到指定高度并悬停。 | |
land (self, targetHeight, duration, groupMask=0) | |
广播指令让所有匹配groupMask的飞行器降落到指定高度。 | |
goTo (self, goal, yaw, duration, groupMask=0) | |
广播goTo指令,让所有匹配groupMask的飞行器同时移动到目标点。 | |
startTrajectory (self, trajectoryId, timescale=1.0, reverse=False, relative=True, groupMask=0) | |
广播开始执行已上传的轨迹。 | |
setParam (self, name, value) | |
广播设置参数命令,参考Crazyflie.setParam()。 | |
readmsg (self) | |
读取消息的占位方法(未实现)。 | |
singleGetpos (self, id) | |
获取特定ID飞行器的位置,并更新msgg对象的transform.translation以供使用。 | |
Getpos (self, id) | |
Getvel (self, id) | |
Getacc (self, id) | |
Public 属性 | |
vehicle_num | |
ini_poses | |
interval | |
init_height | |
crazyflies | |
crazyfliesById | |
tf | |
msgg | |
用于广播指令给所有机器人,以及容纳所有Crazyflie对象的服务器类。
Object for broadcasting commands to all robots at once. Also is the container for the individual :obj:`Crazyflie` objects. Attributes: crazyfliesById (Dict[int, Crazyflie]): Index to the same Crazyflie objects by their ID number (last byte of radio address).
CrazyflieServer通过解析YAML文件或字符串,从而初始化多个Crazyflie对象并维护其引用。 提供批量指令接口(如同时起飞、降落、GoTo等)实现多机同步动作。
__init__ | ( | self, | |
crazyflies_yaml = "../launch/crazyflies.yaml", | |||
num = 1, | |||
ids = None, | |||
mode = 7 ) |
构造函数,初始化CrazyflieServer。
crazyflies_yaml | (str): 配置文件路径或YAML字符串。 |
num | (int): 飞行器数量,默认1。 |
ids | (list[int]): 飞行器ID列表,如果为空则按照1开始递增分配ID。 |
mode | (int): 控制模式,影响构建Crazyflie实例的方式。 |
Initialize the server. Waits for all ROS services before returning. Args: crazyflies_yaml (str): If ends in ".yaml", interpret as a path and load from file. Otherwise, interpret as YAML string and parse directly from string.
emergency | ( | self | ) |
紧急停止所有飞行器,切断电源并忽略后续指令。
Emergency stop. Cuts power; causes future commands to be ignored. This command is useful if the operator determines that the control script is flawed, and that continuing to follow it will cause wrong/ self-destructive behavior from the robots. In addition to cutting power to the motors, it ensures that any future commands, both high- level and streaming, will have no effect. The only ways to reset the firmware after an emergency stop has occurred are a physical hard reset or an nRF51 Reboot command.
Getacc | ( | self, | |
id ) |
实现在这里不合适
Getpos | ( | self, | |
id ) |
实现在这里不合适
Getvel | ( | self, | |
id ) |
实现在这里不合适
goTo | ( | self, | |
goal, | |||
yaw, | |||
duration, | |||
groupMask = 0 ) |
广播goTo指令,让所有匹配groupMask的飞行器同时移动到目标点。
goal | (iterable of float[3]): 目标点偏移(米)。 |
yaw | (float): 目标偏航角(弧度)。 |
duration | (float): 达到目标点所需时间(秒)。 |
groupMask | (int): 组掩码。 |
Broadcasted goTo - Move smoothly to goal, then hover indefinitely. Broadcast version of :meth:`Crazyflie.goTo()`. All robots that match the groupMask start moving at exactly the same time. Use for synchronized movement. Asynchronous command; returns immediately. While the individual goTo() supports both relative and absolute coordinates, the broadcasted goTo only makes sense with relative coordinates (since absolute broadcasted goTo() would cause a collision). Therefore, there is no `relative` kwarg. See docstring of :meth:`Crazyflie.goTo()` for additional details. Args: goal (iterable of 3 floats): The goal offset. Meters. yaw (float): The goal yaw angle (heading). Radians. duration (float): How long until the goal is reached. Seconds. groupMask (int): Group mask bits. See :meth:`Crazyflie.setGroupMask()` doc.
init_poses | ( | self | ) |
land | ( | self, | |
targetHeight, | |||
duration, | |||
groupMask = 0 ) |
广播指令让所有匹配groupMask的飞行器降落到指定高度。
targetHeight | (float): 降落目标高度(米),通常略高于起点以避免地面误差。 |
duration | (float): 达到目标高度所需时间(秒)。 |
groupMask | (int): 组掩码。 |
Broadcasted landing - fly straight down. User must cut power after. Broadcast version of :meth:`Crazyflie.land()`. All robots that match the groupMask land at exactly the same time. Use for synchronized movement. Asynchronous command; returns immediately. Args: targetHeight (float): The z-coordinate at which to land. Meters. Usually should be a few centimeters above the initial position to ensure that the controller does not try to penetrate the floor if the mocap coordinate origin is not perfect. duration (float): How long until the height is reached. Seconds. groupMask (int): Group mask bits. See :meth:`Crazyflie.setGroupMask()` doc.
setParam | ( | self, | |
name, | |||
value ) |
startTrajectory | ( | self, | |
trajectoryId, | |||
timescale = 1.0, | |||
reverse = False, | |||
relative = True, | |||
groupMask = 0 ) |
广播开始执行已上传的轨迹。
trajectoryId | (int): 轨迹ID,对应uploadTrajectory的ID。 |
timescale | (float): 时间缩放因子。 |
reverse | (bool): 若True,则反向执行轨迹。 |
relative | (bool): 若True,则轨迹相对于当前位置偏移执行。 |
groupMask | (int): 组掩码。 |
Broadcasted - begins executing a previously uploaded trajectory. Broadcast version of :meth:`Crazyflie.startTrajectory()`. Asynchronous command; returns immediately. Args: trajectoryId (int): ID number as given to :meth:`Crazyflie.uploadTrajectory()`. timescale (float): Scales the trajectory duration by this factor. For example if timescale == 2.0, the trajectory will take twice as long to execute as the nominal duration. reverse (bool): If true, executes the trajectory backwards in time. relative (bool): If true (default), the position of the trajectory is shifted such that it begins at the current position setpoint. groupMask (int): Group mask bits. See :meth:`Crazyflie.setGroupMask()` doc.
takeoff | ( | self, | |
targetHeight, | |||
duration, | |||
groupMask = 0 ) |
广播指令让所有匹配groupMask的飞行器起飞到指定高度并悬停。
targetHeight | (float): 起飞后的悬停高度(米)。 |
duration | (float): 达到目标高度所需时间(秒)。 |
groupMask | (int): 组掩码,用于同时控制子集飞行器。 |
Broadcasted takeoff - fly straight up, then hover indefinitely. Broadcast version of :meth:`Crazyflie.takeoff()`. All robots that match the groupMask take off at exactly the same time. Use for synchronized movement. Asynchronous command; returns immediately. Args: targetHeight (float): The z-coordinate at which to hover. duration (float): How long until the height is reached. Seconds. groupMask (int): Group mask bits. See :meth:`setGroupMask()` doc.