我有 2 个主题由英特尔实感相机发布。一个主题是发布深度图像,另一个主题是发布彩色图像。每张彩色图像都有一个相应的深度图像,在标题中具有相同的时间戳。我想将颜色和深度主题合并到一个主题中,该主题将发布成对的深度和彩色图像。是否有基于时间戳的 ROS 功能?
以下是我创建的订阅者:
self.image_sub = rospy.Subscriber("image", Image, mask_detect, queue_size=1, buff_size=2**24)
depth_image_sub = rospy.Subscriber("depth_image", Image,
aquire_depth_image, queue_size=1000)
Run Code Online (Sandbox Code Playgroud)
我希望能够做这样的事情(伪代码):
color_depth = rospy.Subscriber(["image", "depth_image"], callback_function, mergePolicy="EXACTTIME")
Run Code Online (Sandbox Code Playgroud)
在 ROS 中是否有一种标准的方法可以做到这一点,或者是一种简单的方法?
我试图理解这行代码
ros::Rate loop_rate(10);
Run Code Online (Sandbox Code Playgroud)
它似乎正在创建某种对象,但这看起来像一个函数调用,我看不到对象的名称。这行代码在做什么?我了解 ros 中的 loop_rate 是什么,但我是 C++ 新手,不了解语法。
#include "ros/ros.h"
#include "std_msgs/String.h"
#include <sstream>
int main(int argc, char **argv)
{
ros::init(argc, argv, "talker");
ros::NodeHandle n;
ros::Publisher chatter_pub = n.advertise<std_msgs::String>("chatter", 1000);
ros::Rate loop_rate(10);
int count = 0;
while (ros::ok())
{
std_msgs::String msg;
std::stringstream ss;
ss << "hello world " << count;
msg.data = ss.str();
ROS_INFO("%s", msg.data.c_str());
chatter_pub.publish(msg);
ros::spinOnce();
loop_rate.sleep();
++count;
}
return 0;
}
Run Code Online (Sandbox Code Playgroud) 这些值何时以及如何设置?它取决于 CMakeLists.txt 的位置吗?这是否取决于 CMake 的运行位置?