< >
Home » ROS2与Open-RMF仿真教程#Jazzy版# » ROS2与Open-RMF仿真教程#Jazzy版#-任务调度工具rmf_demos_task

ROS2与Open-RMF仿真教程#Jazzy版#-任务调度工具rmf_demos_task

文章说明

  • 本教程主要介绍rmf_demo_tasks的使用
  • rmf_demo_tasks主要用来在rmf的仿真环境(Office、Hotel world 等)里下发不同类型的任务给机器人
  • 测试环境:Ubuntu 24.04 + ROS2 Jazzy + Gazebo Harmonic 8.9.0

Flexible Tasks

  • 新的任务系统(Task Dispatcher),支持灵活组合不同的任务

1. dispatch_patrol

  • 功能:让机器人执行巡逻任务
  • 特点:可以指定单个或多个巡逻点;可指定机器人车队或者单台机器人(通过 -F-R 参数)
  • 使用场景:适合模拟机器人多点巡逻
  • 详细参数介绍
$ ros2 run rmf_demos_tasks dispatch_patrol -h
usage: dispatch_patrol [-h] -p PLACES [PLACES ...] [-n ROUNDS] [-F FLEET]
                       [-R ROBOT] [-st START_TIME] [-pt PRIORITY]
                       [--use_sim_time] [--requester REQUESTER]

options:
  -h, --help            show this help message and exit
  -p PLACES [PLACES ...], --places PLACES [PLACES ...]
                        Places to patrol through
  -n ROUNDS, --rounds ROUNDS
                        Number of loops to perform
  -F FLEET, --fleet FLEET
                        Fleet name, should define together with robot
  -R ROBOT, --robot ROBOT
                        Robot name, should define together with fleet
  -st START_TIME, --start_time START_TIME
                        Start time from now in secs, default: 0
  -pt PRIORITY, --priority PRIORITY
                        Priority value for this request
  --use_sim_time        Use sim time, default: false
  --requester REQUESTER
                        Entity that is requesting this task
  • Office world场景为例,指定tinyRobot车队的tinyRobot1机器人巡逻lounge地点2次
$ ros2 run rmf_demos_tasks dispatch_patrol -F tinyRobot -R tinyRobot1 -p lounge -n 2 --use_sim_time
  • 连续巡逻suppliespantrycoe三个地点
$ ros2 run rmf_demos_tasks dispatch_patrol -p supplies pantry coe --use_sim_time

2. dispatch_clean

  • 功能:让机器人执行清扫任务
  • 特点:可指定清扫区域(通过 -cs参数),也可指定机器人车队或者单台机器人(通过 -F-R 参数)
  • 使用场景:模拟清扫机器人的任务分配
  • 详细参数介绍
$ ros2 run rmf_demos_tasks dispatch_clean -h
usage: dispatch_clean [-h] -cs CLEAN_START [-F FLEET] [-R ROBOT]
                      [-st START_TIME] [-pt PRIORITY] [--use_sim_time]
                      [--requester REQUESTER]

options:
  -h, --help            show this help message and exit
  -cs CLEAN_START, --clean_start CLEAN_START
                        Cleaning zone
  -F FLEET, --fleet FLEET
                        Fleet name, should define together with robot
  -R ROBOT, --robot ROBOT
                        Robot name, should define together with fleet
  -st START_TIME, --start_time START_TIME
                        Start time from now in secs, default: 0
  -pt PRIORITY, --priority PRIORITY
                        Priority value for this request
  --use_sim_time        Use sim time, default: false
  --requester REQUESTER
                        Entity that is requesting this task
  • Hotel world场景为例,指定指定cleanerBotA车队的cleanerBotA_1机器人清扫clean_lobby区域
$ ros2 run rmf_demos_tasks dispatch_clean -cs clean_lobby -F cleanerBotA -R cleanerBotA_1 --use_sim_time

3. dispatch_action

  • 功能:让机器人执行 PerformAction 类型的动作(例如临时介入键盘控制)。-a
  • 特点
    • 机器人先移动到指定点(通过-s参数),再进入某种动作模式(通过-a参数)
    • RMF系统放弃对机器人的控制,用户可手动接管(比如进行键盘控制)
    • 完成后需要手动发ModeRequest恢复控制
  • 使用场景:模拟用户需要临时接管机器人,完成特殊动作
  • 详细参数介绍
$ ros2 run rmf_demos_tasks dispatch_action -h
usage: dispatch_action [-h] [-s STARTS [STARTS ...]] [-st START_TIME]
                       [-pt PRIORITY] -a ACTION [-ad ACTION_DESC] [-F FLEET]
                       [-R ROBOT] [--use_sim_time] [--use_tool_sink]
                       [--requester REQUESTER]

