如何在ROS2 Action服务器中访问主题
在ROS2 Action Server回调函数中,我需要访问有关某些ROS主题的数据。我该如何以一种简单明了的方式实现这一目标。
在操作服务器中订阅所需的主题将需要返回回调,这并不简单(我认为)。 有一个更简单的方法可以实现这一目标吗?
In an ROS2 action server callback function, I need to access data which is published on some ROS topic. How can I achieve this, in a straightforward and clean way.
Subscribing to the wanted topic in the action server would require a returning callback, which is not straightforward (in my opinion).
Is there an easier way to achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以创建一个全局变量,其中类型是您要订阅的ROS消息,然后在回调中更新带有最新收到消息的变量,在您的操作服务器中,您可以使用“全局变量”,如果ROS,您可能想使用Mutex您正在收到的消息是图像或PointCloud消息之类的东西
you can create a global variable where the type is ros message that you are subscribing, then in callback update the variable with latest received message, in your action server you can use the the global variable, You might wanted to use a mutex if the ros message you are receiving is something like image or pointcloud message