随手笔记——ROS下joint_state_publisher、robot_state_publisher节点的简要说明

说明

简单记录一下joint_state_publisher、robot_state_publisher节点的功能及使用

笔记

1. 在launch文件中的使用方法

<!-- 运行joint_state_publisher节点,发布机器人的关节状态  -->
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" >
</node> 

<!-- 运行robot_state_publisher节点,发布tf  -->
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"  output="screen" >
    <param name="publish_frequency" type="double" value="50.0" />
</node>

2. joint_state_publisher

joint_state_publisher功能包为机器人发布sensor_msgs/JointState消息,该包从参数服务器读取robot_description参数,查找所有非固定关节,并发布定义了所有这些关节的JointState消息

3. sensor_msgs/JointState消息

File: sensor_msgs/JointState.msg
Raw Message Definition
# This is a message that holds data to describe the state of a set of torque controlled joints.
#
# The state of each joint (revolute or prismatic) is defined by:
# * the position of the joint (rad or m),
# * the velocity of the joint (rad/s or m/s) and
# * the effort that is applied in the joint (Nm or N).
#
# Each joint is uniquely identified by its name
# The header specifies the time at which the joint states were recorded. All the joint states
# in one message have to be recorded at the same time.
#
# This message consists of a multiple arrays, one for each part of the joint state.
# The goal is to make each of the fields optional. When e.g. your joints have no
# effort associated with them, you can leave the effort array empty.
#
# All arrays in this message should have the same size, or be empty.
# This is the only way to uniquely associate the joint name with the correct
# states.

Header header

string[] name
float64[] position
float64[] velocity
float64[] effort

4.关于joint_state_publisher GUI的说明

GUI功能已经从joint_state_publisher包中分离出来,成为其名为joint_state_prublisher_GUI的包。joint_state_publisher中的use_gui参数已删除。
如果要使用GUI功能,joint_state_publisher_gui应作为<exec_depend>添加到package.xml中,并且应更新launch文件以启动joint_state_publisher_gui,而不是使用带有use_gui参数的joint_state_prublisher。

5. robot_state_publisher

robot_state_publisher使用参数robot_description指定的URDF和joint_states (sensor_msgs/JointState)话题中的关节位置来计算机器人的正向运动学,并通过tf发布结果。

### 安装 `joint_state_publisher` 的方法 在 ROS 中安装 `joint_state_publisher` 功能包可以通过系统的包管理工具完成。以下是针对不同 ROS 版本的具体操作: 对于 ROS Humble 用户,可以运行以下命令来安装该功能包: ```bash sudo apt install ros-humble-joint-state-publisher ``` 如果需要同时安装 GUI 工具,则需额外安装对应的 GUI 包: ```bash sudo apt install ros-humble-joint-state-publisher-gui ``` 这一步骤适用于希望可视化关节状态的场景[^1]。 需要注意的是,在较新的 ROS 发布版中,GUI 功能已经被从 `joint_state_publisher` 主包中分离出来,形成独立的功能包 `joint_state_publisher_gui`[^5]。因此,当需要图形界面支持时,必须单独安装此子包。 对于其他 ROS 版本(如 Noetic 或 Melodic),只需将版本名称替换为对应代号即可。例如,在 ROS Noetic 下执行: ```bash sudo apt install ros-noetic-joint-state-publisher sudo apt install ros-noetic-joint-state-publisher-gui ``` 而在 ROS Melodic 下则使用类似的命名方式: ```bash sudo apt-get install ros-melodic-joint-state-publisher sudo apt-get install ros-melodic-joint-state-publisher-gui ``` 以上命令能够解决因缺失依赖而导致无法正常启动节点的问题[^3]。 一旦成功安装这些必要的组件后,就可以通过 launch 文件或者终端直接调用相关节点了。例如,启动默认配置下的 publisher 节点可通过下面的方式实现: ```bash ros2 run joint_state_publisher joint_state_publisher ``` 如果有任何错误提示表明程序崩溃或退出异常,请确认所有必需的软件包均已正确安装并匹配当前使用的 ROS 配置环境[^4]。 #### 注意事项 - 确认系统源列表已更新至最新的 ROS 存储库。 - 使用前检查所选 ROS 发行版是否仍维护以及兼容性问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值