Skip to content

Commit

Permalink
Fix time computation for velocity estimator; removed synced GT publis…
Browse files Browse the repository at this point in the history
…hing - evaluate should subscribe to original GT; latest observation time is now given by landmark observations to prevent cases where target is not seen
  • Loading branch information
Guilherme Lawless committed Jan 6, 2017
1 parent f806423 commit c785d37
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
10 changes: 5 additions & 5 deletions include/pfuclt_omni_dataset/pfuclt_particles.h
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,11 @@ class ParticleFilter
*/
inline void saveLandmarkObservation(const uint robotNumber,
const uint landmarkNumber,
const LandmarkObservation obs)
const LandmarkObservation obs,
ros::Time stamp)
{
bufLandmarkObservations_[robotNumber][landmarkNumber] = obs;
latestObservationTime_ = stamp;
}

/**
Expand Down Expand Up @@ -585,7 +587,6 @@ class ParticleFilter
ros::Time stamp)
{
bufTargetObservations_[robotNumber] = obs;
latestObservationTime_ = stamp;
}

/**
Expand Down Expand Up @@ -649,9 +650,8 @@ class PFPublisher : public ParticleFilter

private:
ros::Subscriber GT_sub_;
ros::Publisher estimatePublisher_,
particlePublisher_, syncedGTPublisher_, targetEstimatePublisher_,
targetGTPublisher_, targetParticlePublisher_;
ros::Publisher estimatePublisher_, particlePublisher_,
targetEstimatePublisher_, targetGTPublisher_, targetParticlePublisher_;
std::vector<ros::Publisher> particleStdPublishers_;
std::vector<ros::Publisher> robotGTPublishers_;
std::vector<ros::Publisher> robotEstimatePublishers_;
Expand Down
3 changes: 2 additions & 1 deletion src/pfuclt_omni_dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ void Robot::landmarkDataCallback(
pow(cos(obs.phi), 2) *
(pow(obs.d, 2) * obs.covPP + obs.covDD * obs.covPP);

pf_->saveLandmarkObservation(robotNumber_, i, obs);
pf_->saveLandmarkObservation(robotNumber_, i, obs,
landmarkData->header.stamp);
}
}

Expand Down
16 changes: 5 additions & 11 deletions src/pfuclt_particles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ void ParticleFilter::fuseRobots()
{
*iteration_oss << "fuseRobots() -> ";

// Save the latest observation time to be used when publishing
savedLatestObservationTime_ = latestObservationTime_;

// Keeps track of number of landmarks seen for each robot
std::vector<uint> landmarksSeen(nRobots_, 0);

Expand Down Expand Up @@ -325,8 +328,6 @@ void ParticleFilter::fuseTarget()
return;
}
// If program is here, at least one robot saw the ball
// Save the latest observation time to be used when publishing
savedLatestObservationTime_ = latestObservationTime_;

// Instance variables to be worked in the loops
pdata_t maxTargetSubParticleWeight, totalWeight;
Expand Down Expand Up @@ -874,15 +875,11 @@ PFPublisher::PFPublisher(struct ParticleFilter::PFinitData& data,
// Prepare particle message
resize_particles(nParticles_);

// Subscribe and advertise the republishing of GT data, time synced with the
// state publisher
// Subscribe to GT data
GT_sub_ = nh_.subscribe<read_omni_dataset::LRMGTData>(
"/gtData_4robotExp", 10,
boost::bind(&PFPublisher::gtDataCallback, this, _1));

syncedGTPublisher_ = nh_.advertise<read_omni_dataset::LRMGTData>(
"/gtData_synced_pfuclt_estimate", 1000);

// Other publishers
estimatePublisher_ =
nh_.advertise<read_omni_dataset::Estimate>("/pfuclt_estimate", 100);
Expand Down Expand Up @@ -1152,9 +1149,6 @@ void PFPublisher::publishTargetObservations()

void PFPublisher::publishGTData()
{
// Publish custom format
syncedGTPublisher_.publish(msg_GT_);

geometry_msgs::PointStamped gtPoint;
gtPoint.header.stamp = savedLatestObservationTime_;
gtPoint.header.frame_id = "world";
Expand Down Expand Up @@ -1253,7 +1247,7 @@ void ParticleFilter::State::targetVelocityEstimator_s::insertZeros()
const double lastPos = posVecs[velType].back();

// Insert the same position at a new time
timeVecs[velType].push_back(ros::Time::now().toNSec() * 1e9 - timeInit);
timeVecs[velType].push_back(ros::Time::now().toNSec() * 1e-9 - timeInit);
posVecs[velType].push_back(lastPos);
}
}
Expand Down

0 comments on commit c785d37

Please sign in to comment.