39 #ifndef WIN32_LEAN_AND_MEAN
40 #define WIN32_LEAN_AND_MEAN 1
47 #include <arpa/inet.h>
65 #include <MultiSense/MultiSenseChannel.hh>
71 volatile bool doneG =
false;
81 void usage(
const char *programNameP)
83 std::cerr <<
"USAGE: " << programNameP <<
" [<options>]" << std::endl;
84 std::cerr <<
"Where <options> are:" << std::endl;
85 std::cerr <<
"\t-a <current_address> : CURRENT IPV4 address (default=10.66.171.21)" << std::endl;
86 std::cerr <<
"\t-m <mtu> : MTU to set the camera to (default=1500)" << std::endl;
87 std::cerr <<
"\t-r <head_id> : remote head ID (default=0)" << std::endl;
93 BOOL WINAPI signalHandler(DWORD dwCtrlType)
100 void signalHandler(
int sig)
109 if (head_str ==
"VPB")
113 else if (head_str ==
"0")
117 else if (head_str ==
"1")
121 else if (head_str ==
"2")
125 else if (head_str ==
"3")
130 fprintf(stderr,
"Error: Unrecognized remote head\n");
131 fprintf(stderr,
"Please use one of the following:\n");
132 fprintf(stderr,
"\tVPB\n");
133 fprintf(stderr,
"\t0'\n");
134 fprintf(stderr,
"\t1\n");
135 fprintf(stderr,
"\t2\n");
136 fprintf(stderr,
"\t3\n");
146 for (
size_t i = 0 ; i < modes.size() ; ++i)
149 if (mode.
width >= best_mode.width && mode.
height >= best_mode.height && mode.
disparities >= best_mode.disparities) {
157 system::DeviceMode target_mode(best_mode.width / 2, best_mode.height / 2, 0, best_mode.disparities);
159 for (
size_t i = 0 ; i < modes.size() ; ++i)
162 if (mode.
width == target_mode.width && mode.
height == target_mode.height && mode.
disparities >= target_mode.disparities) {
170 if (target_mode.supportedDataSources == 0) {
178 std::string
writeMatrix(
const float* data,
size_t width,
size_t height)
180 std::stringstream ss;
181 ss << std::fixed << std::setprecision(6);
183 for (
size_t h = 0 ; h < height ; ++h) {
184 for (
size_t w = 0 ; w < width ; ++w) {
185 ss << data[w + width * h] <<
",";
197 std::stringstream ss;
206 ss <<
"APIVersion," << version.
apiVersion <<
",";
208 ss <<
"timeSec," <<
header.timeSeconds <<
",";
209 ss <<
"timeMiroSec," <<
header.timeMicroSeconds <<
",";
210 ss <<
"exposure," <<
header.exposure <<
",";
211 ss <<
"gain," <<
header.gain <<
",";
212 ss <<
"fps," <<
header.framesPerSecond <<
",";
231 bool savePgm(
const std::string& fileName,
237 const std::string comment = assembledInfoString(header, info, version, calibration);
251 std::cerr <<
"PPS: " <<
header.sensorTime <<
" ns" << std::endl;
258 std::cerr <<
"lidar: " <<
header.pointCount << std::endl;
264 UserData *userData =
reinterpret_cast<UserData*
>(userDataP);
266 static int64_t lastFrameId = -1;
268 if (-1 == lastFrameId)
272 userData->deviceInfo,
274 userData->calibration);
277 lastFrameId =
header.frameId;
281 if (
Status_Ok != userData->channelP->getImageHistogram(
header.frameId, histogram))
282 std::cerr <<
"failed to get histogram for frame " <<
header.frameId << std::endl;
290 std::string currentAddress =
"10.66.171.21";
295 SetConsoleCtrlHandler (signalHandler, TRUE);
297 signal(SIGINT, signalHandler);
305 while(-1 != (c =
getopt(argc, argvPP,
"a:m:r:")))
307 case 'a': currentAddress = std::string(
optarg);
break;
308 case 'm': mtu = atoi(
optarg);
break;
309 case 'r': head_id = getRemoteHeadIdFromString(
optarg);
break;
310 default:
usage(*argvPP);
break;
317 if (NULL == channelP) {
318 std::cerr <<
"Failed to establish communications with \"" << currentAddress <<
"\"" << std::endl;
328 std::vector<system::DeviceMode> deviceModes;
342 std::cout <<
"API build date : " << v.
apiBuildDate <<
"\n";
343 std::cout <<
"API version : 0x" << std::hex << std::setw(4) << std::setfill(
'0') << v.
apiVersion <<
"\n";
345 std::cout <<
"Firmware version : 0x" << std::hex << std::setw(4) << std::setfill(
'0') << v.
sensorFirmwareVersion <<
"\n";
348 std::cout <<
"FPGA DNA : 0x" << std::hex << v.
sensorFpgaDna <<
"\n";
349 std::cout << std::dec;
356 operatingMode = getOperatingMode(deviceModes);
370 std::cout <<
"Setting resolution to: " << operatingMode.
width <<
"x" <<
371 operatingMode.
height <<
"x" <<
389 status = channelP->
setMtu(mtu);
424 userData.channelP = channelP;
425 userData.version = v;
426 userData.deviceInfo = info;
427 userData.calibration = calibration;
453 std::cout <<
"Uptime: " << statusMessage.
uptime <<
", " <<
454 "SystemOk: " << statusMessage.
systemOk <<
", " <<
458 "Input Voltage: " << statusMessage.
inputVoltage <<
", " <<
459 "Input Current: " << statusMessage.
inputCurrent <<
", " <<
460 "FPGA Power: " << statusMessage.
fpgaPower <<
", " <<
461 "Logic Power: " << statusMessage.
logicPower <<
", " <<
462 "Imager Power: " << statusMessage.
imagerPower << std::endl;