File tree Expand file tree Collapse file tree 2 files changed +44
-1
lines changed
infinite_sense_core/include Expand file tree Collapse file tree 2 files changed +44
-1
lines changed Original file line number Diff line number Diff line change 1+ #include " infinite_sense.h"
2+ using namespace infinite_sense ;
3+ int main () {
4+
5+ // 1.创建同步器
6+ Synchronizer synchronizer;
7+ /*
8+ 使用网口连接
9+ synchronizer.SetNetLink("192.168.1.188", 8888);
10+ */
11+ synchronizer.SetUsbLink (" /dev/ttyACM0" , 460800 );
12+
13+ /*
14+ 如使用工业相机, 需要指定 相机名称 和 同步板的触发端口
15+ std::map<std::string, TriggerDevice> params;
16+ params["camera_1"] = TriggerDevice::CAM_1; //camera_1:表示设备的名称,TriggerDevice::CAM_1:使用同步板CAM_1端口触发
17+ synchronizer.UseMvCam(params);
18+ */
19+
20+ // 2.开启同步
21+ synchronizer.Start ();
22+
23+ // 3.订阅数据
24+ 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;
32+ while (true ) {
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+ }
39+ }
40+ // 4.停止同步
41+ synchronizer.Stop ();
42+ return 0 ;
43+ }
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ namespace infinite_sense {
88
99class NetManager ;
1010class UsbManager ;
11- class CamManger ;
11+ class Cam ;
1212class TriggerManger ;
1313class Messenger ;
1414/* *
You can’t perform that action at this time.
0 commit comments