1 #include <read_omni_dataset/read_omni_dataset.h> 9 particleStdPublishers_(data.nRobots),
10 robotGTPublishers_(data.nRobots), robotEstimatePublishers_(data.nRobots),
11 robotBroadcasters(data.nRobots){
16 GT_sub_ =
nh_.subscribe<read_omni_dataset::LRMGTData>(
17 "/gtData_4robotExp", 10,
22 nh_.advertise<read_omni_dataset::Estimate>(
"/pfuclt_estimate", 100);
24 nh_.advertise<pfuclt_omni_dataset::particles>(
"/pfuclt_particles", 10);
29 nh_.advertise<geometry_msgs::PointStamped>(
"/target/estimatedPose", 1000);
31 nh_.advertise<geometry_msgs::PointStamped>(
"/target/gtPose", 1000);
33 nh_.advertise<sensor_msgs::PointCloud>(
"/target/particles", 10);
37 nh_.advertise<visualization_msgs::Marker>(
"/targetObservations", 100);
40 for (uint r = 0; r <
nRobots_; ++r) {
41 std::ostringstream robotName;
42 robotName <<
"omni" << r + 1;
46 "/" + robotName.str() +
"/particles", 1000);
50 "/" + robotName.str() +
"/estimatedPose", 1000);
53 msg_estimate_.robotEstimates.push_back(geometry_msgs::Pose());
57 #ifndef USE_NEWER_READ_OMNI_PACKAGE 59 "/" + robotName.str() +
"/gtPose", 1000);
62 "/" + robotName.str() +
"/gtPose", 1000);
66 ROS_INFO(
"It's a publishing particle filter!");
82 for (uint r = 0; r <
nRobots_; ++r) {
87 geometry_msgs::PoseArray msgStd_particles;
89 msgStd_particles.header.frame_id =
"world";
92 tf2::Quaternion tf2q(tf2::Vector3(0, 0, 1),
94 tf2::Transform tf2t(tf2q, tf2::Vector3(
particles_[o_robot +
O_X][p],
98 geometry_msgs::Pose pose;
99 tf2::toMsg(tf2t, pose);
100 msgStd_particles.poses.insert(msgStd_particles.poses.begin(), pose);
107 sensor_msgs::PointCloud target_particles;
108 target_particles.header.stamp = ros::Time::now();
109 target_particles.header.frame_id =
"world";
112 geometry_msgs::Point32 point;
117 target_particles.points.insert(target_particles.points.begin(), point);
124 for (uint r = 0; r <
nRobots_; ++r) {
128 std::ostringstream robotName;
129 robotName <<
"omni" << r + 1;
134 geometry_msgs::Pose &rosState =
msg_estimate_.robotEstimates[r];
137 tf2::Quaternion tf2q(tf2::Vector3(0, 0, 1), pfState.
pose[
O_THETA]);
138 tf2::Transform tf2t(tf2q, tf2::Vector3(pfState.
pose[
O_X], pfState.
pose[
O_Y],
142 tf2::toMsg(tf2t, rosState);
145 geometry_msgs::TransformStamped estTransf;
147 estTransf.header.frame_id =
"world";
148 estTransf.child_frame_id = robotName.str() +
"est";
149 estTransf.transform = tf2::toMsg(tf2t);
153 geometry_msgs::PoseStamped estPose;
154 estPose.header.stamp = estTransf.header.stamp;
155 estPose.header.frame_id = estTransf.child_frame_id;
171 for (uint r = 0; r <
nRobots_; ++r) {
176 geometry_msgs::PointStamped estPoint;
177 estPoint.header.stamp = ros::Time::now();
178 estPoint.header.frame_id =
"world";
196 static std::vector<bool> previouslyPublished(
nRobots_,
false);
198 for (uint r = 0; r <
nRobots_; ++r) {
200 visualization_msgs::Marker marker;
206 std::ostringstream robotName;
207 robotName <<
"omni" << r + 1;
212 if (obs.
found ==
false) {
213 if (previouslyPublished[r])
216 previouslyPublished[r] =
true;
218 previouslyPublished[r] =
false;
220 marker.header.frame_id = robotName.str() +
"est";
224 marker.ns = robotName.str() +
"_target_observations";
227 marker.type = visualization_msgs::Marker::ARROW;
228 marker.action = visualization_msgs::Marker::ADD;
231 geometry_msgs::Point tail;
232 tail.x = tail.y = tail.z = 0.0;
234 marker.points.push_back(tail);
236 geometry_msgs::Point head;
240 marker.points.push_back(head);
242 marker.scale.x = 0.01;
243 marker.scale.y = 0.03;
244 marker.scale.z = 0.05;
249 marker.color.r = marker.color.g = marker.color.b = 0.6;
251 marker.color.r = 1.0;
252 marker.color.g = marker.color.b = 0.0;
256 marker.lifetime = ros::Duration(2);
264 geometry_msgs::PointStamped gtPoint;
266 gtPoint.header.frame_id =
"world";
268 #ifdef USE_NEWER_READ_OMNI_PACKAGE 269 geometry_msgs::PoseStamped gtPose;
271 gtPose.header.frame_id =
"world";
273 for (uint r = 0; r <
nRobots_; ++r) {
274 gtPose.pose =
msg_GT_.poseOMNI[r].pose;
281 gtPoint.point =
msg_GT_.poseOMNI1.pose.position;
287 gtPoint.point =
msg_GT_.poseOMNI3.pose.position;
293 gtPoint.point =
msg_GT_.poseOMNI4.pose.position;
299 gtPoint.point =
msg_GT_.poseOMNI5.pose.position;
305 if (
msg_GT_.orangeBall3DGTposition.found) {
306 gtPoint.point.x =
msg_GT_.orangeBall3DGTposition.x;
307 gtPoint.point.y =
msg_GT_.orangeBall3DGTposition.y;
308 gtPoint.point.z =
msg_GT_.orangeBall3DGTposition.z;
314 const read_omni_dataset::LRMGTData::ConstPtr >MsgReceived) {
338 #ifdef USE_NEWER_READ_OMNI_PACKAGE ros::Publisher particlePublisher_
std::vector< ros::Publisher > robotEstimatePublishers_
read_omni_dataset::LRMGTData msg_GT_
ros::Publisher targetObservationsPublisher_
ros::Publisher targetEstimatePublisher_
struct pfuclt_omni_dataset::PFPublisher::PublishData pubData
std::vector< TargetObservation > bufTargetObservations_
struct pfuclt_omni_dataset::ParticleFilter::State::targetState_s target
void publishTargetState()
ros::Publisher estimatePublisher_
The robotState_s struct - saves information on the belief of a robot's state.
ros::Time savedLatestObservationTime_
const uint nStatesPerRobot_
ros::Publisher targetGTPublisher_
std::vector< RobotState > robots
std::vector< ros::Publisher > particleStdPublishers_
void gtDataCallback(const read_omni_dataset::LRMGTData::ConstPtr &)
gtDataCallback - callback of ground truth data
read_omni_dataset::Estimate msg_estimate_
void publishRobotStates()
std::vector< tf2_ros::TransformBroadcaster > robotBroadcasters
void nextIteration()
nextIteration - extends the base class method to add the ROS publishing
std::vector< ros::Publisher > robotGTPublishers_
std::vector< pdata_t > pose
ros::Publisher targetParticlePublisher_
The PFinitData struct - provides encapsulation to the initial data necessary to construct a ParticleF...
const uint nSubParticleSets_
ros::WallDuration deltaIteration_
std::vector< pdata_t > pos
const std::vector< bool > & robotsUsed_
pfuclt_omni_dataset::particles msg_particles_
virtual void nextIteration()
nextIteration - perform final steps before next iteration
void publishTargetObservations()
PFPublisher(struct PFinitData &data, struct PublishData publishData)
PFPublisher - constructor.
void resize_particles(const uint n)
resize_particles - change to a different number of particles and resize the publishing message ...