当前位置:网站首页>ROS2的topic pub 指令出现:Failed to populate field: ‘Vector3‘ object has no attribute ‘x:1‘错误
ROS2的topic pub 指令出现:Failed to populate field: ‘Vector3‘ object has no attribute ‘x:1‘错误
2022-07-23 04:31:00 【无水先生】
1 指令ros2 topic pub的潜规则
在yaml格式输入的指令中,其格式中有某些细节需要注意;比如,一个小小的空格就能影响,本文是作者在执行此类命令时,发现的yaml格式中的“潜规则”。
在测试小海龟运动时,用指令:
ros2 topic pub /turtle1/cmd_vel geometry_msgs/msg/Twist "{linear:{x=5,y=5,z:0},angular:{x=0,y=0,z=3.14}}"出现下面提示:
Failed to populate field: 'Vector3' object has no attribute 'x:5'
这是什么原因呢?是因为

2 正确的输入格式如下:
ros2 topic pub --once /turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.8}}"3 对应的Python程序实现
如:我正在尝试使用 RosAria 向 Pioneer P3-AT(编辑:3-AT 或 P3-AT,两个名称都使用)发送命令。我知道 RosAria 可以工作,因为当我在终端时,我可以使用以下命令移动机器人:
import rclpy
from geometry_msgs.msg import Twist
topic = rospy.Publisher('/RosAria/cmd_vel', Twist, queue_size=10)
linear = [ 0, 0, 0 ]
angular = [ 0, 0, 0 ]
rospy.sleep(1) # waiting for subscribers
test = topic.publish(linear, angular)又发生类似的错误提示,
Traceback (most recent call last):
File "robotControl.py", line 32, in startServer
test = topic.publish(linear, angular)
packages/geometry_msgs/msg/_Twist.py", line 71, in serialize
buff.write(_get_struct_6d().pack(_x.linear.x, _x.linear.y, _x.linear.z, _x.angular.x, _x.angular.y, _x.angular.z))
AttributeError: 'list' object has no attribute 'x'当我使用集合或 numpy 数组时,也会出现同样的错误。如果我尝试以另一种格式(不是两个列表)发布值,则会给出不期望格式的错误。从任一列表中添加或删除条目也不能解决此错误。
以上代码请大家自己试试,看能否调通。
边栏推荐
- 2022/7/22
- 第四篇章:运行时数据区——共享空间
- ANTLR4 入门学习(一):下载和测试
- hbv参数提取和拟合[草稿]
- 推荐一款 Shell 装逼神器,已开源!网友:真香。。。
- Industry insight | how to better build a data center? It and business should "go together"
- Add trust list
- SAP batch import template (WBS batch import as an example)
- 04_ UE4 advanced_ Introduction to physical collision and firing fireballs
- 记一次 .NET 某智能交通后台服务 CPU爆高分析
猜你喜欢

SQLZOO——SELECT from WORLD Tutorial

Clion + mingw64 configure C language development environment visual studio installation

Meituan's 8-year experience on how to improve test engineers (automation, performance, test development)

SQLZOO——SELECT Quiz

What is file management software? Why do you need it?

7.< tag-动态规划和买卖股票合集>lt.121. 买卖股票的最佳时机 + lt.122.买卖股票的最佳时机 II+ lt.123. 买卖股票的最佳时机 III dbc

PyQt5_pyqtgraph鼠标在折线图上画线段

How does VirtualBox set up port forwarding?

数据湖:Delta Lake介绍

推荐一款 Shell 装逼神器,已开源!网友:真香。。。
随机推荐
chrome selenium 用默认profile 不必每次清空
Kingbasees SQL language reference manual of Jincang database (8. Function (6))
【Delphi】制作控件面板安装图标的简单方法(译)
How Alibaba cloud resolves a domain name to another domain name
LeetCode刷题--点滴记录023
Chapter 3 Standard Input
应用层重要知识(面试、复试、期末)
Exciting metauniverse! Wealth outlet of next generation Internet
云徙科技CTO李楠:技术和技术人,与数字化共同进化
Industry insight | how to better build a data center? It and business should "go together"
注册树模式
PowerBI入门指南
DPDK 交叉编译基本流程
什么是即时通讯?即时通讯的发展
Chapter 4: runtime data area - shared space
元宇宙浪潮震撼来袭,抓住时机,齐心协力
Interest rate in installment payment
0 basic career change software test, the necessary skills with a monthly salary of 6000 and 11000 are quite different
Kingbasees SQL language reference manual of Jincang database (4. Pseudo column)
Unityc realizes the conversion of Chinese characters to Pinyin - using Microsoft chspinyinconv Library