38 #ifndef WIN32_LEAN_AND_MEAN 39 #define WIN32_LEAN_AND_MEAN 1 65 volatile bool doneG =
false;
66 FILE* logFileP = stdout;
67 uint32_t accel_samples = 0;
68 uint32_t gyro_samples = 0;
69 uint32_t mag_samples = 0;
70 int64_t sequence = -1;
71 uint32_t messages = 0;
74 void usage(
const char *programNameP)
76 std::cerr <<
"USAGE: " << programNameP <<
" [<options>]" << std::endl;
77 std::cerr <<
"Where <options> are:" << std::endl;
78 std::cerr <<
"\t-a <ip_address> : IPV4 address (default=10.66.171.21)" << std::endl;
79 std::cerr <<
"\t-m <mtu> : default=7200" << std::endl;
80 std::cerr <<
"\t-f <log_file> : FILE to log IMU data (stdout by default)" << std::endl;
86 BOOL WINAPI signalHandler(DWORD dwCtrlType)
89 std::cerr <<
"Shutting down on signal: CTRL-C" << std::endl;
94 void signalHandler(
int sig)
96 std::cerr <<
"Shutting down on signal: " << strsignal(sig) << std::endl;
105 std::vector<imu::Sample>::const_iterator it = header.
samples.begin();
107 for(; it!=header.
samples.end(); ++it) {
118 fprintf(logFileP,
"%d %.6f %.6f %.6f %.6f\n",
126 else if ((sequence + 1) != header.
sequence) {
127 const int32_t
d =
static_cast<int32_t
> (header.
sequence - (sequence + 1));
140 std::string currentAddress =
"10.66.171.21";
141 const char *logFileNameP = NULL;
145 SetConsoleCtrlHandler (signalHandler, TRUE);
147 signal(SIGINT, signalHandler);
155 while(-1 != (c =
getopt(argc, argvPP,
"a:f:m:v")))
157 case 'a': currentAddress = std::string(
optarg);
break;
158 case 'f': logFileNameP =
optarg;
break;
159 case 'm': mtu = atoi(
optarg);
break;
160 default:
usage(*argvPP);
break;
167 if (NULL == channelP) {
168 std::cerr <<
"Failed to establish communications with \"" << currentAddress <<
"\"" << std::endl;
187 std::cerr <<
"IMU support requires sensor firmware version v2.3 or greater, sensor is " <<
204 if (NULL != logFileNameP) {
209 logFileP = fopen(logFileNameP,
"w+");
210 if (NULL == logFileP) {
211 std::cerr <<
"Failed to open \"" << logFileNameP <<
"\" for writing: " << strerror(errno) << std::endl;
220 status = channelP->
setMtu(mtu);
255 int64_t imu_total = accel_samples + gyro_samples + mag_samples;
257 std::cerr <<
"IMU samples : " <<
258 "total: " << imu_total <<
", " <<
259 "accel: " << std::fixed << std::setprecision(1) << (100.0 *
static_cast<double>(accel_samples) / static_cast<double>(imu_total)) <<
"%, " <<
260 "gyro: " << std::fixed << std::setprecision(1) << (100.0 *
static_cast<double>(gyro_samples) / static_cast<double>(imu_total)) <<
"%, " <<
261 "mag: " << std::fixed << std::setprecision(1) << (100.0 *
static_cast<double>(mag_samples) / static_cast<double>(imu_total)) <<
"%" << std::endl;
265 std::cerr <<
"IMU messages: total: " << messages <<
", " <<
266 "dropped: " << dropped <<
"(" << std::fixed << std::setprecision(6) << (100* static_cast<double>(dropped) / static_cast<double>(messages+dropped)) <<
"%)" << std::endl;
virtual Status startStreams(DataSource mask)=0
static CRL_CONSTEXPR Type Type_Accelerometer
static const char * statusString(Status status)
virtual Status stopStreams(DataSource mask)=0
static Channel * Create(const std::string &sensorAddress)
int main(int argc, char **argvPP)
static CRL_CONSTEXPR Type Type_Magnetometer
virtual Status getVersionInfo(system::VersionInfo &v)=0
int getopt(int argc, char **argv, char *opts)
virtual Status addIsolatedCallback(image::Callback callback, DataSource imageSourceMask, void *userDataP=NULL)=0
static CRL_CONSTEXPR DataSource Source_Imu
static CRL_CONSTEXPR Status Status_Ok
virtual Status setMtu(int32_t mtu)=0
VersionType sensorFirmwareVersion
uint32_t timeMicroSeconds
static void Destroy(Channel *instanceP)
static CRL_CONSTEXPR Type Type_Gyroscope
static CRL_CONSTEXPR DataSource Source_All