ROS2机器人f1tenth之CLI工具基础

Posted zhangrelay

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ROS2机器人f1tenth之CLI工具基础相关的知识,希望对你有一定的参考价值。

案例适用于ROS2如下三个版本:

  1. humble
  2. galactic
  3. foxy

适用于win/linux/macos。

为何选择f1tenth,延续性,之前使用f1tenth的ros1进行案例讲解。

具体可以参考如下链接:

蓝桥ROS之f1tenth简单PID沿墙跑起来(Python)


ROS2基础教程可以参考:

ROS2机器人个人教程博客汇总(2021共6套)


课程教程迭代更新只有进行时,没有完成时。

f1tenth资源需求量非常小,适合课程教学,并无缝支持云端实践,以此为主。


善于使用各类帮助文档,例如:

ros2 -h

命令会列出所有ros2的CLI命令:

zhangrelay@LAPTOP-5REQ7K1L:~$ ros2 -h
usage: ros2 [-h] [--use-python-default-buffering] Call `ros2 <command> -h` for more detailed usage. ...

ros2 is an extensible command-line tool for ROS 2.

options:
  -h, --help            show this help message and exit
  --use-python-default-buffering
                        Do not force line buffering in stdout and instead use the python default buffering, which
                        might be affected by PYTHONUNBUFFERED/-u and depends on whatever stdout is interactive or not

Commands:
  action     Various action related sub-commands
  bag        Various rosbag related sub-commands
  component  Various component related sub-commands
  daemon     Various daemon related sub-commands
  doctor     Check ROS setup and other potential issues
  interface  Show information about ROS interfaces
  launch     Run a launch file
  lifecycle  Various lifecycle related sub-commands
  multicast  Various multicast related sub-commands
  node       Various node related sub-commands
  param      Various param related sub-commands
  pkg        Various package related sub-commands
  run        Run a package specific executable
  security   Various security related sub-commands
  service    Various service related sub-commands
  topic      Various topic related sub-commands
  wtf        Use `wtf` as alias to `doctor`

  Call `ros2 <command> -h` for more detailed usage.

默认系统环境导入:

source /opt/ros/humble/setup.bash

自定义功能包环境导入,在对应文件夹下:

~/ros_ws/f1tenth_gym_ros$ source install/setup.sh

查看系统变量:

printenv | grep -i ROS 


使用F1tenth和rqt:

~/ros_ws/f1tenth_gym_ros$ ros2 launch f1tenth_gym_ros gym_bridge_launch.py

试一试如下命令:

  • ros2 node list
  • ros2 topic list
  • ros2 service list
  • ros2 action list 
zhangrelay@LAPTOP-5REQ7K1L:~$ ros2 topic list
/bond
/clicked_point
/clock
/cmd_vel
/diagnostics
/drive
/ego_racecar/odom
/ego_robot_description
/goal_pose
/initialpose
/joint_states
/map
/map_server/transition_event
/map_updates
/parameter_events
/rosout
/scan
/tf
/tf_static
zhangrelay@LAPTOP-5REQ7K1L:~$ ros2 service list
/bridge/describe_parameters
/bridge/get_parameter_types
/bridge/get_parameters
/bridge/list_parameters
/bridge/set_parameters
/bridge/set_parameters_atomically
/ego_robot_state_publisher/describe_parameters
/ego_robot_state_publisher/get_parameter_types
/ego_robot_state_publisher/get_parameters
/ego_robot_state_publisher/list_parameters
/ego_robot_state_publisher/set_parameters
/ego_robot_state_publisher/set_parameters_atomically
/lifecycle_manager_localization/describe_parameters
/lifecycle_manager_localization/get_parameter_types
/lifecycle_manager_localization/get_parameters
/lifecycle_manager_localization/is_active
/lifecycle_manager_localization/list_parameters
/lifecycle_manager_localization/manage_nodes
/lifecycle_manager_localization/set_parameters
/lifecycle_manager_localization/set_parameters_atomically
/map_server/change_state
/map_server/describe_parameters
/map_server/get_available_states
/map_server/get_available_transitions
/map_server/get_parameter_types
/map_server/get_parameters
/map_server/get_state
/map_server/get_transition_graph
/map_server/list_parameters
/map_server/load_map
/map_server/map
/map_server/set_parameters
/map_server/set_parameters_atomically
/rviz/describe_parameters
/rviz/get_parameter_types
/rviz/get_parameters
/rviz/list_parameters
/rviz/set_parameters
/rviz/set_parameters_atomically
zhangrelay@LAPTOP-5REQ7K1L:~$ ros2 node list
/bridge
/ego_robot_state_publisher
/lifecycle_manager_localization
/map_server
/rviz
/transform_listener_impl_55c114fc5430
zhangrelay@LAPTOP-5REQ7K1L:~$ ros2 action list

