Ignore:
Timestamp:
11/22/15 23:00:29 (9 years ago)
Author:
xuphilip
Message:

Updated I/O for Sick LDMRS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/StdDbtPlayerComponents/DbtPlySickLDMRSManager.cpp

    r74 r104  
    3535static const char * kSickMemoryName = "sickLDMRS";
    3636
    37 //////////////////////////////////////////////////////////////////////////
    38 /// Constructor.
     37/************************************************************************
     38 * Constructor
     39 ************************************************************************/
    3940DbtPlySickLDMRSManager::DbtPlySickLDMRSManager(QString name)
    4041    : DbtPlyFileManager(name)
    4142{
    4243    LOG_TRACE("constructor(" << name << ")");
    43 
    44     // mShMem = new ShMem(kAlaskaMemoryName, sizeof(ScanSickData));
    4544}
    4645
    47 //////////////////////////////////////////////////////////////////////////
    48 /// Destructor.
     46/************************************************************************
     47 * Destructor
     48 ************************************************************************/
    4949DbtPlySickLDMRSManager::~DbtPlySickLDMRSManager()
    5050{
    5151    LOG_TRACE("destructor");
    52     // delete mShMem;
    5352}
    5453
    55 //////////////////////////////////////////////////////////////////////////
    56 /// Configure the component.
     54/************************************************************************
     55 * Configuration of the component, called by the ComponentManager after
     56 * the construction of the object
     57 ************************************************************************/
    5758ComponentBase::COMPONENT_CONFIGURATION DbtPlySickLDMRSManager::configureComponent(XmlComponentConfig config)
    5859{
     
    6465}
    6566
    66 //////////////////////////////////////////////////////////////////////////
    67 /// Starts the component.
     67/************************************************************************
     68 * Start function, called by the ComponentManager when a start()
     69 * command is received
     70 ************************************************************************/
    6871void DbtPlySickLDMRSManager::startActivity()
    6972{
    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 
    7673    LOG_TRACE("DbtPlySickLDMRSManager component is starting.");
    7774
     
    8582        return;
    8683    }
    87     // }
     84
     85    outScan = getTypedOutput<SickLDMRSScan, DbtPlySickLDMRSManager>("scan");
     86
    8887    DbtPlyFileManager::startActivity();
    8988}
    9089
    91 //////////////////////////////////////////////////////////////////////////
    92 /// Stops the component.
     90/************************************************************************
     91 * Stop function, called by the ComponentManager when a stop()
     92 * command is received
     93 ************************************************************************/
    9394void DbtPlySickLDMRSManager::stopActivity()
    9495{
     
    9798}
    9899
    99 //////////////////////////////////////////////////////////////////////////
    100 /// processData
     100
     101/************************************************************************
     102 * Called by the framework at initialization
     103 ************************************************************************/
     104void DbtPlySickLDMRSManager::addInputs()
     105{
     106  // uncomment to add an input
     107}
     108
     109
     110/************************************************************************
     111 * Called by the framework at initialization
     112 ************************************************************************/
     113void DbtPlySickLDMRSManager::addOutputs()
     114{
     115  // empty: no output
     116  addOutput<SickLDMRSScan, DbtPlySickLDMRSManager>("scan");
     117}
     118
     119
     120/************************************************************************
     121 * Process LiDAR data
     122 ************************************************************************/
    101123void DbtPlySickLDMRSManager::processData(road_time_t t, road_timerange_t tr, void * buffer)
    102124{
     
    111133
    112134    // // copy the values contained in the dbt file
    113     mSickDbt.timeStartFromSensor = sickLDMRS_dbt->timeStartFromSensor;
    114     mSickDbt.hScan = sickLDMRS_dbt->hScan;
    115     mSickDbt.dataPos = sickLDMRS_dbt->dataPos;
    116     mSickDbt.time = t;
    117     mSickDbt.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);
    118140
    119     LOG_TRACE("Number of points " << mSickDbt.hScan.numPoints);
     141    LOG_TRACE("Number of points " << mScan.header.numPoints);
    120142
    121143    LOG_TRACE("Reading UTC file ... ");
    122144
    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
    126146
    127147    // then copy the data contained in the binary file
    128     for (unsigned int i = 0 ; i < mSickDbt.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));
    130150    }
    131 
    132151
    133152    // verify that the last value is the UTC magic word
     
    138157        LOG_DEBUG("wrong magic word: EXPECTED=" << UTC_MAGIC_WORD << ", ACTUAL=" << utcMagicWord);
    139158    } 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);
    147161    }
    148162
    149163    if (mVerbose) {
    150164        cout << "[SICK LDMRS]:\t"
    151              << "numPoints=" << mSickDbt.hScan.numPoints << "\t"
     165             << "numPoints=" << mScan.header.numPoints << "\t"
    152166             << "time=" << t << endl
    153167                ;
     
    155169    if (mVerbose >= 2)  {
    156170        cout << "[SICK LDMRS]:\t"
    157              << "startAngle=" << mSickDbt.hScan.startAngle << "\t"
    158              << "endAngle=" << mSickDbt.hScan.endAngle << std::endl ;
     171             << "startAngle=" << mScan.header.startAngle << "\t"
     172             << "endAngle=" << mScan.header.endAngle << std::endl ;
    159173    }
    160     free(points);
    161174}
    162175
Note: See TracChangeset for help on using the changeset viewer.