File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#include " infinite_sense.h"
22using namespace infinite_sense ;
33int main () {
4+
5+ // 1.创建同步器
46 Synchronizer synchronizer;
57 /*
68 使用网口连接
@@ -15,13 +17,27 @@ int main() {
1517 synchronizer.UseMvCam(params);
1618 */
1719
18- // 开启同步
20+ // 2. 开启同步
1921 synchronizer.Start ();
22+
23+ // 3.订阅数据
2024 Synchronizer::PrintSummary ();
25+ zmq::context_t context (1 );
26+ zmq::socket_t subscriber (context, zmq::socket_type::sub);
27+ subscriber.connect (" tcp://localhost:5555" );
28+
29+ const std::string topic = " imu_1" ; // 订阅特定主题(如,板载IMU数据: "imu_1")
30+ subscriber.setsockopt (ZMQ_SUBSCRIBE, topic.c_str (), topic.size ());
31+ zmq::message_t msg;
2132 while (true ) {
22- std::this_thread::sleep_for (std::chrono::milliseconds{1000 });
33+ if (subscriber.recv (msg, zmq::recv_flags::dontwait)) {
34+ if (subscriber.get (zmq::sockopt::rcvmore)) {
35+ zmq::message_t dummy;
36+ subscriber.recv (dummy);
37+ }
38+ }
2339 }
24- // 停止同步
40+ // 4. 停止同步
2541 synchronizer.Stop ();
2642 return 0 ;
2743}
You can’t perform that action at this time.
0 commit comments