options:
  -h, --help            show this help message and exit
  -s STARTS [STARTS ...], --starts STARTS [STARTS ...]
                        Action start waypoints
  -st START_TIME, --start_time START_TIME
                        Start time from now in secs, default: 0
  -pt PRIORITY, --priority PRIORITY
                        Priority value for this request
  -a ACTION, --action ACTION
                        action name
  -ad ACTION_DESC, --action_desc ACTION_DESC
                        action description in json str
  -F FLEET, --fleet FLEET
                        Fleet name, should define together with robot
  -R ROBOT, --robot ROBOT
                        Robot name, should define together with fleet
  --use_sim_time        Use sim time, default: false
  --use_tool_sink       Use tool sink during perform action, default: false
  --requester REQUESTER
                        Entity that is requesting this task

  • Office world场景为例,指定tinyRobot车队的tinyRobot1机器人先移动到coe地点再切换到键盘控制模式
$ ros2 run rmf_demos_tasks dispatch_action -F tinyRobot -R tinyRobot1 -a teleop -s coe --use_sim_time
  • 键盘控制结束之后,需要发布以下消息以将控制权归还给RMF
$ ros2 topic pub /action_execution_notice rmf_fleet_msgs/msg/ModeRequest '{fleet_name:  tinyRobot, robot_name: tinyRobot1, mode: {mode: 0}}' --once
  • coesuppliespantry地点再切换到键盘控制模式
$ ros2 run rmf_demos_tasks dispatch_action -a teleop -s coe supplies pantry --use_sim_time

4.dispatch_delivery

  • 功能:执行配送任务
  • 特点:支持多个pickup&drop-off,任务通过活动序列 (-p / -d / -pp / -dp参数)组合
  • 详细参数介绍
$ ros2 run rmf_demos_tasks dispatch_delivery -h
usage: dispatch_delivery [-h] -p PICKUPS [PICKUPS ...] -d DROPOFFS
                         [DROPOFFS ...] -ph PICKUP_HANDLERS
                         [PICKUP_HANDLERS ...] -dh DROPOFF_HANDLERS
                         [DROPOFF_HANDLERS ...]
                         [-pp PICKUP_PAYLOADS [PICKUP_PAYLOADS ...]]
                         [-dp DROPOFF_PAYLOADS [DROPOFF_PAYLOADS ...]]
                         [-F FLEET] [-R ROBOT] [-st START_TIME] [-pt PRIORITY]
                         [--use_sim_time] [--requester REQUESTER]

options:
  -h, --help            show this help message and exit
  -p PICKUPS [PICKUPS ...], --pickups PICKUPS [PICKUPS ...]
                        Pickup names
  -d DROPOFFS [DROPOFFS ...], --dropoffs DROPOFFS [DROPOFFS ...]
                        Dropoff names
  -ph PICKUP_HANDLERS [PICKUP_HANDLERS ...], --pickup_handlers PICKUP_HANDLERS [PICKUP_HANDLERS ...]
                        Pickup handler names
  -dh DROPOFF_HANDLERS [DROPOFF_HANDLERS ...], --dropoff_handlers DROPOFF_HANDLERS [DROPOFF_HANDLERS ...]
                        Dropoffs handler names
  -pp PICKUP_PAYLOADS [PICKUP_PAYLOADS ...], --pickup_payloads PICKUP_PAYLOADS [PICKUP_PAYLOADS ...]
                        Pickup payload [sku,quantity sku2,qty...]
  -dp DROPOFF_PAYLOADS [DROPOFF_PAYLOADS ...], --dropoff_payloads DROPOFF_PAYLOADS [DROPOFF_PAYLOADS ...]
                        Dropoff payload [sku,quantity sku2,qty...]
  -F FLEET, --fleet FLEET
                        Fleet name, should define together with robot
  -R ROBOT, --robot ROBOT
                        Robot name, should define together with fleet
  -st START_TIME, --start_time START_TIME
                        Start time from now in secs, default: 0
  -pt PRIORITY, --priority PRIORITY
                        Priority value for this request
  --use_sim_time        Use sim time, default: false
  --requester REQUESTER
                        Entity that is requesting this task

  • Office world场景为例,机器人跑两趟储藏室从coke_dispensercoke_dispenser_2分别取1支可乐,然后分别送去 hardware_2coe地点,分别对应交给coke_ingestorcoke_ingestor_2各1支可乐
