Changeset 104 in pacpussensors


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

Updated I/O for Sick LDMRS

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Sick/SickLDMRSData.h

    r71 r104  
    1717#include "Pacpus/kernel/cstdint.h"
    1818#include "Pacpus/kernel/road_time.h"
     19#include <QVector>
    1920
    2021// Export macro for SickLDMRS DLL for Windows only
     
    8384    uint64_t endNtpTime;   //!< NTP time last measurement
    8485    uint16_t ticksPerRot;  //!< Angle ticks per rotation (used to compute the real angle of a point)
    85     int16_t startAngle;     //!< Angle of the first measured value
    86     int16_t endAngle;       //!< Angle of the last measured value
     86    int16_t  startAngle;     //!< Angle of the first measured value
     87    int16_t  endAngle;       //!< Angle of the last measured value
    8788    uint16_t numPoints;    //!< Number of scanned points during this scan @see ScanPoint
    8889
     
    124125 * Data type 0x2221 @see DataHeader
    125126 */
     127
    126128struct SICKLDMRS_API ScanObject{
    127129    // TODO
     
    136138typedef struct
    137139{
    138     uint64_t timeStartFromSensor;  //!< NTP time (creation of the message on sensor).
     140    uint64_t timeStartFromSensor;   //!< NTP time (creation of the message on sensor).
    139141    ScanHeader hScan;               //!< General information about points recorded. @see ScanHeader
    140142    road_time_t time;               //!< DBT timestamp.
     
    142144    int32_t dataPos;                //!< The position of the data in the binary file associated to the dbt file (utc file).
    143145} SickLDMRS_dbt;
     146
     147/*!
     148 * \brief The Sick LDMRS scan struct
     149 *
     150 * Used to describe one complete scan
     151 * @see DataHeader
     152 */
     153struct SICKLDMRS_API SickLDMRSScan{
     154    uint64_t timeStartFromSensor;   //!< NTP time (creation of the message on sensor).
     155    ScanHeader header;              //!< General information about points recorded.
     156    QVector<ScanPoint> points;      //!< Scan point cloud
     157    road_time_t time;               //!< DBT timestamp.
     158    road_timerange_t timerange;     //!< DBT timerange.
     159};
    144160
    145161#ifdef SICKLDMRS_SH_MEM
  • 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
  • trunk/StdDbtPlayerComponents/DbtPlySickLDMRSManager.h

    r99 r104  
    1717
    1818#include "Pacpus/DbitePlayer/DbtPlyFileManager.h"
     19#include <Pacpus/kernel/InputOutputInterface.h>
    1920#include "../Sick/SickLDMRSData.h"
    2021
     
    4445    ~DbtPlySickLDMRSManager();
    4546
     47    virtual void startActivity();
     48    virtual void stopActivity();
     49    virtual ComponentBase::COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
     50
     51    virtual void addInputs();
     52    virtual void addOutputs();
     53
    4654protected:
    4755    void processData(road_time_t t, road_timerange_t tr, void * buffer);
    4856    void displayUI();
    4957
    50     virtual ComponentBase::COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
    51     virtual void startActivity();
    52     virtual void stopActivity();
    53 
    5458private:
    55     // ShMem * mShMem;
    5659    SickLDMRS_dbt mSickDbt;
    5760
     61    // .dbt file ("sickldmrs_0.dbt")
    5862    std::ifstream mDataFile;
     63    // .utc data file ("sickldmrs_0_data.utc")
    5964    QString mDataFilename;
    6065
    61     QStringList mDataFilenameList;
     66    // local copy of each scan
     67    SickLDMRSScan mScan;
     68
     69    // Declaration of outputs
     70    OutputInterface<SickLDMRSScan, DbtPlySickLDMRSManager>* outScan;
    6271};
    6372
Note: See TracChangeset for help on using the changeset viewer.