42 #include <people_msgs/PositionMeasurement.h> 63 meas_cloud_.points = std::vector<geometry_msgs::Point32>(1);
100 for (std::list<Tracker*>::iterator it =
trackers_.begin(); it !=
trackers_.end(); it++)
107 ROS_DEBUG(
"Tracking node got a people position measurement (%f,%f,%f)",
108 message->pos.x, message->pos.y, message->pos.z);
112 tf::Vector3(message->pos.x, message->pos.y, message->pos.z));
113 meas_rel.
stamp_ = message->header.stamp;
114 meas_rel.
frame_id_ = message->header.frame_id;
118 BFL::SymmetricMatrix cov(3);
119 for (
unsigned int i = 0; i < 3; i++)
120 for (
unsigned int j = 0; j < 3; j++)
121 cov(i + 1, j + 1) = message->covariance[3 * i + j];
127 for (std::list<Tracker*>::iterator it =
trackers_.begin(); it !=
trackers_.end(); it++)
128 if ((*it)->getName() == message->object_id)
130 (*it)->updatePrediction(message->header.stamp.toSec());
131 (*it)->updateCorrection(meas, cov);
138 for (std::list<Tracker*>::iterator it =
trackers_.begin(); it !=
trackers_.end(); it++)
140 (*it)->getEstimate(est);
141 double dst = sqrt(pow(est.
pos_[0] - meas[0], 2) + pow(est.
pos_[1] - meas[1], 2));
142 if (dst < closest_tracker_dist)
143 closest_tracker_dist = dst;
147 std::cout <<
"Following one person" << std::endl;
148 if (message->initialization == 1 &&
154 ROS_INFO(
"Passed crazy conditional.");
162 std::cout <<
"starting new tracker" << std::endl;
163 std::stringstream tracker_name;
173 message->header.stamp.toSec());
175 ROS_INFO(
"Initialized new tracker %s", tracker_name.str().c_str());
178 ROS_INFO(
"Found a person, but he/she is not close enough to start following. " 179 "Person is %f away, and must be less than %f away.", cur_dist,
tracker_init_dist);
182 ROS_INFO(
"Failed crazy conditional.");
198 ROS_INFO(
"DROPPED PACKAGE for %s from %s with delay %f !!!!!!!!!!!",
199 message->object_id.c_str(), message->name.c_str(), (
ros::Time::now() - message->header.stamp).toSec());
205 ROS_INFO(
"People tracking manager started.");
213 std::vector<geometry_msgs::Point32> filter_visualize(
trackers_.size());
214 std::vector<float> weights(
trackers_.size());
215 sensor_msgs::ChannelFloat32 channel;
219 std::list<Tracker*>::iterator it =
trackers_.begin();
226 people_msgs::PositionMeasurement est_pos;
227 (*it)->getEstimate(est_pos);
230 ROS_DEBUG(
"Publishing people tracker filter.");
234 filter_visualize[i].x = est_pos.pos.x;
235 filter_visualize[i].y = est_pos.pos.y;
236 filter_visualize[i].z = est_pos.pos.z;
240 int quality =
static_cast<int>(trunc((*it)->getQuality() * 999.0));
241 int index = std::min(998, 999 - std::max(1, quality));
242 weights[i] = *(
float*) & (
rgb[index]);
246 ROS_INFO(
"Quality of tracker %s = %f", (*it)->getName().c_str(), (*it)->getQuality());
247 if ((*it)->getQuality() <= 0)
249 ROS_INFO(
"Removing tracker %s", (*it)->getName().c_str());
260 channel.name =
"rgb";
261 channel.values = weights;
262 sensor_msgs::PointCloud people_cloud;
263 people_cloud.channels.push_back(channel);
265 people_cloud.points = filter_visualize;
279 int main(
int argc,
char **argv)
289 my_tracking_node.
spin();
static const unsigned int num_particles_tracker
static void pointMsgToTF(const geometry_msgs::Point &msg_v, Point &bt_v)
void publish(const boost::shared_ptr< M > &message) const
void setData(const T &input)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
boost::mutex filter_mutex_
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void callbackDrop(const people_msgs::PositionMeasurement::ConstPtr &message)
callback for dropped messages
sensor_msgs::PointCloud meas_cloud_
Class representing state with pos and vel.
tf::TransformListener robot_state_
ros::Publisher people_tracker_vis_pub_
void callbackRcv(const people_msgs::PositionMeasurement::ConstPtr &message)
callback for messages
static const unsigned int sequencer_subscribe_buffer
ros::Publisher people_filter_pub_
std::list< Tracker * > trackers_
trackers
unsigned int tracker_counter_
static const double sequencer_delay
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
double reliability_threshold_
virtual void initialize(const BFL::StatePosVel &mu, const BFL::StatePosVel &sigma, const double time)=0
initialize tracker
virtual ~PeopleTrackingNode()
destructor
static const unsigned int sequencer_internal_buffer
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
double start_distance_min_
message_filters::TimeSequencer< people_msgs::PositionMeasurement > * message_sequencer_
message sequencer
BFL::StatePosVel sys_sigma_
ros::Subscriber people_meas_sub_
static const double tracker_init_dist
PeopleTrackingNode(ros::NodeHandle nh)
constructor
ros::Publisher people_filter_vis_pub_
ROSCPP_DECL void spinOnce()
int main(int argc, char **argv)