6 #include <base-logging/Logging.hpp>
9 using namespace ViconDataStreamSDK::CPP;
32 int axis_val = axis < 0 ? -axis : axis;
49 : impl( new
DriverImpl() ), mLastResult(UNKNOWN)
55 std::ostringstream host;
56 host << hostname <<
":" << port;
57 LOG_INFO_S <<
"connecting to " << host.str();
59 impl->client.Connect( host.str() );
63 impl->client.EnableSegmentData();
64 impl->client.EnableUnlabeledMarkerData();
71 impl->client.SetAxisMapping(
84 return impl->client.IsConnected().Connected;
89 LOG_INFO_S <<
"disconnecting";
90 impl->client.Disconnect();
95 base::Time start = base::Time::now();
97 while( ((result=impl->client.GetFrame().Result) ==
Result::NoFrame) && (start+timeout > base::Time::now()) )
99 const unsigned long wait_ms = 10;
109 LOG_DEBUG_S <<
"Got Frame!";
114 if ( timeout.toSeconds() > 0 ) LOG_ERROR_S <<
"No Frame received!";
122 return base::Time::now();
129 std::string SegmentName = impl->client.GetSubjectRootSegmentName(subjectName).SegmentName;
131 LOG_DEBUG_S <<
" Name: " << SegmentName;
133 LOG_DEBUG_S <<
"get transform: " << subjectName <<
"." << segmentName;
135 impl->client.GetSegmentGlobalTranslation( subjectName, segmentName );
138 impl->client.GetSegmentGlobalRotationQuaternion( subjectName, segmentName );
143 Eigen::Affine3d result = Eigen::Translation3d( trans_m * 1e-3 ) *
168 std::vector<base::Vector3d> result;
170 unsigned int UnlabeledMarkerCount = impl->client.GetUnlabeledMarkerCount().MarkerCount;
171 for(
unsigned int UnlabeledMarkerIndex = 0 ; UnlabeledMarkerIndex < UnlabeledMarkerCount ; ++UnlabeledMarkerIndex )
174 impl->client.GetUnlabeledMarkerGlobalTranslation( UnlabeledMarkerIndex );
176 Eigen::Vector3d marker_pos(
177 _Output_GetUnlabeledMarkerGlobalTranslation.
Translation[ 0 ],
178 _Output_GetUnlabeledMarkerGlobalTranslation.
Translation[ 1 ],
179 _Output_GetUnlabeledMarkerGlobalTranslation.
Translation[ 2 ] );
181 result.push_back( marker_pos * 1e-3 );
void setAxesDir(int x_dir, int y_dir, int z_dir)
Set axes directions.
void getAxesDir(int &x_dir, int &y_dir, int &z_dir)
Get axes direction.
int axesMap(Direction::Enum axis)
Eigen::Affine3d getSegmentTransform(const std::string &subjectName, const std::string &segmentName, bool &inFrame)
bool connect(const std::string &hostname, const unsigned int port=801)
bool getFrame(const base::Time &timeout=base::Time::fromSeconds(1.0))
std::vector< base::Vector3d > getUnlabeledMarkers()
base::Time getTimestamp()