Changeset 104 in pacpussensors for trunk/StdDbtPlayerComponents/DbtPlySickLDMRSManager.cpp
- Timestamp:
- Nov 22, 2015, 11:00:29 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/StdDbtPlayerComponents/DbtPlySickLDMRSManager.cpp
r74 r104 35 35 static const char * kSickMemoryName = "sickLDMRS"; 36 36 37 ////////////////////////////////////////////////////////////////////////// 38 /// Constructor. 37 /************************************************************************ 38 * Constructor 39 ************************************************************************/ 39 40 DbtPlySickLDMRSManager::DbtPlySickLDMRSManager(QString name) 40 41 : DbtPlyFileManager(name) 41 42 { 42 43 LOG_TRACE("constructor(" << name << ")"); 43 44 // mShMem = new ShMem(kAlaskaMemoryName, sizeof(ScanSickData));45 44 } 46 45 47 ////////////////////////////////////////////////////////////////////////// 48 /// Destructor. 46 /************************************************************************ 47 * Destructor 48 ************************************************************************/ 49 49 DbtPlySickLDMRSManager::~DbtPlySickLDMRSManager() 50 50 { 51 51 LOG_TRACE("destructor"); 52 // delete mShMem;53 52 } 54 53 55 ////////////////////////////////////////////////////////////////////////// 56 /// Configure the component. 54 /************************************************************************ 55 * Configuration of the component, called by the ComponentManager after 56 * the construction of the object 57 ************************************************************************/ 57 58 ComponentBase::COMPONENT_CONFIGURATION DbtPlySickLDMRSManager::configureComponent(XmlComponentConfig config) 58 59 { … … 64 65 } 65 66 66 ////////////////////////////////////////////////////////////////////////// 67 /// Starts the component. 67 /************************************************************************ 68 * Start function, called by the ComponentManager when a start() 69 * command is received 70 ************************************************************************/ 68 71 void DbtPlySickLDMRSManager::startActivity() 69 72 { 70 // QString dataDir = mEngine->getDataDir();71 72 // for (int i = 0; i < mDataFilenameList.size(); ++i) {73 // QString file = mDataFilenameList.at(i);74 // mDataFilenameList[i] = dataDir + file;75 76 73 LOG_TRACE("DbtPlySickLDMRSManager component is starting."); 77 74 … … 85 82 return; 86 83 } 87 // } 84 85 outScan = getTypedOutput<SickLDMRSScan, DbtPlySickLDMRSManager>("scan"); 86 88 87 DbtPlyFileManager::startActivity(); 89 88 } 90 89 91 ////////////////////////////////////////////////////////////////////////// 92 /// Stops the component. 90 /************************************************************************ 91 * Stop function, called by the ComponentManager when a stop() 92 * command is received 93 ************************************************************************/ 93 94 void DbtPlySickLDMRSManager::stopActivity() 94 95 { … … 97 98 } 98 99 99 ////////////////////////////////////////////////////////////////////////// 100 /// processData 100 101 /************************************************************************ 102 * Called by the framework at initialization 103 ************************************************************************/ 104 void DbtPlySickLDMRSManager::addInputs() 105 { 106 // uncomment to add an input 107 } 108 109 110 /************************************************************************ 111 * Called by the framework at initialization 112 ************************************************************************/ 113 void DbtPlySickLDMRSManager::addOutputs() 114 { 115 // empty: no output 116 addOutput<SickLDMRSScan, DbtPlySickLDMRSManager>("scan"); 117 } 118 119 120 /************************************************************************ 121 * Process LiDAR data 122 ************************************************************************/ 101 123 void DbtPlySickLDMRSManager::processData(road_time_t t, road_timerange_t tr, void * buffer) 102 124 { … … 111 133 112 134 // // copy the values contained in the dbt file 113 mS ickDbt.timeStartFromSensor = sickLDMRS_dbt->timeStartFromSensor;114 mS ickDbt.hScan= sickLDMRS_dbt->hScan;115 mS ickDbt.dataPos = sickLDMRS_dbt->dataPos;116 mS ickDbt.time = t;117 mS ickDbt.timerange = tr;135 mScan.timeStartFromSensor = sickLDMRS_dbt->timeStartFromSensor; 136 mScan.header = sickLDMRS_dbt->hScan; 137 mScan.time = t; 138 mScan.timerange = tr; 139 mScan.points = QVector<ScanPoint>(mScan.header.numPoints); 118 140 119 LOG_TRACE("Number of points " << mS ickDbt.hScan.numPoints);141 LOG_TRACE("Number of points " << mScan.header.numPoints); 120 142 121 143 LOG_TRACE("Reading UTC file ... "); 122 144 123 mDataFile.seekg(mSickDbt.dataPos); // set the get pointer to the correct place 124 125 ScanPoint* points = (ScanPoint*) malloc(mSickDbt.hScan.numPoints * sizeof(ScanPoint)); 145 mDataFile.seekg(sickLDMRS_dbt->dataPos); // set the get pointer to the correct place 126 146 127 147 // then copy the data contained in the binary file 128 for (unsigned int i = 0 ; i < mS ickDbt.hScan.numPoints ; ++i) {129 mDataFile.read(reinterpret_cast<char *>(&( points[i])), sizeof(ScanPoint));148 for (unsigned int i = 0 ; i < mScan.header.numPoints ; ++i) { 149 mDataFile.read(reinterpret_cast<char *>(&(mScan.points[i])), sizeof(ScanPoint)); 130 150 } 131 132 151 133 152 // verify that the last value is the UTC magic word … … 138 157 LOG_DEBUG("wrong magic word: EXPECTED=" << UTC_MAGIC_WORD << ", ACTUAL=" << utcMagicWord); 139 158 } else { 140 LOG_TRACE("writing scan "); 141 LOG_WARN("NOT YET IMPLEMENTED"); 142 // mShMem->write(&mSickDbt, sizeof(SickLMS_dbt)); 143 144 /**********************************/ 145 /* TODO : Send data ! */ 146 /**********************************/ 159 LOG_TRACE("sending scan "); 160 checkedSend(outScan, mScan); 147 161 } 148 162 149 163 if (mVerbose) { 150 164 cout << "[SICK LDMRS]:\t" 151 << "numPoints=" << mS ickDbt.hScan.numPoints << "\t"165 << "numPoints=" << mScan.header.numPoints << "\t" 152 166 << "time=" << t << endl 153 167 ; … … 155 169 if (mVerbose >= 2) { 156 170 cout << "[SICK LDMRS]:\t" 157 << "startAngle=" << mS ickDbt.hScan.startAngle << "\t"158 << "endAngle=" << mS ickDbt.hScan.endAngle << std::endl ;171 << "startAngle=" << mScan.header.startAngle << "\t" 172 << "endAngle=" << mScan.header.endAngle << std::endl ; 159 173 } 160 free(points);161 174 } 162 175
Note:
See TracChangeset
for help on using the changeset viewer.