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)
83 std::cerr <<
"Shutting down on signal: CTRL-C" << std::endl;
88 void signalHandler(
int sig)
90 std::cerr <<
"Shutting down on signal: " << strsignal(sig) << std::endl;
95 bool savePgm(
const std::string& fileName,
98 uint32_t bitsPerPixel,
101 std::ofstream outputStream(fileName.c_str(), std::ios::binary | std::ios::out);
103 if (
false == outputStream.good()) {
104 std::cerr <<
"Failed to open \"" << fileName <<
"\"" << std::endl;
108 const uint32_t imageSize = height * width;
110 switch(bitsPerPixel) {
114 outputStream <<
"P5\n" 115 << width <<
" " << height <<
"\n" 118 outputStream.write(reinterpret_cast<const char*>(dataP), imageSize);
124 outputStream <<
"P5\n" 125 << width <<
" " << height <<
"\n" 128 const uint16_t *imageP =
reinterpret_cast<const uint16_t*
>(dataP);
130 for (uint32_t i=0; i<imageSize; ++i) {
131 uint16_t o = htons(imageP[i]);
132 outputStream.write(reinterpret_cast<const char*>(&o),
sizeof(uint16_t));
139 outputStream.close();
146 std::cerr <<
"PPS: " << header.
sensorTime <<
" ns" << std::endl;
153 static double lastTimeStamp = timeStamp;
155 if (header.
scanId % 100 == 0)
156 std::cout <<
"Laser Frequency " << (1 / (timeStamp - lastTimeStamp)) << std::endl;
158 lastTimeStamp = timeStamp;
167 static double lastTimeStamp = timeStamp;
170 std::cout <<
"Left Image Frequency " << (1 / (timeStamp - lastTimeStamp)) <<
" " 173 lastTimeStamp = timeStamp;
175 static int64_t lastFrameId = -1;
177 if (-1 == lastFrameId)
178 savePgm(
"left_rect.pgm",
189 std::cerr <<
"failed to get histogram for frame " << header.
frameId << std::endl;
198 static double lastTimeStamp = timeStamp;
201 std::cout <<
"Disparity Frequency " << (1 / (timeStamp - lastTimeStamp)) <<
" " 204 lastTimeStamp = timeStamp;
206 static int64_t lastFrameId = -1;
208 if (-1 == lastFrameId)
209 savePgm(
"disparity.pgm",
220 std::cerr <<
"failed to get histogram for frame " << header.
frameId << std::endl;
228 std::string currentAddress =
"10.66.171.21";
230 uint32_t decimation = 1;
233 SetConsoleCtrlHandler (signalHandler, TRUE);
235 signal(SIGINT, signalHandler);
244 std::vector<DirectedStream> queryStreams;
246 uint32_t streamIndex;
257 while(-1 != (c =
getopt(argc, argvPP,
"a:m:d:")))
259 case 'a': currentAddress = std::string(
optarg);
break;
260 case 'm': mtu = atoi(
optarg);
break;
261 case 'd': decimation = atoi(
optarg);
break;
262 default:
usage(*argvPP);
break;
269 if (NULL == channelP) {
270 std::cerr <<
"Failed to establish communications with \"" << currentAddress <<
"\"" << std::endl;
286 std::cout <<
"API build date : " << v.
apiBuildDate <<
"\n";
287 std::cout <<
"API version : 0x" << std::hex << std::setw(4) << std::setfill(
'0') << v.
apiVersion <<
"\n";
289 std::cout <<
"Firmware version : 0x" << std::hex << std::setw(4) << std::setfill(
'0') << v.
sensorFirmwareVersion <<
"\n";
292 std::cout <<
"FPGA DNA : 0x" << std::hex << v.
sensorFpgaDna <<
"\n";
293 std::cout << std::dec;
321 status = channelP->
setMtu(mtu);
366 for (streamIndex = 0 ; streamIndex < queryStreams.size() ; ++streamIndex) {
367 std::cout <<
"Directed Stream " << streamIndex << std::endl;
368 std::cout <<
"Address: " << queryStreams[streamIndex].address << std::endl;
369 std::cout <<
"Port: " << std::dec << queryStreams[streamIndex].udpPort << std::endl;
370 std::cout <<
"Mask: 0x" << std::hex << queryStreams[streamIndex].mask << std::endl;
371 std::cout <<
"Decimation: " << std::dec << queryStreams[streamIndex].fpsDecimation << std::endl;
372 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