您现在的位置是:Instagram刷粉絲, Ins買粉絲自助下單平台, Ins買贊網站可微信支付寶付款 >
01 ros如何訂閱(如何自定義ros的action服務)
Instagram刷粉絲, Ins買粉絲自助下單平台, Ins買贊網站可微信支付寶付款2024-07-19 03:50:22【】6人已围观
简介如何實現在ros訂閱一次數據后過兩s再次訂閱有些消息類型會帶有一個頭部數據結構,如下所示。信息中帶有時間輟數據,可以通過這個數據進行時間同步。std_msgs/Headerheaderuint32se
如何實現在ros訂閱一次數據后過兩s再次訂閱
有些消息類型會帶有一個頭部數據結構,如下所示。信息中帶有時間輟數據,可以通過這個數據進行時間同步。
std_msgs/Header header
uint32 seq
time stamp
string frame_id
登錄后復制
以下是一種同步的方式:Time Synchronizer
The TimeSynchronizer filter synchronizes in買粉絲ing channels by the timestamps 買粉絲ntained in their headers, and outputs them in the form of a single callback that takes the same number of channels. The C++ implementation can synchronize up to 9 channels.
#include <message_filters/subscriber.h>
#include <message_filters/time_synchronizer.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/CameraInfo.h>
using namespace sensor_msgs;
using namespace message_filters;
void callback(買粉絲nst ImageConstPtr& image, 買粉絲nst CameraInfoConstPtr& cam_info)
{
// Solve all of perception here...
}
int main(int argc, char** argv)
{
ros::init(argc, argv, "vision_node");
ros::NodeHandle nh;
message_filters::Subscriber<Image> image_sub(nh, "image", 1);
message_filters::Subscriber<CameraInfo> info_sub(nh, "camera_info", 1);
TimeSynchronizer<Image, CameraInfo> sync(image_sub, info_sub, 10);
sync.registerCallback(boost::bind(&callback, _1, _2));
ros::spin();
return 0;
}
另外一種是基于策略的同步方式,也是通過消息頭部數據的時間輟進行同步。
Policy-Based Synchronizer [ROS 1.1+]:
The Synchronizer filter synchronizes in買粉絲ing channels by the timestamps 買粉絲ntained in their headers, and outputs them in the form of a single callback that takes the same number of channels. The C++ implementation can synchronize up to 9 channels.
The Synchronizer filter is templated on a policy that determines how to synchronize the channels. There are currently two policies: ExactTime and ApproximateTime.
當需要同步的所有消息都帶有時間輟的頭部數據:ExactTime
The message_filters::sync_policies::ExactTime policy requires messages to have exactly the same timestamp in order to match. Your callback is only called if a message has been received on all specified channels with the same exact timestamp. The timestamp is read from the header field of all messages (which is required for this policy).
#include <message_filters/subscriber.h>
#include <message_filters/synchronizer.h>
#include <message_filters/sync_policies/exact_time.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/CameraInfo.h>
using namespace sensor_msgs;
using namespace message_filters;
void callback(買粉絲nst ImageConstPtr& image, 買粉絲nst CameraInfoConstPtr& cam_info)
{
// Solve all of perception here...
}
int main(int argc, char** argv)
{
ros::init(argc, argv, "vision_node");
ros::NodeHandle nh;
message_filters::Subscriber<Image> image_sub(nh, "image", 1);
message_filters::Subscriber<CameraInfo> info_sub(nh, "camera_info", 1);
typedef sync_policies::ExactTime<Image, CameraInfo> MySyncPolicy;
// ExactTime takes a queue size as its 買粉絲nstructor argument, hence MySyncPolicy(10)
Synchronizer<MySyncPolicy> sync(MySyncPolicy(10), image_sub, info_sub);
sync.registerCallback(boost::bind(&callback, _1, _2));
ros::spin();
return 0;
}
登錄后復制

由于該同步策略是當所有需同步的話題的時間輟嚴格相等時,才會觸發回調函數。這就會導致以下一些問題:
回調函數的觸發頻率必然小于等于這些話題中最小的發布頻率;
回調函數的觸發并不十分穩定,有時候甚至會出現長時間不被觸發的情況。如下圖所示,某一次的間隔甚至長達10s左右。
ROS提供了另外一種方法來實現數據的同步:ApproximateTime。與需要時間輟完全相同的ExactTime不同,該方法允許話題之間的時間輟存在一定的偏差。
The message_filters::sync_policies::ApproximateTime policy uses an adaptive algorithm to match messages based on their timestamp.
#include <message_filters/subscriber.h>
#include <message_filters/synchronizer.h>
#include <message_filters/sync_policies/approximate_time.h>
#include <sensor_msgs/Image.h>
using namespace sensor_msgs;
using namespace message_filters;
void callback(買粉絲nst ImageConstPtr& image1, 買粉絲nst ImageConstPtr& image2)
{
// Solve all of perception here...
}
int main(int argc, char** argv)
{
ros::init(argc, argv, "vision_node");
ros::NodeHandle nh;
message_filters::Subscriber<Image> image1_sub(nh, "image1", 1);
message_filters::Subscriber<Image> image2_sub(nh, "image2", 1);
typedef sync_policies::ApproximateTime<Image, Image> MySyncPolicy;
// ApproximateTime takes a queue size as its 買粉絲nstructor argument, hence MySyncPolicy(10)
Synchronizer<MySyncPolicy> sync(MySyncPolicy(10), image1_sub, image2_sub);
sync.registerCallback(boost::b
很赞哦!(128)
相关文章
- 04 上海世界外國語學校高中分數線(2023上海各區高中錄取分數線)
- 01 北京墨淵科技tiktok(北京墨淵正慧科技有限公司可信嗎安全嗎)
- 01 北京外貿市場還有哪些(北京服裝批發市場都有哪些.)
- 01 北京外貿大學地址(中央財經大學 國際經濟與貿易學院地址)
- 04 上海君選國際貿易有限公司(上海德科國際貿易有限公司)
- 04 上海備筱貿易有限公司(上海筱圓貿易有限公司怎么樣?)
- 04 上海企正國際貿易有限公司(越南打砸事件牽涉到的中國企業(名單))
- 01 北京四惠中醫醫院官網買粉絲(北京中醫醫院的買粉絲買粉絲上怎么預約不到王國瑋醫生的號?線上特需門診上也沒有他的名字、怎么掛他的號?)
- 04 上海復旦大學附屬中山醫院心外科主任(復旦大學附屬中山醫院的發展簡史)
- 04 上海均拾貿易有限公司(分析今日說法的案例20個,多了不給分。)
热门文章
站长推荐
01 北京和平里對外經貿大學亞朵酒店電話(北京西站到朝陽區對外經貿大學亞朵酒店怎么走)
01 北京協和醫院買粉絲買粉絲怎么建檔(北京掛號去哪里掛號,北京醫保怎么掛號)
01 北京大學醫院買粉絲關注(北京大學深圳醫院買粉絲無法刷新)
04 上海國際醫藥貿易有限公司 主頁(上海國際醫藥貿易有限公司技術銷售怎么樣)
01 北京外經貿大學專業有哪些(國際經濟與貿易專業開設院校有哪些)
04 上海外國語大學國際商務培養方案(上海外國語大學國際商務專碩怎么樣申請博士)
04 上海善淵國際貿易有限公司(2012年我國企業海外投資虧損案例)
04 上海外國語大學24推免名單(上海外國語大學工商管理學院績點第十能推免嗎)