如何在ROS2 Action服务器中访问主题

发布于 2025-01-26 05:14:02 字数 132 浏览 3 评论 0原文

在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

少女净妖师 2025-02-02 05:14:02

在操作服务器中订阅所需主题的订阅将需要返回回调,这并不简单(我认为)。有一个更简单的方法可以实现这一目标吗?

您可以创建一个全局变量,其中类型是您要订阅的ROS消息,然后在回调中更新带有最新收到消息的变量,在您的操作服务器中,您可以使用“全局变量”,如果ROS,您可能想使用Mutex您正在收到的消息是图像或PointCloud消息之类的东西

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?

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文