$ ros2 run rmf_demos_tasks dispatch_delivery \
-p pantry pantry \
-ph coke_dispenser coke_dispenser_2 \
-d hardware_2 coe \
-dh coke_ingestor coke_ingestor_2 \
-pp coke,1 coke,1 \
-dp coke,1 coke,1 \
--use_sim_time

5.cancel_task / cancel_robot_task

  • 功能:前者按任务ID取消任务,后者取消特定机器人正在执行的任务
  • 使用场景:模拟任务取消、抢占
  • 详细参数:
$ ros2 run rmf_demos_tasks cancel_task -h
usage: cancel_task [-h] -id TASK_ID

options:
  -h, --help            show this help message and exit
  -id TASK_ID, --task_id TASK_ID
                        Cancel Task ID

$ ros2 run rmf_demos_tasks cancel_robot_task -h
usage: cancel_robot_task [-h] [-R ROBOT] [-F FLEET] [--timeout TIMEOUT]

options:
  -h, --help            show this help message and exit
  -R ROBOT, --robot ROBOT
                        Robot name, should define together with fleet
  -F FLEET, --fleet FLEET
                        fleet name
  --timeout TIMEOUT     Timeout seconds
  • 示例1,以Office world场景为例,运行一个巡逻任务
$ ros2 run rmf_demos_tasks dispatch_patrol -p coe lounge --use_sim_time
  • 取消指定ID的任务
$ ros2 run rmf_demos_tasks cancel_task -id patrol.dispatch-0
  • 示例2,以Office world场景为例,指定tinyRobot车队的tinyRobot1机器人移动到指定地点
$ ros2 run rmf_demos_tasks dispatch_go_to_place -p pantry -F tinyRobot -R tinyRobot2 --use_sim_time
  • 取消指定机器人的任务
$ ros2 run rmf_demos_tasks cancel_robot_task -F tinyRobot -R tinyRobot2

Additional Scripts

1.office_teleop_robot

  • 功能:在office world里进行键盘控制机器人
  • 特点:直接控制机器人,而不是通过 fleet adapter
  • 使用场景:展示dispatch_action下发teleop控制指令 后,用户再手动操作机器人
  • Office world场景为例,指定tinyRobot车队的tinyRobot1机器人先移动到coe地点再切换到键盘控制模式
$ ros2 run rmf_demos_tasks dispatch_action -F tinyRobot -R tinyRobot1 -a teleop -s coe --use_sim_time
  • 启动键盘控制
$ ros2 launch rmf_demos office_teleop_robot.launch.xml
  • 键盘控制结束之后,需要发布以下消息以将控制权归还给RMF
$ ros2 topic pub /action_execution_notice rmf_fleet_msgs/msg/ModeRequest '{fleet_name:  tinyRobot, robot_name: tinyRobot1, mode: {mode: 0}}' --once

2.dispatch_go_to_place

  • 功能:让机器人去一个指定目标点
  • 特点:可设置目标姿态(朝向需设置-o),也支持指定机器人
  • 使用场景:单点导航任务
  • 详细参数介绍
$ ros2 run rmf_demos_tasks  dispatch_go_to_place -h
usage: dispatch_go_to_place [-h] [-F FLEET] [-R ROBOT] -p PLACE [PLACE ...]
                            [-o ORIENTATION] [-m] [-st START_TIME]
                            [-pt PRIORITY] [--use_sim_time]
                            [--requester REQUESTER]

options:
  -h, --help            show this help message and exit
  -F FLEET, --fleet FLEET
                        Fleet name
  -R ROBOT, --robot ROBOT
                        Robot name
  -p PLACE [PLACE ...], --place PLACE [PLACE ...]
                        Place to go to
  -o ORIENTATION, --orientation ORIENTATION
                        Orientation to face in degrees (optional)
  -m, --prefer-same-map
                        When choosing between multiple destination options,
                        prefer an option on the same map as the starting
                        location.
  -st START_TIME, --start_time START_TIME
                        Start time from now in secs, default: 0
  -pt PRIORITY, --priority PRIORITY
                        Priority value for this request
  --use_sim_time        Use sim time, default: false
  --requester REQUESTER
                        Entity that is requesting this task
  • Office world场景为例,让系统分配机器人移动到lounge地点且指定朝向
$ ros2 run rmf_demos_tasks  dispatch_go_to_place -p lounge -o 105 --use_sim_time

参考资料

  • https://github.com/open-rmf/rmf_demos/blob/jazzy/rmf_demos_tasks/README.md

纠错,疑问,交流: 请进入讨论区点击加入Q群

获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号


标签: none