RflySimSDK v3.08
RflySimSDK说明文档
载入中...
搜索中...
未找到
CrazyflieServer类 参考

用于广播指令给所有机器人,以及容纳所有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__()

__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()

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()

Getacc ( self,
id )
实现在这里不合适

◆ Getpos()

Getpos ( self,
id )
实现在这里不合适

◆ Getvel()

Getvel ( self,
id )
实现在这里不合适

◆ goTo()

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()

init_poses ( self)

初始化飞行器的起始位置列表。

  • 根据vehicle_num计算出sqrt_num,构建一个sqrt_num x sqrt_num的网格阵列, 并在此网格中为每个飞行器分配初始位置。
+ 这是这个函数的调用关系图:

◆ land()

land ( self,
targetHeight,
duration,
groupMask = 0 )

广播指令让所有匹配groupMask的飞行器降落到指定高度。

  • 异步操作,函数立即返回。 降落结束后使用cmdStop()停机。
    参数
    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.
    

◆ readmsg()

readmsg ( self)

读取消息的占位方法(未实现)。

◆ setParam()

setParam ( self,
name,
value )

广播设置参数命令,参考Crazyflie.setParam()。

  • 参数
    name(str): 参数名称。
    value(Any): 参数新值。
    Broadcasted setParam. See Crazyflie.setParam() for details.

◆ singleGetpos()

singleGetpos ( self,
id )

获取特定ID飞行器的位置,并更新msgg对象的transform.translation以供使用。

  • 参数
    id(int): 飞行器ID。

◆ startTrajectory()

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()

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.
    

该类的文档由以下文件生成: