简体   繁体   English

如何在ROS中编写多个Twist消息

[英]How to write multiple Twist messages in ROS

I'm trying to build two virtual joysticks using differential_drive package in ROS using Python (new as well) for my mecanum wheel project (ability to do sideways movement joystick). 我正在尝试为我的麦克纳姆轮项目(使用侧向移动游戏杆的能力)使用Python(也使用Python)(在ROS中使用differential_drive包)构建两个虚拟游戏杆。 Since both uses the same file type Twist how do I make two outputs to be published? 由于两者都使用相同的文件类型Twist ,我该如何发布两个输出? Does twist only understand linear or should I change it to linear2 as well? 扭曲只会理解linear吗?还是应该将其更改为linear2

original: 原版的:

self.twist = Twist()
self.twist.linear.x = (1-self.y) * (x_max - x_min) + x_min
self.twist.linear.y = 0

etc. 等等

Do I have to change like this: 我是否需要这样更改:

self.twist2 = Twist()
self.twist2.linear.x = (1-self.y) * (x_max - x_min) + x_min
self.twist2.linear.y = 0

or: 要么:

self.twist2 = Twist()
self.twist2.linear2.x = (1-self.y) * (x_max - x_min) + x_min
self.twist2.linear2.y = 0

Both Virtual Joystick (original) and Virtual Joystick 2 (modified) have to be on at launch 虚拟游戏杆(原始)和虚拟游戏杆2(已修改)都必须在启动时启动

The first one is correct 第一个是正确的

 self.twist2 = Twist() self.twist2.linear.x = (1-self.y) * (x_max - x_min) + x_min self.twist2.linear.y = 0 

twist2 is just an arbitrary name of the variable. twist2只是变量的任意名称。 linear is a member of the Twist instance, which has always the same name, no matter how you call the variable. linearTwist实例的成员,该实例始终具有相同的名称,无论您如何调用变量。

You could have easily figured that out yourself by just trying it, though (the second one would raise an error). 但是,您可以通过尝试轻松地弄清这一点(第二个方法会引发错误)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM