11 #include <boost/random.hpp> 12 #include <boost/thread/mutex.hpp> 13 #include <eigen3/Eigen/Core> 14 #include <eigen3/Eigen/Geometry> 16 #include <pfuclt_omni_dataset/particle.h> 17 #include <pfuclt_omni_dataset/particles.h> 19 #include <dynamic_reconfigure/server.h> 20 #include <pfuclt_omni_dataset/DynamicConfig.h> 25 #define STATES_PER_TARGET 3 38 #define TARGET_RAND_MEAN 0 39 #define TARGET_RAND_STDDEV_LOST 500.0 42 #define TARGET_ITERATION_TIME_DEFAULT 0.0333 43 #define TARGET_ITERATION_TIME_MAX (1) 46 #define MIN_WEIGHTSUM 1e-10 55 const std::vector<double>&);
67 double covDD, covPP, covXX,
covYY;
76 double covDD, covPP, covXX,
covYY;
92 dynamic_reconfigure::Server<DynamicConfig>
103 std::vector<std::vector<float> >
alpha;
107 void fill_alpha(
const uint robot,
const std::string& str);
151 State(
const uint nStatesPerRobot,
const uint nRobots)
152 : nStatesPerRobot(nStatesPerRobot), nRobots(nRobots)
155 for (uint r = 0; r < nRobots; ++r)
188 PFinitData(ros::NodeHandle& nh,
const uint mainRobotID,
const uint nTargets,
189 const uint statesPerRobot,
const uint nRobots,
190 const uint nLandmarks,
const std::vector<bool>& robotsUsed,
191 const std::vector<Landmark>& landmarksMap)
192 : nh(nh), mainRobotID(mainRobotID), nTargets(nTargets),
193 statesPerRobot(statesPerRobot), nRobots(nRobots),
194 nLandmarks(nLandmarks), robotsUsed(robotsUsed),
195 landmarksMap(landmarksMap)
235 inline void copyParticle(particles_t& p_To, particles_t& p_From, uint i_To,
238 copyParticle(p_To, p_From, i_To, i_From, 0, p_To.size() - 1);
252 inline void copyParticle(particles_t& p_To, particles_t& p_From, uint i_To,
253 uint i_From, uint subFirst, uint subLast)
255 for (uint k = subFirst; k <= subLast; ++k)
256 p_To[k][i_To] = p_From[k][i_From];
264 particles_[O_WEIGHT].assign(particles_[O_WEIGHT].size(), val);
275 void spreadTargetParticlesSphere(
float particlesRatio, pdata_t center[3],
282 void predictTarget();
298 void modifiedMultinomialResampler(uint startAt);
321 size_t old_size = particles_[0].size();
324 for (uint r = 0; r < weightComponents_.size(); ++r)
325 weightComponents_[r].resize(n);
328 for (uint s = 0; s < particles_.size(); ++s)
329 particles_[s].resize(n);
346 void dynamicReconfigureCallback(pfuclt_omni_dataset::DynamicConfig&);
370 ROS_DEBUG(
"Target tracking iteration time: %f", targetIterationTime_.
diff);
383 void printWeights(std::string pre);
389 void assign(
const pdata_t value);
396 void assign(
const pdata_t value,
const uint index);
403 inline subparticles_t&
operator[](
int index) {
return particles_[index]; }
414 return particles_[index];
433 void init(
const std::vector<double>& customRandInit,
434 const std::vector<double>& customPosInit);
444 void predict(
const uint robotNumber,
const Odometry odom,
445 const ros::Time stamp);
458 std::size_t
size() {
return nSubParticleSets_; }
469 const uint landmarkNumber,
473 bufLandmarkObservations_[robotNumber][landmarkNumber] = obs;
474 latestObservationTime_ = stamp;
483 const uint landmarkNumber,
486 bufLandmarkObservations_[robotNumber][landmarkNumber].found = found;
495 void saveAllLandmarkMeasurementsDone(
const uint robotNumber);
507 bufTargetObservations_[robotNumber] = obs;
510 if (obs.
found && !state_.target.seen)
513 state_.target.seen =
true;
517 pdata_t ballGlobal[3];
522 ballGlobal[
O_TZ] = obs.
z;
526 spreadTargetParticlesSphere(0.5, ballGlobal, 1.0);
537 bufTargetObservations_[robotNumber].found = found;
546 void saveAllTargetMeasurementsDone(
const uint robotNumber);
551 #endif // PARTICLES_H
dynamic_reconfigure::Server< DynamicConfig > dynamicServer_
void resetWeights(pdata_t val)
resetWeights - assign the value val to all particle weights
const std::vector< Landmark > & landmarksMap
#define TARGET_ITERATION_TIME_DEFAULT
const uint statesPerRobot
void updateTargetIterationTime(ros::Time tRos)
updateTargetIterationTime - the main robot should call this method after the target callback ...
std::vector< pdata_t > subparticles_t
#define STATES_PER_TARGET
std::vector< TargetObservation > bufTargetObservations_
double(* estimatorFunc)(const std::vector< double > &, const std::vector< double > &)
std::size_t size()
size - interface to the size of the particle filter
struct pfuclt_omni_dataset::landmarkObs_s LandmarkObservation
uint16_t numberIterations
bool isInitialized()
isInitialized - simple interface to access private member initialized_
particles_t weightComponents_
The targetState_s struct - saves information on the belief of the target's state. ...
State(const uint nStatesPerRobot, const uint nRobots)
State - constructor.
const subparticles_t & operator[](int index) const
operator [] - const version of the array subscripting access, when using it on const intantiations of...
The robotState_s struct - saves information on the belief of a robot's state.
ros::Time savedLatestObservationTime_
const std::vector< bool > & robotsUsed
boost::random::mt19937 RNGType
const uint nStatesPerRobot_
std::vector< std::vector< float > > alpha
The state_s struct - defines a structure to hold state information for the particle filter class...
std::vector< RobotState > robots
void saveTargetObservation(const uint robotNumber, const TargetObservation obs, ros::Time stamp)
saveTargetObservation - saves the target observation to a buffer of observations
subparticles_t & operator[](int index)
operator [] - array subscripting access to the private particle set
double oldTargetRandSTddev
double resamplingPercentageToKeep
robotState_s(uint poseSize)
void copyParticle(particles_t &p_To, particles_t &p_From, uint i_To, uint i_From, uint subFirst, uint subLast)
copyParticle - copies some subparticle sets of a particle from one particle set to another ...
std::vector< std::vector< LandmarkObservation > > bufLandmarkObservations_
std::vector< pdata_t > pose
#define TARGET_ITERATION_TIME_MAX
ParticleFilter * getPFReference()
getPFReference - retrieve a reference to this object - to be overloaded by deriving classes so that t...
The PFinitData struct - provides encapsulation to the initial data necessary to construct a ParticleF...
void saveLandmarkObservation(const uint robotNumber, const uint landmarkNumber, const bool found)
saveLandmarkObservation - change the measurement buffer state
const uint nSubParticleSets_
void saveLandmarkObservation(const uint robotNumber, const uint landmarkNumber, const LandmarkObservation obs, ros::Time stamp)
saveLandmarkObservation - saves the landmark observation to a buffer of observations ...
std::vector< pdata_t > pos
const std::vector< bool > & robotsUsed_
struct pfuclt_omni_dataset::odometry_s Odometry
TimeEval targetIterationTime_
boost::shared_ptr< std::ostringstream > iteration_oss
virtual void nextIteration()
nextIteration - perform final steps before next iteration
The timeEval_s struct - takes care of time difference evaluation through the ros::Time methods...
struct pfuclt_omni_dataset::targetObs_s TargetObservation
PFinitData(ros::NodeHandle &nh, const uint mainRobotID, const uint nTargets, const uint statesPerRobot, const uint nRobots, const uint nLandmarks, const std::vector< bool > &robotsUsed, const std::vector< Landmark > &landmarksMap)
PFinitData.
ros::WallDuration durationSum
ros::WallDuration maxDeltaIteration_
std::vector< subparticles_t > particles_t
virtual void resize_particles(const uint n)
resize_particles - change to a different number of particles
void saveTargetObservation(const uint robotNumber, const bool found)
saveTargetObservation - change the measurement buffer state
double updateTime(ros::Time t)
updateTime - adds the newest time available to the struct and returns the time difference ...
ros::WallTime iterationEvalTime_
void copyParticle(particles_t &p_To, particles_t &p_From, uint i_To, uint i_From)
copyParticle - copies a whole particle from one particle set to another
const std::vector< Landmark > & landmarksMap_