rqt 或 rqt --force-discover

 rqt --help
usage: main.py [-b BINDING] [--clear-config] [-f] [--force-discover] [-h] [-ht] [-l] [-p PERSPECTIVE]
               [--perspective-file PERSPECTIVE_FILE] [--reload-import] [-s PLUGIN] [-t] [-v]
               [--args [PLUGIN_ARGS ...]] [--list-perspectives] [--list-plugins] [--command-pid PID]
               [--command-start-plugin PLUGIN] [--command-switch-perspective PERSPECTIVE]

Options for GUI instance:
  -b BINDING, --qt-binding BINDING
                        choose Qt bindings to be used [pyqt|pyside]
  --clear-config        clear the configuration (including all perspectives and plugin settings)
  -f, --freeze-layout   freeze the layout of the GUI (prevent rearranging widgets, disable undock/redock)
  --force-discover      force a rediscover of plugins
  -h, --help            show this help message and exit
  -ht, --hide-title     hide the title label, the icon, and the help button (combine with -l and -f to eliminate the
                        entire title bar and reclaim the space)
  -l, --lock-perspective
                        lock the GUI to the used perspective (hide menu bar and close buttons of plugins)
  -p PERSPECTIVE, --perspective PERSPECTIVE
                        start with this named perspective
  --perspective-file PERSPECTIVE_FILE
                        start with a perspective loaded from a file
  --reload-import       reload every imported module
  -s PLUGIN, --standalone PLUGIN
                        start only this plugin (implies -l). To pass arguments to the plugin use --args
  -t, --on-top          set window mode to always on top
  -v, --verbose         output qDebug messages
  --args [PLUGIN_ARGS ...]
                        arbitrary arguments which are passes to the plugin (only with -s, --command-start-plugin or
                        --embed-plugin). It must be the last option since it collects all following options.

Options to query information without starting a GUI instance:
  These options can be used to query information about valid arguments for various options.

  --list-perspectives   list available perspectives
  --list-plugins        list available plugins

Options to operate on a running GUI instance:
  These options can be used to perform actions on a running GUI instance.

  --command-pid PID     pid of the GUI instance to operate on, defaults to oldest running GUI instance
  --command-start-plugin PLUGIN
                        start plugin
  --command-switch-perspective PERSPECTIVE
                        switch perspective

Special options for embedding widgets from separate processes:
  These options should never be used on the CLI but only from the GUI code itself.


---


 

以上是关于ROS2机器人f1tenth之CLI工具基础的主要内容,如果未能解决你的问题,请参考以下文章

ROS2机器人笔记22.02.17

机器人编程实践-ROS2基础与应用-第⑦版

ROS2+Gazebo+OpenCV之mobot仿真视觉传感器

FTXUI按键和ROS2 CLI组合使用笔记(turtlesim+teleop)

C++编程中的system终端命令与thread并行基础和进阶(含ROS2 CLI)

ROS2机器人坐标工具→tf2静态广播←Python