39 #ifndef WIN32_LEAN_AND_MEAN 40 #define WIN32_LEAN_AND_MEAN 1 47 #include <arpa/inet.h> 68 volatile bool doneG =
false;
70 void usage(
const char *programNameP)
72 std::cerr <<
"USAGE: " << programNameP <<
" [<options>]" << std::endl;
73 std::cerr <<
"Where <options> are:" << std::endl;
74 std::cerr <<
"\t-a <current_address> : CURRENT IPV4 address (default=10.66.171.21)" << std::endl;
75 std::cerr <<
"\t-d <decimation> : Decimation to apply for the directed streams (default=1)" << std::endl;
81 BOOL WINAPI signalHandler(DWORD dwCtrlType)
84 std::cerr <<
"Shutting down on signal: CTRL-C" << std::endl;
89 void signalHandler(
int sig)
91 std::cerr <<
"Shutting down on signal: " << strsignal(sig) << std::endl;
96 bool savePgm(
const std::string& fileName,
99 uint32_t bitsPerPixel,
102 std::ofstream outputStream(fileName.c_str(), std::ios::binary | std::ios::out);
104 if (
false == outputStream.good()) {
105 std::cerr <<
"Failed to open \"" << fileName <<
"\"" << std::endl;
109 const uint32_t imageSize = height * width;
111 switch(bitsPerPixel) {
115 outputStream <<
"P5\n" 116 << width <<
" " << height <<
"\n" 119 outputStream.write(reinterpret_cast<const char*>(dataP), imageSize);
125 outputStream <<
"P5\n" 126 << width <<
" " << height <<
"\n" 129 const uint16_t *imageP =
reinterpret_cast<const uint16_t*
>(dataP);
131 for (uint32_t i=0; i<imageSize; ++i) {
132 uint16_t o = htons(imageP[i]);
133 outputStream.write(reinterpret_cast<const char*>(&o),
sizeof(uint16_t));
140 outputStream.close();
148 std::cerr <<
"PPS: " << header.
sensorTime <<
" ns" << std::endl;
156 static double lastTimeStamp = timeStamp;
158 if (header.
scanId % 100 == 0)
159 std::cout <<
"Laser Frequency " << (1 / (timeStamp - lastTimeStamp)) << std::endl;
161 lastTimeStamp = timeStamp;
170 static double lastTimeStamp = timeStamp;
173 std::cout <<
"Left Image Frequency " << (1 / (timeStamp - lastTimeStamp)) <<
" " 176 lastTimeStamp = timeStamp;
178 static int64_t lastFrameId = -1;
180 if (-1 == lastFrameId)
181 savePgm(
"left_rect.pgm",
192 std::cerr <<
"failed to get histogram for frame " << header.
frameId << std::endl;
201 static double lastTimeStamp = timeStamp;
204 std::cout <<
"Disparity Frequency " << (1 / (timeStamp - lastTimeStamp)) <<
" " 207 lastTimeStamp = timeStamp;
209 static int64_t lastFrameId = -1;
211 if (-1 == lastFrameId)
212 savePgm(
"disparity.pgm",
223 std::cerr <<
"failed to get histogram for frame " << header.
frameId << std::endl;
231 std::string currentAddress =
"10.66.171.21";
233 uint32_t decimation = 1;
236 SetConsoleCtrlHandler (signalHandler, TRUE);
238 signal(SIGINT, signalHandler);
247 std::vector<DirectedStream> queryStreams;
249 uint32_t streamIndex;
260 while(-1 != (c =
getopt(argc, argvPP,
"a:m:d:")))
262 case 'a': currentAddress = std::string(
optarg);
break;
263 case 'm': mtu = atoi(
optarg);
break;
264 case 'd': decimation = atoi(
optarg);
break;
265 default:
usage(*argvPP);
break;
272 if (NULL == channelP) {
273 std::cerr <<
"Failed to establish communications with \"" << currentAddress <<
"\"" << std::endl;
289 std::cout <<
"API build date : " << v.
apiBuildDate <<
"\n";
290 std::cout <<
"API version : 0x" << std::hex << std::setw(4) << std::setfill(
'0') << v.
apiVersion <<
"\n";
292 std::cout <<
"Firmware version : 0x" << std::hex << std::setw(4) << std::setfill(
'0') << v.
sensorFirmwareVersion <<
"\n";
295 std::cout <<
"FPGA DNA : 0x" << std::hex << v.
sensorFpgaDna <<
"\n";
296 std::cout << std::dec;
324 status = channelP->
setMtu(mtu);
369 for (streamIndex = 0 ; streamIndex < queryStreams.size() ; ++streamIndex) {
370 std::cout <<
"Directed Stream " << streamIndex << std::endl;
371 std::cout <<
"Address: " << queryStreams[streamIndex].address << std::endl;
372 std::cout <<
"Port: " << std::dec << queryStreams[streamIndex].udpPort << std::endl;
373 std::cout <<
"Mask: 0x" << std::hex << queryStreams[streamIndex].mask << std::endl;
374 std::cout <<
"Decimation: " << std::dec << queryStreams[streamIndex].fpsDecimation << std::endl;
375 std::cout << std::endl;
virtual Status startDirectedStream(const DirectedStream &stream)=0
static const char * statusString(Status status)
static CRL_CONSTEXPR DataSource Source_Disparity
static CRL_CONSTEXPR TriggerSource Trigger_Internal
ros::Time * timeStamp(M &m)
virtual Status getDirectedStreams(std::vector< DirectedStream > &streams)=0
uint64_t sensorHardwareMagic
static Channel * Create(const std::string &sensorAddress)
virtual Status getImageHistogram(int64_t frameId, image::Histogram &histogram)=0
void setResolution(uint32_t w, uint32_t h)
virtual Status stopDirectedStream(const DirectedStream &stream)=0
std::string sensorFirmwareBuildDate
virtual Status getVersionInfo(system::VersionInfo &v)=0
int getopt(int argc, char **argv, char *opts)
static CRL_CONSTEXPR DataSource Source_Lidar_Scan
virtual Status addIsolatedCallback(image::Callback callback, DataSource imageSourceMask, void *userDataP=NULL)=0
virtual Status setTriggerSource(TriggerSource s)=0
static CRL_CONSTEXPR Status Status_Ok
virtual Status getLocalUdpPort(uint16_t &port)=0
virtual Status setMtu(int32_t mtu)=0
virtual Status setImageConfig(const image::Config &c)=0
int main(int argc, char **argvPP)
VersionType sensorFirmwareVersion
static void Destroy(Channel *instanceP)
uint64_t sensorHardwareVersion
virtual Status getImageConfig(image::Config &c)=0
static CRL_CONSTEXPR DataSource Source_Luma_Rectified_Left