本文整理汇总了C++中CActionCollectionPtr类的典型用法代码示例。如果您正苦于以下问题:C++ CActionCollectionPtr类的具体用法?C++ CActionCollectionPtr怎么用?C++ CActionCollectionPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CActionCollectionPtr类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: observation
void PFLocalizationCore::observation(CSensoryFramePtr _sf, CObservationOdometryPtr _odometry) {
CActionCollectionPtr action = CActionCollection::Create();
CActionRobotMovement2D odom_move;
odom_move.timestamp = _sf->getObservationByIndex(0)->timestamp;
if(_odometry) {
if(odomLastObservation_.empty()) {
odomLastObservation_ = _odometry->odometry;
}
mrpt::poses::CPose2D incOdoPose = _odometry->odometry - odomLastObservation_;
odomLastObservation_ = _odometry->odometry;
odom_move.computeFromOdometry(incOdoPose, motion_model_options_);
action->insert(odom_move);
updateFilter(action, _sf);
} else {
if(use_motion_model_default_options_){
log_info("No odometry at update %4i -> using dummy", update_counter_);
odom_move.computeFromOdometry(mrpt::poses::CPose2D(0,0,0), motion_model_default_options_);
action->insert(odom_move);
updateFilter(action, _sf);
} else {
log_info("No odometry at update %4i -> skipping observation", update_counter_);
}
}
}
示例2: updateFilter
void PFLocalizationCore::updateFilter(CActionCollectionPtr _action, CSensoryFramePtr _sf) {
if(state_ == INIT) initializeFilter();
tictac_.Tic();
pf_.executeOn( pdf_, _action.pointer(), _sf.pointer(), &pf_stats_ );
timeLastUpdate_ = _sf->getObservationByIndex(0)->timestamp;
update_counter_++;
}
示例3: vOdometry_lightweight
// ------------------------------------------------------
// Visual Odometry
// ------------------------------------------------------
void vOdometry_lightweight()
{
// My Local Variables
CVisualOdometryStereo vOdometer;
unsigned int step = 0;
CTicTac tictac;
std::vector<CPose3DQuat> path1;
std::vector<CPose3DQuatPDFGaussian> path2;
size_t rawlogEntry = 0;
CFileGZInputStream rawlogFile( RAWLOG_FILE );
// Initial pose of the path
path1.push_back( CPose3DQuat() );
path2.push_back( CPose3DQuatPDFGaussian() );
// ----------------------------------------------------------
// vOdometry
// ----------------------------------------------------------
CActionCollectionPtr action;
CSensoryFramePtr observations;
CObservationPtr observation;
// Load options (stereo + matching + odometry)
vOdometer.loadOptions( INI_FILENAME );
// Delete previous files and prepare output dir
deleteFiles( format("%s/*.txt", OUT_DIR) );
FILE *f_cov = os::fopen( format( "%s/cov.txt", OUT_DIR ), "wt");
ASSERT_( f_cov != NULL );
// Iteration counter
int counter = 0;
FILE *f_log = os::fopen( format( "%s/q.txt", OUT_DIR ), "wt");
FILE *f_log2 = os::fopen( format( "%s/path.txt", OUT_DIR ), "wt");
unsigned int imDecimation = 5;
// Main Loop
tictac.Tic();
for (;;)
{
if (os::kbhit())
{
char c = os::getch();
if (c==27)
break;
}
// Load action/observation pair from the rawlog:
// --------------------------------------------------
if (! CRawlog::getActionObservationPairOrObservation( rawlogFile, action, observations, observation, rawlogEntry) )
break; // file EOF
if ( rawlogEntry >= RAWLOG_OFFSET && 0 == ( step % DECIMATION ) )
{
// Execute:
// ----------------------------------------
// STEREO IMAGES OBSERVATION
CObservationStereoImagesPtr sImgs;
if( observation )
sImgs = CObservationStereoImagesPtr( observation );
else
sImgs = observations->getObservationByClass<CObservationStereoImages>();
poses::CPose3DQuatPDFGaussian outEst;
if( sImgs )
{
if( counter == 0 )
{
// Set initial parameters
vOdometer.stereoParams.baseline = sImgs->rightCameraPose.x();
vOdometer.stereoParams.K = sImgs->leftCamera.intrinsicParams;
}
cout << "Rawlog Entry: " << rawlogEntry << " Iteration: " << counter++ << endl;
if( step % imDecimation )
{
vOdometer.process_light( sImgs, outEst );
TOdometryInfo info = vOdometer.getInfo();
// Save to file both the quaternion and covariance matrix
os::fprintf( f_log,"%f %f %f %f %f %f %f\n",
outEst.mean[0], outEst.mean[1], outEst.mean[2], outEst.mean[3], outEst.mean[4], outEst.mean[5], outEst.mean[6] );
info.m_Prev_cloud.landmarks.saveToTextFile( format( "%s/clouds%04d.txt", OUT_DIR, step ) );
path1.push_back( path1.back() + outEst.mean );
os::fprintf( f_log2,"%f %f %f %f %f %f %f\n",
path1.back()[0], path1.back()[1], path1.back()[2], path1.back()[3], path1.back()[4], path1.back()[5], path1.back()[6] );
path2.push_back( outEst );
//.........这里部分代码省略.........
示例4: process
/*---------------------------------------------------------------
CLSLAM_RBPF_2DLASER
Implements a 2D local SLAM method based on a RBPF
over an occupancy grid map. A part of HMT-SLAM.
\param LMH The local metric hypothesis which must be updated by this SLAM algorithm.
\param act The action to process (or NULL).
\param sf The observations to process (or NULL).
WE ALREADY HAVE CONTROL OVER THE CRITICAL SECTION OF THE LMHs!
--------------------------------------------------------------- */
void CLSLAM_RBPF_2DLASER::processOneLMH(
CLocalMetricHypothesis *LMH,
const CActionCollectionPtr &actions,
const CSensoryFramePtr &sf )
{
MRPT_START
// Get the current robot pose estimation:
TPoseID currentPoseID = LMH->m_currentRobotPose;
// If this is the first iteration, just create a new robot pose at the origin:
if (currentPoseID == POSEID_INVALID )
{
currentPoseID = CHMTSLAM::generatePoseID();
LMH->m_currentRobotPose = currentPoseID; // Change it in the LMH
// Create a new robot pose:
CPose3D initPose(0,0,0);
ASSERT_( LMH->m_particles.size()>0 );
for (CLocalMetricHypothesis::CParticleList::iterator it=LMH->m_particles.begin();it!=LMH->m_particles.end();++it)
it->d->robotPoses[ currentPoseID ] = initPose;
ASSERT_( m_parent->m_map.nodeCount()==1 );
m_parent->m_map_cs.enter();
CHMHMapNodePtr firstArea = m_parent->m_map.getFirstNode();
ASSERT_(firstArea);
LMH->m_nodeIDmemberships[currentPoseID] = firstArea->getID();
// Set annotation for the reference pose:
firstArea->m_annotations.setElemental( NODE_ANNOTATION_REF_POSEID, currentPoseID , LMH->m_ID);
m_parent->m_map_cs.leave();
}
bool insertNewRobotPose = false;
if (sf)
{
if ( LMH->m_nodeIDmemberships.size()<2 ) // If there is just 1 node (the current robot pose), then there is no observation in the map yet!
{ // Update map if this is the first observation!
insertNewRobotPose = true;
}
else
{
// Check minimum distance from current robot pose to those in the neighborhood:
map< TPoseID, CPose3D > lstRobotPoses;
LMH->getMeans( lstRobotPoses );
CPose3D *currentRobotPose = & lstRobotPoses[currentPoseID];
float minDistLin = 1e6f;
float minDistAng = 1e6f;
//printf("Poses in graph:\n");
for (map< TPoseID, CPose3D >::iterator it = lstRobotPoses.begin();it!=lstRobotPoses.end();++it)
{
if (it->first != currentPoseID )
{
float linDist = it->second.distanceTo( *currentRobotPose );
float angDist = fabs(math::wrapToPi( it->second.yaw() - currentRobotPose->yaw() ));
minDistLin = min( minDistLin, linDist );
if ( linDist < m_parent->m_options.SLAM_MIN_DIST_BETWEEN_OBS )
minDistAng = min(minDistAng, angDist);
}
}
// time to insert a new node??
insertNewRobotPose = (minDistLin>m_parent->m_options.SLAM_MIN_DIST_BETWEEN_OBS) || ( minDistAng > m_parent->m_options.SLAM_MIN_HEADING_BETWEEN_OBS );
}
} // end if there are SF
// Save data in members so PF callback "prediction_and_update_pfXXXX" have access to them:
m_insertNewRobotPose = insertNewRobotPose;
// ------------------------------------------------
// Execute RBPF method:
// 1) PROCESS ACTION
// 2) PROCESS OBSERVATIONS
// ------------------------------------------------
CParticleFilter pf;
pf.m_options = m_parent->m_options.pf_options;
pf.executeOn( *LMH, actions.pointer(), sf.pointer() );
// 3) The appearance observation: update the log likelihood
//.........这里部分代码省略.........
示例5: TestLaser2Imgs
// ------------------------------------------------------
// TestGeometry3D
// ------------------------------------------------------
void TestLaser2Imgs()
{
// Set your rawlog file name
if (!mrpt::system::fileExists(RAWLOG_FILE))
THROW_EXCEPTION_CUSTOM_MSG1("Rawlog file does not exist: %s",RAWLOG_FILE.c_str())
CActionCollectionPtr action;
CSensoryFramePtr observations;
size_t rawlogEntry = 0;
//bool end = false;
CDisplayWindow wind;
// Set relative path for externally-stored images in rawlogs:
string rawlog_images_path = extractFileDirectory( RAWLOG_FILE );
rawlog_images_path+="/Images";
CImage::IMAGES_PATH_BASE = rawlog_images_path; // Set it.
CFileGZInputStream rawlogFile( RAWLOG_FILE );
for (;;)
{
if (os::kbhit())
{
char c = os::getch();
if (c==27)
break;
}
// Load action/observation pair from the rawlog:
// --------------------------------------------------
cout << "Reading act/oct pair from rawlog..." << endl;
if (! CRawlog::readActionObservationPair( rawlogFile, action, observations, rawlogEntry) )
break; // file EOF
// CAMERA............
// Get CObservationStereoImages
CObservationStereoImagesPtr sImgs;
CObservationImagePtr Img;
sImgs = observations->getObservationByClass<CObservationStereoImages>();
if (!sImgs)
{
Img = observations->getObservationByClass<CObservationImage>();
if(!Img)
continue;
}
CPose3D cameraPose; // Get Camera Pose (B) (CPose3D)
CMatrixDouble33 K; // Get Calibration matrix (K)
sImgs ? sImgs->getSensorPose( cameraPose ) : Img->getSensorPose( cameraPose );
K = sImgs ? sImgs->leftCamera.intrinsicParams : Img->cameraParams.intrinsicParams;
// LASER.............
// Get CObservationRange2D
CObservation2DRangeScanPtr laserScan = observations->getObservationByClass<CObservation2DRangeScan>();
if (!laserScan) continue;
// Get Laser Pose (A) (CPose3D)
CPose3D laserPose;
laserScan->getSensorPose( laserPose );
if (abs(laserPose.yaw())>DEG2RAD(90)) continue; // Only front lasers
// Get 3D Point relative to the Laser coordinate Frame (P1) (CPoint3D)
CPoint3D point;
CSimplePointsMap mapa;
mapa.insertionOptions.minDistBetweenLaserPoints = 0;
observations->insertObservationsInto( &mapa ); // <- The map contains the pose of the points (P1)
// Get the points into the map
vector<float> X, Y, Z;
vector<float>::iterator itX, itY, itZ;
mapa.getAllPoints(X,Y,Z);
unsigned int imgW = sImgs? sImgs->imageLeft.getWidth() : Img->image.getWidth();
unsigned int imgH = sImgs? sImgs->imageLeft.getHeight() : Img->image.getHeight();
//unsigned int idx = 0;
vector<float> imgX,imgY;
vector<float>::iterator itImgX,itImgY;
imgX.resize( X.size() );
imgY.resize( Y.size() );
CImage image;
image = sImgs ? sImgs->imageLeft : Img->image;
// Get pixels in the image:
// Pimg = (kx,ky,k)^T = K(I|0)*P2
// Main loop
for( itX = X.begin(), itY = Y.begin(), itZ = Z.begin(), itImgX = imgX.begin(), itImgY = imgY.begin();
itX != X.end();
itX++, itY++, itZ++, itImgX++, itImgY++)
{
// Coordinates Transformation
CPoint3D pLaser(*itX,*itY,*itZ);
//.........这里部分代码省略.........
示例6: TNodeData
/* ------------------------------------------------------------
reloadFromRawlog
------------------------------------------------------------ */
void CRawlogTreeView::reloadFromRawlog( int hint_rawlog_items )
{
// Recompute the total height of the scroll area:
// We also compute a list for each index with:
// - Pointer to data
// - level in the hierarchy (0,1,2)
// --------------------------------------------------------
if (m_rawlog)
{
if (hint_rawlog_items<0)
m_tree_nodes.reserve( m_rawlog->size()+100 );
else m_tree_nodes.reserve( hint_rawlog_items+100 );
}
// Create a "tree node" for each element in the rawlog:
// ---------------------------------------------------------
m_tree_nodes.clear();
m_rawlog_start = INVALID_TIMESTAMP;
m_rawlog_last = INVALID_TIMESTAMP;
// Root:
m_tree_nodes.push_back( TNodeData() );
TNodeData &d = m_tree_nodes.back();
d.level = 0;
// CVectorDouble tims;
if (m_rawlog)
{
CRawlog::iterator end_it = m_rawlog->end();
size_t rawlog_index = 0;
for (CRawlog::iterator it=m_rawlog->begin();it!=end_it;it++,rawlog_index++)
{
m_tree_nodes.push_back( TNodeData() );
TNodeData &d = m_tree_nodes.back();
d.level = 1;
d.data = (*it);
d.index = rawlog_index;
// For containers, go recursively:
if ( (*it)->GetRuntimeClass()==CLASS_ID(CSensoryFrame))
{
CSensoryFramePtr sf = CSensoryFramePtr( *it );
for (CSensoryFrame::iterator o=sf->begin();o!=sf->end();++o)
{
m_tree_nodes.push_back( TNodeData() );
TNodeData &d = m_tree_nodes.back();
d.level = 2;
d.data = (*o);
if ((*o)->timestamp!=INVALID_TIMESTAMP)
{
m_rawlog_last = (*o)->timestamp;
if (m_rawlog_start == INVALID_TIMESTAMP)
m_rawlog_start = (*o)->timestamp;
}
}
}
else
if ( (*it)->GetRuntimeClass()==CLASS_ID(CActionCollection))
{
CActionCollectionPtr acts = CActionCollectionPtr( *it );
for (CActionCollection::iterator a=acts->begin();a!=acts->end();++a)
{
m_tree_nodes.push_back( TNodeData() );
TNodeData &d = m_tree_nodes.back();
d.level = 2;
d.data = (*a);
if ((*a)->timestamp!=INVALID_TIMESTAMP)
{
m_rawlog_last = (*a)->timestamp;
if (m_rawlog_start == INVALID_TIMESTAMP)
m_rawlog_start = (*a)->timestamp;
}
}
}
else
if ( (*it)->GetRuntimeClass()->derivedFrom( CLASS_ID(CObservation) ))
{
CObservationPtr o = CObservationPtr(*it);
if (o->timestamp!=INVALID_TIMESTAMP)
{
m_rawlog_last = o->timestamp;
if (m_rawlog_start == INVALID_TIMESTAMP)
m_rawlog_start = o->timestamp;
//tims.push_back( mrpt::system::timeDifference(m_rawlog_start, o->timestamp));
}
}
}
}
// mrpt::system::vectorToTextFile(tims,"tims.txt");
//.........这里部分代码省略.........
示例7: THROW_EXCEPTION
/** This is the common function for all operations over a rawlog file ("filter" a rawlog file into a new one) or over the loaded rawlog (depending on the user selection in the GUI).
*/
void CFormChangeSensorPositions::executeOperationOnRawlog( TRawlogFilter operation, const char *endMsg )
{
WX_START_TRY
int processMax;
bool isInMemory;
CStream *in_fil=NULL,*out_fil=NULL;
sensorPoseReadOK = false;
camReadIsOk = false;
if (rbLoaded->GetValue())
{
// APPLY TO rawlog in memory:
isInMemory = true;
processMax = (int)rawlog.size();
}
else
{
// APPLY TO rawlog files:
isInMemory = false;
if ( !txtInputFile->GetValue().size() )
THROW_EXCEPTION("An input rawlog file must be selected")
if ( !txtOutputFile->GetValue().size() )
THROW_EXCEPTION("An output rawlog file must be selected")
string fileName_IN( txtInputFile->GetValue().mbc_str() );
if (!mrpt::system::fileExists(fileName_IN) )
THROW_EXCEPTION("Input file does not exist!")
string fileName_OUT( txtOutputFile->GetValue().mbc_str() );
if (!fileName_OUT.compare(fileName_IN))
THROW_EXCEPTION("Input and output files must be different!")
in_fil = new CFileGZInputStream(fileName_IN);
out_fil = new CFileGZOutputStream(fileName_OUT);
processMax = (int)in_fil->getTotalBytesCount();
}
wxProgressDialog progDia(
wxT("Modifying rawlog"),
wxT("Processing..."),
processMax, // range
this, // parent
wxPD_CAN_ABORT |
wxPD_APP_MODAL |
wxPD_SMOOTH |
wxPD_AUTO_HIDE |
wxPD_ELAPSED_TIME |
wxPD_ESTIMATED_TIME |
wxPD_REMAINING_TIME);
wxTheApp->Yield(); // Let the app. process messages
unsigned int countLoop = 0;
bool keepLoading=true;
string errorMsg;
wxString auxStr;
// Apply changes:
int changes = 0;
wxBusyCursor cursor;
while ((( !isInMemory && keepLoading ) ||
( isInMemory && countLoop < rawlog.size() ))&& !sensorPoseReadOK && !camReadIsOk )
{
CSerializablePtr newObj;
try
{
if (isInMemory)
{
newObj = rawlog.getAsGeneric(countLoop);
}
else
{
(*in_fil) >> newObj;
}
// Check type:
if ( newObj->GetRuntimeClass() == CLASS_ID(CSensoryFrame))
{
// A sensory frame:
CSensoryFramePtr sf(newObj);
// Process & save:
operation(NULL,sf.pointer(),changes );
if (!isInMemory) (*out_fil) << *sf.pointer();
}
else if ( newObj->GetRuntimeClass() == CLASS_ID(CActionCollection))
{
// This is an action:
CActionCollectionPtr acts =CActionCollectionPtr( newObj );
//.........这里部分代码省略.........
示例8: MapBuilding_ICP
// ------------------------------------------------------
// MapBuilding_ICP
// ------------------------------------------------------
void MapBuilding_ICP()
{
MRPT_TRY_START
CTicTac tictac,tictacGlobal,tictac_JH;
int step = 0;
std::string str;
CSensFrameProbSequence finalMap;
float t_exec;
COccupancyGridMap2D::TEntropyInfo entropy;
size_t rawlogEntry = 0;
CFileGZInputStream rawlogFile( RAWLOG_FILE.c_str() );
CFileGZOutputStream sensor_data;
// ---------------------------------
// Constructor
// ---------------------------------
CMetricMapBuilderICP mapBuilder(
&metricMapsOpts,
insertionLinDistance,
insertionAngDistance,
&icpOptions
);
mapBuilder.ICP_options.matchAgainstTheGrid = matchAgainstTheGrid;
// ---------------------------------
// CMetricMapBuilder::TOptions
// ---------------------------------
mapBuilder.options.verbose = true;
mapBuilder.options.enableMapUpdating = true;
mapBuilder.options.debugForceInsertion = false;
mapBuilder.options.insertImagesAlways = false;
// Prepare output directory:
// --------------------------------
deleteFilesInDirectory(OUT_DIR);
createDirectory(OUT_DIR);
// Open log files:
// ----------------------------------
CFileOutputStream f_log(format("%s/log_times.txt",OUT_DIR));
CFileOutputStream f_path(format("%s/log_estimated_path.txt",OUT_DIR));
CFileOutputStream f_pathOdo(format("%s/log_odometry_path.txt",OUT_DIR));
// Create 3D window if requested:
CDisplayWindow3DPtr win3D;
#if MRPT_HAS_WXWIDGETS
if (SHOW_PROGRESS_3D_REAL_TIME)
{
win3D = CDisplayWindow3DPtr( new CDisplayWindow3D("ICP-SLAM @ MRPT C++ Library (C) 2004-2008", 600, 500) );
win3D->setCameraZoom(20);
win3D->setCameraAzimuthDeg(-45);
}
#endif
if(OBS_FROM_FILE == 0){
sensor_data.open("sensor_data.rawlog");
printf("Receive From Sensor\n");
initLaser();
printf("OK\n");
}
// ----------------------------------------------------------
// Map Building
// ----------------------------------------------------------
CActionCollectionPtr action;
CSensoryFramePtr observations, temp_obs;
CSensoryFramePtr obs_set;
CPose2D odoPose(0,0,0);
CSimplePointsMap oldMap, newMap;
CICP ICP;
vector_float accum_x, accum_y, accum_z;
// ICP Setting
ICP.options.ICP_algorithm = (TICPAlgorithm)ICP_method;
ICP.options.maxIterations = 40;
ICP.options.thresholdAng = 0.15;
ICP.options.thresholdDist = 0.75f;
ICP.options.ALFA = 0.30f;
ICP.options.smallestThresholdDist = 0.10f;
ICP.options.doRANSAC = false;
ICP.options.dumpToConsole();
//
CObservationPtr obsSick = CObservationPtr(new CObservation2DRangeScan());
CObservationPtr obsHokuyo = CObservationPtr(new CObservation2DRangeScan());
CSimplePointsMap hokuyoMap;
bool isFirstTime = true;
//.........这里部分代码省略.........
示例9: wxMessageBox
void xRawLogViewerFrame::OnMenuConvertObservationOnly(wxCommandEvent& event)
{
WX_START_TRY
wxMessageBox( _("Select the rawlog file to convert...") );
string str;
if ( !AskForOpenRawlog( str ) ) return;
wxMessageBox( _("Select the target file where to save the new rawlog.") );
string filToSave;
if ( !AskForSaveRawlog( filToSave ) ) return;
wxBusyCursor waitCursor;
CFileGZInputStream fil(str);
unsigned int filSize = (unsigned int)fil.getTotalBytesCount();
CFileGZOutputStream f_out(filToSave);
wxString auxStr;
wxProgressDialog progDia(
wxT("Progress"),
wxT("Parsing file..."),
filSize, // range
this, // parent
wxPD_CAN_ABORT |
wxPD_APP_MODAL |
wxPD_SMOOTH |
wxPD_AUTO_HIDE |
wxPD_ELAPSED_TIME |
wxPD_ESTIMATED_TIME |
wxPD_REMAINING_TIME);
wxTheApp->Yield(); // Let the app. process messages
unsigned int countLoop = 0;
bool keepLoading=true;
string errorMsg;
CPose2D odometry_accum;
// We'll save here all the individual observations ordered in time:
TListTimeAndObservations time_ordered_list_observation;
mrpt::system::TTimeStamp lastValidObsTime = INVALID_TIMESTAMP;
while (keepLoading)
{
if (countLoop++ % 5 == 0)
{
auxStr.sprintf(wxT("Parsing file... %u objects"),countLoop );
if (!progDia.Update( (int)fil.getPosition(), auxStr ))
keepLoading = false;
wxTheApp->Yield(); // Let the app. process messages
}
try
{
CSerializablePtr newObj;
fil >> newObj;
// Check type:
if ( newObj->GetRuntimeClass() == CLASS_ID(CSensoryFrame) )
{
CSensoryFramePtr SF(newObj);
for (CSensoryFrame::iterator it=SF->begin();it!=SF->end();++it)
{
time_ordered_list_observation.insert( TTimeObservationPair( (*it)->timestamp, (*it) ));
lastValidObsTime = (*it)->timestamp;
}
}
else
if ( newObj->GetRuntimeClass() == CLASS_ID(CActionCollection) )
{
// Replace "odometry action" with "odometry observation":
CActionCollectionPtr acts = CActionCollectionPtr( newObj );
// Get odometry:
CActionRobotMovement2DPtr actOdom = acts->getBestMovementEstimation();
if (actOdom)
{
odometry_accum = odometry_accum + actOdom->poseChange->getMeanVal();
// Generate "odometry obs":
CObservationOdometryPtr newO = CObservationOdometry::Create();
newO->sensorLabel = "odometry";
newO->timestamp = actOdom->timestamp!=INVALID_TIMESTAMP ? actOdom->timestamp : lastValidObsTime;
newO->odometry = odometry_accum;
time_ordered_list_observation.insert( TTimeObservationPair( newO->timestamp, newO ));
}
}
else
if ( newObj->GetRuntimeClass()->derivedFrom( CLASS_ID(CObservation) ) )
{
CObservationPtr o = CObservationPtr( newObj );
time_ordered_list_observation.insert( TTimeObservationPair( o->timestamp, o ));
}
// Dump to the new file: Only the oldest one:
//.........这里部分代码省略.........
示例10: wxGetTextFromUser
//.........这里部分代码省略.........
if (!progDia.Update( (int)fil.getPosition(), auxStr ))
keepLoading = false;
wxTheApp->Yield(); // Let the app. process messages
}
CSerializablePtr newObj;
try
{
fil >> newObj;
entryIndex++;
// Check type:
if ( newObj->GetRuntimeClass() == CLASS_ID(CSensoryFrame) )
{
// Decimate Observations
// ---------------------------
// Add observations to the accum. SF:
if (!accum_sf)
accum_sf = CSensoryFrame::Create();
// Copy pointers to observations only (fast):
accum_sf->moveFrom( *CSensoryFramePtr(newObj) );
if ( ++SF_counter >= DECIMATE_RATIO )
{
SF_counter = 0;
// INSERT OBSERVATIONS:
f_out << *accum_sf;
accum_sf.clear_unique();
// INSERT ACTIONS:
CActionCollectionPtr actsCol = CActionCollection::Create();
if (cummMovementInit)
{
CActionRobotMovement2D cummMovement;
cummMovement.computeFromOdometry(accumMovement, odometryOptions );
cummMovement.timestamp = timestamp_lastAction;
actsCol->insert( cummMovement );
// Reset odometry accumulation:
accumMovement = CPose2D(0,0,0);
}
f_out << *actsCol;
actsCol.clear_unique();
}
}
else if ( newObj->GetRuntimeClass() == CLASS_ID(CActionCollection) )
{
// Accumulate Actions
// ----------------------
CActionCollectionPtr curActs = CActionCollectionPtr( newObj );
CActionRobotMovement2DPtr mov = curActs->getBestMovementEstimation();
if (mov)
{
timestamp_lastAction = mov->timestamp;
CPose2D incrPose = mov->poseChange->getMeanVal();
// If we have previous observations, shift them according to this new increment:
if (accum_sf)
{
CPose3D inv_incrPose3D( CPose3D(0,0,0) - CPose3D(incrPose) );
for (CSensoryFrame::iterator it=accum_sf->begin();it!=accum_sf->end();++it)
{
CPose3D tmpPose;
示例11: icp_test_1
// ------------------------------------------------------
// Benchmark: A whole ICP-SLAM run
// ------------------------------------------------------
double icp_test_1(int a1, int a2)
{
#ifdef MRPT_DATASET_DIR
const string rawlog_file = MRPT_DATASET_DIR "/2006-01ENE-21-SENA_Telecom Faculty_one_loop_only.rawlog";
if (!mrpt::system::fileExists(rawlog_file))
return 1;
CTicTac tictac;
int step = 0;
size_t rawlogEntry = 0;
CFileGZInputStream rawlogFile( rawlog_file );
TSetOfMetricMapInitializers metricMapsOpts;
const bool use_grid = a1!=0;
if (use_grid)
{
COccupancyGridMap2D::TMapDefinition def;
def.resolution = 0.05;
metricMapsOpts.push_back( def );
}
else
{
CSimplePointsMap::TMapDefinition def;
def.insertionOpts.minDistBetweenLaserPoints = 0.03;
metricMapsOpts.push_back( def );
}
double insertionLinDistance = 0.75;
double insertionAngDistance = DEG2RAD(30);
CICP::TConfigParams icpOptions;
icpOptions.maxIterations = 40;
// ---------------------------------
// Constructor
// ---------------------------------
CMetricMapBuilderICP mapBuilder;
mapBuilder.ICP_options.mapInitializers = metricMapsOpts;
mapBuilder.ICP_options.insertionLinDistance = insertionLinDistance;
mapBuilder.ICP_options.insertionAngDistance = insertionAngDistance;
mapBuilder.ICP_options.matchAgainstTheGrid = use_grid ;
mapBuilder.ICP_params = icpOptions;
// Start with an empty map:
mapBuilder.initialize( CSimpleMap() );
// ---------------------------------
// CMetricMapBuilder::TOptions
// ---------------------------------
mapBuilder.options.verbose = false;
mapBuilder.options.enableMapUpdating = true;
// ----------------------------------------------------------
// Map Building
// ----------------------------------------------------------
CActionCollectionPtr action;
CSensoryFramePtr observations;
for (;;)
{
// Load action/observation pair from the rawlog:
// --------------------------------------------------
if (! CRawlog::readActionObservationPair( rawlogFile, action, observations, rawlogEntry) )
break; // file EOF
// Execute:
mapBuilder.processActionObservation( *action, *observations );
step++;
// printf("\n---------------- STEP %u | RAWLOG ENTRY %u ----------------\n",step, (unsigned)rawlogEntry);
// Free memory:
action.clear_unique();
observations.clear_unique();
}
#if 0
mapBuilder.getCurrentlyBuiltMetricMap()->saveMetricMapRepresentationToFile( format("icp_%i_result",a1) );
#endif
if (!step) step++;
return tictac.Tac()/step;
#else
return 1;
#endif
}
示例12: ASSERT_
/*---------------------------------------------------------------
process
---------------------------------------------------------------*/
void CDetectorDoorCrossing::process(
CActionRobotMovement2D &in_poseChange,
CSensoryFrame &in_sf,
TDoorCrossingOutParams &out_estimation
)
{
// Variables for generic use:
size_t i;
out_estimation.cumulativeTurning = 0;
MRPT_START
// 1) Add new pair to the list:
// -----------------------------------------
lastObs.addAction( in_poseChange );
lastObs.addObservations( in_sf );
// 2) Remove oldest pair:
// -----------------------------------------
ASSERT_( options.windowSize > 1 );
ASSERT_( (lastObs.size() % 2) == 0 ); // Assure even size
while (lastObs.size()>options.windowSize*2)
{
lastObs.remove(0);
lastObs.remove(0);
}
if ( lastObs.size() < options.windowSize * 2 )
{
// Not enought old data yet:
out_estimation.enoughtInformation = false;
return;
}
// 3) Build an occupancy grid map with observations
// -------------------------------------------------
CPose2D p, pos;
TSetOfMetricMapInitializers mapInitializer;
{
CSimplePointsMap::TMapDefinition def;
mapInitializer.push_back( def );
}
{
COccupancyGridMap2D::TMapDefinition def;
def.resolution = options.gridResolution;
mapInitializer.push_back( def );
}
CMultiMetricMap auxMap( &mapInitializer );
for (i=0;i<options.windowSize;i++)
{
CActionCollectionPtr acts = lastObs.getAsAction( i*2+0 );
CActionPtr act = acts->get(0);
ASSERT_( act->GetRuntimeClass()->derivedFrom( CLASS_ID( CActionRobotMovement2D ) ) )
CActionRobotMovement2DPtr action = CActionRobotMovement2DPtr( act );
action->poseChange->getMean(pos);
out_estimation.cumulativeTurning+= fabs(pos.phi());
// Get the cumulative pose for the current observation:
p = p + pos;
// Add SF to the grid map:
CSensoryFramePtr sf = lastObs.getAsObservations( i*2+1 );
CPose3D pose3D(p);
sf->insertObservationsInto( &auxMap, &pose3D );
}
// 4) Compute the information differece between this
// "map patch" and the previous one:
// -------------------------------------------------------
auxMap.m_gridMaps[0]->computeEntropy( entropy );
if (!lastEntropyValid)
{
out_estimation.enoughtInformation = false;
}
else
{
// 5) Fill output data
// ---------------------------------
out_estimation.enoughtInformation = true;
out_estimation.informationGain = entropy.I - lastEntropy.I;
out_estimation.pointsMap.copyFrom( *auxMap.m_pointsMaps[0] );
}
// For next iterations:
//.........这里部分代码省略.........
示例13: addAction
void CRawlog::addAction( CAction &action )
{
CActionCollectionPtr temp = CActionCollection::Create();
temp->insert( action );
m_seqOfActObs.push_back( temp );
}
示例14: MapBuilding_ICP
//.........这里部分代码省略.........
// Prepare output directory:
// --------------------------------
deleteFilesInDirectory(OUT_DIR);
createDirectory(OUT_DIR);
// Open log files:
// ----------------------------------
CFileOutputStream f_log(format("%s/log_times.txt",OUT_DIR));
CFileOutputStream f_path(format("%s/log_estimated_path.txt",OUT_DIR));
CFileOutputStream f_pathOdo(format("%s/log_odometry_path.txt",OUT_DIR));
// Create 3D window if requested:
CDisplayWindow3DPtr win3D;
#if MRPT_HAS_WXWIDGETS
if (SHOW_PROGRESS_3D_REAL_TIME)
{
win3D = CDisplayWindow3D::Create("ICP-SLAM @ MRPT C++ Library", 600, 500);
win3D->setCameraZoom(20);
win3D->setCameraAzimuthDeg(-45);
}
#endif
// ----------------------------------------------------------
// Map Building
// ----------------------------------------------------------
CPose2D odoPose(0,0,0);
tictacGlobal.Tic();
for (;;)
{
CActionCollectionPtr action;
CSensoryFramePtr observations;
CObservationPtr observation;
if (os::kbhit())
{
char c = os::getch();
if (c==27)
break;
}
// Load action/observation pair from the rawlog:
// --------------------------------------------------
if (! CRawlog::getActionObservationPairOrObservation( rawlogFile, action, observations, observation, rawlogEntry) )
break; // file EOF
const bool isObsBasedRawlog = observation.present();
if (rawlogEntry>=rawlog_offset)
{
// Update odometry:
if (isObsBasedRawlog)
{
static CPose2D lastOdo;
static bool firstOdo = true;
if (IS_CLASS(observation,CObservationOdometry))
{
CObservationOdometryPtr o = CObservationOdometryPtr(observation);
if (!firstOdo)
odoPose = odoPose + (o->odometry - lastOdo);
lastOdo=o->odometry;
firstOdo=false;