7#include<YarpViconBridge.h>
11using namespace ViconDataStreamSDK::CPP;
16#define output_stream if(!logFile.empty()) ; else yInfo()
46bool YarpViconBridge::open(
Searchable &config) {
48 if (config.
check(
"log_file"))
54 if(config.
check(
"hostname"))
56 hostname = config.
find(
"hostname").asString();
57 hostname = hostname +
":801";
60 if(config.
check(
"silent"))
65 if(config.
check(
"inversion"))
70 if (config.
check(
"enable_multicast"))
77 if (config.
check(
"connect_to_multicast"))
84 if(config.
check(
"publish_segments"))
89 if(config.
check(
"publish_labeled_markers"))
94 if(config.
check(
"publish_unlabeled_markers"))
99 if(config.
check(
"subject_string"))
104 if(config.
check(
"segment_string"))
109 if(config.
check(
"test_frame"))
114 if(config.
check(
"viconroot_string"))
119 if(config.
check(
"labeled_marker_string"))
124 if(config.
check(
"unlabeled_marker_string"))
129 if(config.
check(
"centroids"))
134 if(config.
check(
"rays"))
139 if(config.
check(
"client-buffer-size"))
144 if(config.
check(
"set-axis-mapping"))
153 yInfo() <<
"Unknown axis setting: "<<
axisMapping <<
" . Should be XUp, YUp, or ZUp";
163 yError() <<
"YarpViconBridge: Could not open log file <" <<
logFile <<
">...exiting";
169 yInfo() <<
"Connecting to " << hostname <<
" ...";
185 ok =(
viconClient.Connect( hostname ).Result == Result::Success );
218 viconClient.SetStreamMode( ViconDataStreamSDK::CPP::StreamMode::ServerPush );
253 prop.
put(
"device",
"transformClient");
254 prop.
put(
"local",
"/transformClientVicon");
255 prop.
put(
"remote",
"/transformServer");
256 if(!poly->open(prop))
258 yError()<<
"YarpViconBridge: unable to open `transformClient` device";
265 yError()<<
"YarpViconBridge: unable to open `transformClient` device";
276void YarpViconBridge::run()
285 while(
viconClient.GetFrame().Result != Result::Success)
320 yInfo() <<
"Frame rate: " <<
Rate.FrameRateHz;
413 m1[3][0] = 0;
m1[3][1] = 0;
m1[3][2] = 0;
m1[3][3] = 1;
472 m1[3][0] = 0;
m1[3][1] = 0;
m1[3][2] = 0;
m1[3][3] = 1;
538 m1[3][0] = 0;
m1[3][1] = 0;
m1[3][2] = 0;
m1[3][3] = 1;
557bool YarpViconBridge::close()
587 yInfo() <<
" Disconnecting..." ;
591 yInfo() <<
" Disconnect time = " <<
secs <<
" secs" ;
constexpr uint32_t default_rate
A container for a device driver.
A mini-server for performing network communication in the background.
void close() override
Stop port activity.
BufferedPort()
Constructor.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
An abstraction for a periodic thread.
bool isRunning() const
Returns true when the thread is started, false otherwise.
bool start()
Call this to start the thread.
void stop()
Call this to stop the thread, this call blocks until the thread is terminated (and releaseThread() ca...
A class for storing options and configuration information.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
A base class for nested structures that can be searched.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
For streams capable of holding different kinds of content, check what they actually have.
yarp::sig::Matrix SE3inv(const yarp::sig::Matrix &H)
Returns the inverse of a 4 by 4 rototranslational matrix (defined in Math.h).
double now()
Return the current time in seconds, relative to an arbitrary starting point.
An interface to the operating system, including Port based communication.