whoenig / NatNetSDKCrossplatform

Crossplatform version of the OptiTrack NatNet SDK
13 stars 8 forks source link

Request for help in using UNIX time in Natnet SampleClient.cpp #4

Open gauricollab09 opened 1 week ago

gauricollab09 commented 1 week ago

My question is regarding Optitrack - Motive and NatNet SDK SampleClient.cpp script.

My goal is to capture the "time now" in UNIX on my NatNet machine, which is running on Ubuntu.

However, I’m having trouble figuring out where exactly to implement this in the SampleClient.cpp code. I’ve already added the following line using std::chrono to capture the current time in the Data handler:

const auto now = std::chrono::system_clock::now(); const std::time_t t_c = std::chrono::system_clock::to_time_t(now); image (1)

But I’m unsure if this should be placed inside the void NATNET_CALLCONV DataHandler(sFrameOfMocapData data, void pUserData) function or elsewhere. I also want to use the time_now in the OutputFrameQueueToConsole() function where the latencies, etc are printed, but I’m a bit confused on how to approach this since I’m not very comfortable with C++ code. (Running into errors accessing the variables etc)

printf("Server Timestamp : %s\n", std::ctime(&t_c)); image (2)

Could you provide some guidance on where this logic should go? Thank you so much for your help.

whoenig commented 1 week ago

NatNet and the SimpleClient example are actually from OptiTrack (the vendor). I only host the code here for version control and to include minimal changes to be able to compile on Linux.

Perhaps you can explain your goal in https://github.com/IMRCLab/libmotioncapture, where I maintain the user code base.