相关文章推荐
焦虑的皮带  ·  10.1. robomaster package·  3 月前    · 
  • 1. Introduction
  • 2. Programming Environment Installation
  • 3. Third-party Platform Communication
  • RoboMaster SDK Description

  • 1. Install RoboMaster SDK
  • 2. Download RoboMaster SDK Source Code
  • 3. Connect the RoboMaster SDK with Robots
  • 4. Getting Started with RoboMaster SDK - Basics
  • 5. Getting Started with the RoboMaster SDK - EP
  • 6. Getting Started with the RoboMaster SDK - Education-series Drones
  • 7. Getting Started with the RoboMaster SDK - Multi-device Control
  • 8. Logging for the RoboMaster SDK
  • 9. RoboMaster SDK APIs
  • 10. Detailed Description of RoboMaster SDK APIs
    • 10.1. robomaster package
      • 10.1.1. robomaster.action
      • 10.1.2. robomaster.armor
      • 10.1.3. robomaster.battery
      • 10.1.4. robomaster.blaster
      • 10.1.5. robomaster.camera
      • 10.1.6. robomaster.chassis
      • 10.1.7. robomaster.exceptions
      • 10.1.8. robomaster.flight
      • 10.1.9. robomaster.gimbal
      • 10.1.10. robomaster.gripper
      • 10.1.11. robomaster.led
      • 10.1.12. robomaster.robot
      • 10.1.13. robomaster.robotic_arm
      • 10.1.14. robomaster.sensor
      • 10.1.15. robomaster.servo
      • 10.1.16. robomaster.uart
      • 10.1.17. robomaster.version
      • 10.1.18. robomaster.vision
      • 10.1.19. Module contents
      • 11. Summary of RoboMaster SDK Multi-device APIs
      • 12. Implement Multi-device Formation for TT by Using the RoboMaster SDK
      • 13. Implement Multi-device Formation for EP by Using the RoboMaster SDK
      • Extended Module/Interface Description

      • 1. Mechanical Arm and Mechanical Gripper
      • 2. Servo
      • 3. Infrared Distance Sensor
      • 4. Sensor Adapter
      • 5. UART Interface
      • Plaintext SDK Description

      • 1. Introduction to the Plaintext SDK
      • 2. Access Methods
      • 3. Plaintext Protocol
      • 4. Formation Control
      • Python Programming Description

      • 1. Introduction to Python Programming
      • 2. Introduction to Python Functions
      • 3. Python API
      • Version Description

      • Version Description
      • class robomaster.action. TextAction ( **kw )

        Bases: robomaster.action.Action

        Blocking action in plaintext protocol

        wait_for_completed ( timeout=None )

        等待任务动作直到完成

        Parameters: comp – enum (“bottom_back”, “bottom_front”, “bottom_left”, “bottom_right”, “top_left”, “top_right”) 装甲部位 Returns:int: [1, 6] 装甲ID Parameters:
        • comp – enum:(“all”, “top_all”, “bottom_all”, “top_left”, “top_right”, “bottom_left”, “bottom_right”, “bottom_front”, “bottom_back”):要设置的装甲部位
        • sensitivity – int:[0, 10] 灵敏度系数,系数越大灵敏度越低
        • Returns:

          bool:返回调用结果

          class robomaster.camera. EPCamera ( robot )

          Bases: robomaster.module.Module , robomaster.camera.Camera

          EP 摄像机模块

          audio_stream_addr

          机器人音频流地址

          class robomaster.camera. TelloCamera ( robot )

          Bases: robomaster.camera.Camera

          教育无人机 摄像机模块

          read_cv2_image ( timeout=3 , strategy='pipeline' )

          读取一帧视频流帧

          class robomaster.chassis. Chassis ( robot )

          Bases: robomaster.module.Module

          EP 底盘模块,可以控制底盘的速度、位置、订阅底盘的数据,控制麦克纳姆轮等操作

          drive_speed ( x=0.0 , y=0.0 , z=0.0 , timeout=None )

          设置底盘速度,立即生效

          Parameters:
          • x – float:[-3.5,3.5],x 轴向运动速度即前进速度,单位 m/s
          • y – float:[-3.5,3.5],y 轴向运动速度即横移速度,单位 m/s
          • z – float:[-600,600],z 轴向运动速度即旋转速度,单位 °/s
          • timeout – float:(0,inf),超过指定时间内未收到麦轮转速指令,主动控制机器人停止,单位 s
          • Parameters:
            • w1 – int:[-1000,1000],右前麦轮速度,以车头方向前进旋转为正方向,单位 rpm
            • w2 – int:[-1000,1000],左前麦轮速度,以车头方向前进旋转为正方向,单位 rpm
            • w3 – int:[-1000,1000],左后麦轮速度,以车头方向前进旋转为正方向,单位 rpm
            • w4 – int:[-1000,1000],右后麦轮速度,以车头方向前进旋转为正方向,单位 rpm
            • timeout – float:(0,inf),超过指定时间内未收到麦轮转速指令,主动控制机器人停止,单位 s
            • x – float: [-5,5],x轴向运动距离,单位 m
            • y – float: [-5,5],y轴向运动距离,单位 m
            • z – float: [-1800,1800],z轴向旋转角度,单位 °
            • xy_speed – float: [0.5,2],xy轴向运动速度,单位 m/s
            • z_speed – float: [10,540],z轴向旋转速度,单位 °/s
            • Returns:

              返回action对象

              set_pwm_value ( pwm1=None , pwm2=None , pwm3=None , pwm4=None , pwm5=None , pwm6=None )

              设置PWM输出占空比

            • pwm1 – int:[0,100],pwm输出占空比,单位%
            • pwm2 – int:[0,100],pwm输出占空比,单位%
            • pwm3 – int:[0,100],pwm输出占空比,单位%
            • pwm4 – int:[0,100],pwm输出占空比,单位%
            • pwm5 – int:[0,100],pwm输出占空比,单位%
            • pwm6 – int:[0,100],pwm输出占空比,单位%
            • Parameters:
              • cs – int: [0,1] 设置底盘位置的坐标系,0 机器人当前位置,1 机器人上电位置
              • freq – enum: (1, 5, 10, 20, 50) 设置数据订阅数据的推送频率,单位 Hz
              • callback

                回调函数,返回数据 (x, y, z):

                exception robomaster.exceptions. TimeOutError

                Bases: robomaster.exceptions.SDKException

                Remote Call Timeout.

                with_traceback ( )

                Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

                curve ( x1=0 , y1=0 , z1=0 , x2=0 , y2=0 , z2=0 , speed=20 , mid=None , retry=True )

                以设置速度飞弧线,经过对应坐标系中的(x1, y1, z1)点到(x2, y2, z2)点

                如果选用mid参数,则对应坐标系为指定挑战卡的坐标系。不使用挑战卡时,飞机的前方为x轴正方向,飞机的左方为y轴的正方向 如果mid参数为默认值None,则为飞机自身坐标系

                Param:y1: float:[-500, 500] y轴坐标 Param:z1: float:如果使用挑战卡(mid不为None),取值范围为 [0, 500]; 如果不使用挑战卡(mid为None),取值范围为[-500, 500] Param:x2: float:[-500, 500] x轴坐标 Param:y2: float:[-500, 500] y轴坐标 Param:z2: float:如果使用挑战卡(mid不为None),取值范围为 [0, 500]; 如果不使用挑战卡(mid为None),取值范围为[-500, 500] Param:speed: float:[10, 60] 飞行的速度 Param:mid: string: 不使用挑战卡时mid为None,运动坐标系为飞机自身坐标系;当使用挑战卡时mid为对应挑战卡编号,运动坐标系为对应挑战卡 坐标系。挑战卡编号参考挑战卡使用说明 Param:retry: bool:是否重发命令 Returns:action对象

                控制飞机向指定方向翻滚

                当电量低于50%时无法完成翻滚 :param direction: string: 飞机翻转的方向, ’l‘ 向左翻滚,’r‘ 向右翻滚,’f‘ 向前翻滚, ’b‘ 向后翻滚 :param: retry: bool:是否重发命令 :return: action对象

                Param:direction: string: 飞行的方向,”forward” 向上飞行, “back” 向下飞行, “up” 向上飞行, “down” 向下飞行, “left” 向左飞行, “right” 向右飞行 Param:distance: float:[20, 500],飞行的距离,单位 cm Param:retry: bool:是否重发命令 Returns:action对象 Param:speed: float: [10, 100] 运动速度, 单位 cm/s Param:mid: string: 不使用挑战卡时mid为None,运动坐标系为飞机自身坐标系;当使用挑战卡时mid为对应挑战卡编号, 运动坐标系为指定挑战卡的坐标系。支持编号可参考挑战卡使用说明。 Param:retry: bool:是否重发命令 Returns:action对象 Param:yaw: [-360, 360] 最终悬停的yaw轴角度, 单位 ° Param:mid1: string: 第一个挑战卡的id, 挑战卡id的介绍参考挑战卡使用说明 Param:mid2: string: 第一个挑战卡的id, 挑战卡id的介绍参考挑战卡使用说明 Param:retry: bool:是否重发命令 Returns:action对象 Param:x: float:[-500, 500],目标位置在挑战卡坐标系中的x坐标,实际取值范围要根据挑战卡大小调整,单位 cm Param:y: float:[-500, 500],目标位置在挑战卡坐标系中的y坐标,实际取值范围要根据挑战卡大小调整,单位 cm Param:z: float:[-500, 500],目标位置在挑战卡坐标系中的z坐标,实际取值范围要根据挑战卡大小调整,单位 cm Param:speed: int:[10, 100],运动速度,单位 cm/s Param:mid: string: 挑战卡的编号,支持编号可参考挑战卡使用说明 Param:retry: bool:是否重发命令 Returns:action对象
              • pitch – float: [-55, 55],pitch 轴角度,单位 °
              • yaw – float: [-55, 55],yaw 轴角度,单位 °
              • pitch_speed – float: [0, 540],pitch 轴运动速速,单位 °/s
              • yaw_speed – float: [0, 540],yaw 轴运动速度,单位 °/s
              • Returns:

                返回action对象

              • pitch – int: [-25, 30],pitch 轴角度,单位 °
              • yaw – int: [-250, 250],yaw 轴角度,单位 °
              • pitch_speed – int: [0, 540],pitch 轴运动速度,单位 °
              • yaw_speed – int: [0, 540],yaw 轴运动速度,单位 °
              • Returns:

                返回action对象

                set_gimbal_led ( comp='top_all', r=255, g=255, b=255, led_list=[0, 1, 2, 3], effect='on' )

                设置云台灯效

                Parameters:
                • comp – enum: (“top_all”, “top_left”, “top_right”),云台部位
                • r – int: [0, 255],RGB红色分量值
                • g – int: [0, 255],RGB绿色分量值
                • b – int: [0, 255],RGB蓝色分量值
                • led_list – list [idx0, idx1, …],idx:int[0,7] 云台灯序号列表.
                • effect – enum: (“on”, “off”),灯效类型
                • Returns:

                  bool: 调用结果

                  Parameters:
                  • comp – enum: (“all”, “top_all”, “top_right”, “top_left”, “bottom_all”, “bottom_front”, “bottom_back”, “bottom_left”, “bottom_right”) 灯效部位,all: 所有装甲灯;top_all:云台所有装甲灯; top_right: 云台右侧装甲灯;top_left: 云台左侧装甲灯; bottom_all: 底盘所有装甲灯;bottom_front: 前装甲灯; bottom_back: 后装甲灯;bottom_left: 左装甲灯;bottom_right: 右装甲灯
                  • r – int: [0~255],RGB红色分量值
                  • g – int: [0~255],RGB绿色分量值
                  • b – int: [0~255],RGB蓝色分量值
                  • effect – enum: (“on”, “off”, “flash”, “breath”, “scrolling”) 灯效类型,on:常亮;off:常灭;flash:闪烁; breath:呼吸;scrolling:跑马灯(仅对云台灯有效)
                  • freq – int: [1, 10],闪烁频率,仅对闪烁灯效有效
                  • Returns:

                    bool:调用结果

                    class robomaster.robot. Robot ( cli=None )

                    Bases: robomaster.robot.RobotBase

                    RoboMaster EP 机甲大师 机器人

                    battery

                    获取电池模块对象

                    Parameters: name – 模块名称,字符串,如:chassis, gimbal, led, blaster, camera, battery, vision, etc. Returns:模块对象 Parameters: name – string:需要获取的状态名,可列表[“MID”, “x”, “y”, “z”, “mpry”, “pitch”, “roll”, “yaw”, “vgx”, “vgy”, “vgz”, “templ”, “temph”, “tof”, “h”, “bat”, “baro”, “time”, “agx”, “agy”, “agz”],详细介绍 参考SDK使用文档 Returns:name对应状态的数据值,DDS_PAD_MPRY_FLAG 对应状态的返回值为长度为3的list,分别代表的在飞机相对挑战卡的pitch、yaw、row值, 其他状态返回的都是float数据 get_subnets ( )

                    Look through the machine’s internet connection and returns subnet addresses and server ip :return: list[str]: subnets

                    list[str]: addr_list
                    class robomaster.robotic_arm. RoboticArm ( robot )

                    Bases: robomaster.module.Module

                    EP 机械臂 模块

                    get_version ( )

                    获取模块版本号

                    :return:字符串,格式为:AA.BB.CC.DD

                    class robomaster.sensor. DistanceSensor ( robot )

                    Bases: robomaster.module.Module

                    EP 距离传感器模块

                    get_version ( )

                    获取模块版本号

                    :return:字符串,格式为:AA.BB.CC.DD

                    serial_param_set ( baud_rate=0 , data_bit=1 , odd_even=0 , stop_bit=0 , rx_en=1 , tx_en=1 , rx_size=50 , tx_size=50 )

                    底盘串口参数设置

                    默认设置:’9600’, ‘bit8’, ‘none’, ‘1’

                    Parameters:
                    • baud_rate – 串口波特率,设置范围:0~4映射‘9600’,‘19200’,‘38400’,‘57600’,‘115200’
                    • data_bit – 数据位设置,设置范围:0~3映射‘bit7’, ‘bit8’, ‘bit9’, ‘bit10’
                    • odd_even – 数据校验位,设置范围:0~3映射‘none’, ‘odd’, ‘even’
                    • stop_bit – 停止位,设置范围:1~2
                    • rx_en – 接收使能
                    • tx_en – 发送使能
                    • rx_size – 接收buff大小
                    • tx_size – 发送buff大小
                    • Returns:

                      返回串口设置结果

                      Parameters:
                      • name – enum: (“person”, “gesture”, “line”, “marker”, “robot”),person 行人,gesture 手势,line 线识别, marker 标签识别,robot 机器人识别
                      • color – enum:(“red”, “green”, “blue”): 指定识别颜色,仅线识别和标签识别时生效
                      • callback

                        回调函数,返回数据 (list(rect_info)):

                        rect_info:包含的信息如下: person 行人识别:(x, y, w, h), x 中心点x轴坐标,y 中心点y轴坐标,w 宽度,h 高度 gesture 手势识别:(x, y, w, h), x 中心点x轴坐标,y 中心点y轴坐标,w 宽度,h 高度 line 线识别:(x, y, theta, C),x点x轴坐标,y点y轴坐标,theta切线角,C 曲率 marker 识别:(x, y, w, h, marker), x 中心点x轴坐标,y 中心点y轴坐标,w 宽度,h 高度,marker 识别到的标签 robot 机器人识别:(x, y, w, h),x 中心点x轴坐标,y 中心点y轴坐标,w 宽度,h 高度
  •