当前位置:网站首页>The topic pub instruction of ros2 appears: failed to populate field: 'vector3' object has no attribute 'x:1' error
The topic pub instruction of ros2 appears: failed to populate field: 'vector3' object has no attribute 'x:1' error
2022-07-23 10:46:00 【Mr anhydrous】
1 Instructions ros2 topic pub The hidden rules of
stay yaml In the instruction of format input , There are some details in its format that need attention ; such as , A small space can affect , This article is about the author when executing such commands , Discovered yaml In the format “ Hidden rules ”.
When testing the movement of little turtles , Using instructions :
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}}"The following prompt appears :
Failed to populate field: 'Vector3' object has no attribute 'x:5'
What's the reason for this ? Because

2 The correct input format is as follows :
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 Corresponding Python Program realization
Such as : I'm trying to use RosAria towards Pioneer P3-AT( edit :3-AT or P3-AT, Use both names ) dispatch orders . That's true. RosAria Can work , Because when I'm at the terminal , I can use the following commands to move the robot :
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)Similar error prompt occurs again ,
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'When I use sets or numpy Array time , There will be the same mistake . If I try another format ( Not two lists ) Release value , An unexpected format error will be given . Adding or removing entries from any list does not solve this error .
Please try the above code yourself , Let's see if we can tune .
边栏推荐
- 美团8年经验之谈,测试工程师如何进阶(自动化、性能、测开)
- Chapter 3 Standard Input
- SVG、canvas、绘制线段和填充多边形、矩形、曲线的绘制和填充
- PyQt5_QListWidget分页多选控件
- LeetCode刷题--点滴记录022
- PyQt5_pyqtgraph鼠标在折线图上画线段
- SQLZOO——SELECT Quiz
- Comprehensive experiment of realizing private network interworking under mGRE environment
- Introduction to partition operators, broadcast variables and accumulators of 32 spark
- Clion + mingw64 configure C language development environment visual studio installation
猜你喜欢

Basic knowledge of C language (I)

C# 客户端程序调用外部程序的3种实现方法

《Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks》论文阅读

Rapid SQL all platforms high performance SQL code

云徙科技CTO李楠:技术和技术人,与数字化共同进化

元宇宙浪潮震撼来袭,抓住时机,齐心协力

美团8年经验之谈,测试工程师如何进阶(自动化、性能、测开)

04_ UE4 advanced_ Introduction to physical collision and firing fireballs

Chrome selenium uses the default profile without emptying it every time

PyQt5_ Qlistwidget paging multiple selection control
随机推荐
Visual Studio 2022有趣又强大的智能辅助编码
全局事件总线
组件中的自定义事件
China Economic Net: "Yuan universe" is hot
理解ASP.NET Core - 基于Cookie的身份认证(Authentication)
LeetCode刷题--点滴记录023
MySql 数据库表名命名规则---方便自动转换工具转换
Cloudcompare & PCL point cloud point matching (based on point to face distance)
Important knowledge of application layer (interview, reexamination, term end)
推荐一款 Shell 装逼神器,已开源!网友:真香。。。
Warning lnk4210 reports an error when writing the driver
Idea integrated sonar complete process
What is instant messaging? Development of instant messaging
Ue5 official case Lyra full feature explanation 6. generate defense tower
How to protect the copyright of NFT digital collections?
添加信任列表
FPGA——SPI总线控制flash(2)(含代码)
Chapter 3 Standard Input
数据湖:从数据仓库看数据湖
Compile build tool -bazel