13 #include "boost/thread.hpp" 21 :
loop_rate_(20), world_model_(0), tf_listener_(tf_listener), is_tf_owner_(false), last_update_duration(0),
22 max_update_duration(0), world_model_frame_id_(
"/map"), output_frame_id_(
"/map"), max_num_hyps_(100), min_prob_ratio_(1e-10),
53 string object_models_filename =
"";
54 n.
getParam(
"knowledge_filename", object_models_filename);
56 if (object_models_filename ==
"") {
57 ROS_ERROR(
"Parameter 'knowledge_filename' not set.");
117 msg.ID = obj.
getID();
119 const map<Attribute, Property*>& properties = obj.
getPropertyMap();
124 wire_msgs::Property prop_msg;
127 msg.properties.push_back(prop_msg);
137 msg.header.stamp = time;
144 wire_msgs::ObjectState obj_msg;
146 msg.objects.push_back(obj_msg);
160 ROS_ERROR(
"Position evidence is not a gaussian!");
171 pbl::Vector3 pos_world(pos_stamped_world.getX(), pos_stamped_world.getY(), pos_stamped_world.getZ());
188 ROS_ERROR(
"Orientation evidence is not a gaussian!");
199 pbl::Vector4 ori_world(ori_stamped_world.getX(), ori_stamped_world.getY(), ori_stamped_world.getZ(), ori_stamped_world.getW());
237 ROS_WARN(
"Saw a negative time change of %f seconds; resetting the world model.", (current_time -
last_update_).toSec());
247 std::list<Evidence*> measurements_mem;
249 const vector<wire_msgs::ObjectEvidence>& object_evidence = world_evidence_msg.object_evidence;
251 const wire_msgs::ObjectEvidence& evidence = (*it_ev);
256 measurements_mem.push_back(meas);
258 bool position_ok =
true;
261 const wire_msgs::Property& prop = *it_prop;
266 if (prop.attribute ==
"position") {
275 }
else if (prop.attribute ==
"orientation") {
285 ROS_ERROR_STREAM(
"For attribute '" << prop.attribute <<
"': malformed pdf: " << prop.pdf);
290 evidence_set.
add(meas);
292 ROS_ERROR(
"Unable to transform position.");
311 wire_msgs::WorldState map_world_msg;
SemanticObject * clone() const
std::string getErrorMessage() const
PDF * msgToPDF(const problib::PDF &msg)
void add(Evidence *ev)
Adds evidence to the evidence set.
static Attribute attribute(const std::string &attribute_str)
attribute
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
const std::map< Attribute, Property * > & getPropertyMap() const
void registerEvidenceTopic(const std::string &topic_name)
void addProperty(const Attribute &attribute, const pbl::PDF &value)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
bool objectToMsg(const SemanticObject &obj, wire_msgs::ObjectState &msg) const
double max_update_duration
static KnowledgeDatabase & getInstance()
mhf::HypothesisTree * world_model_
static std::string attribute_str(const Attribute &attribute)
attribute_str
iterator(field< oT > &in_M, const bool at_end=false)
void processEvidence(const ros::Duration max_duration)
std::list< ros::Subscriber > subs_evidence_
bool resetWorldModel(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res)
const arma::mat & getCovariance() const
void showStatistics() const
The class Evidence represents a set of properties (PropertySet) that all originate from one physical ...
void addEvidence(const EvidenceSet &ev_set)
const Hypothesis & getMAPHypothesis() const
A set of Evidence items which all originate from the same point int time.
void setMean(const arma::vec &mu)
Duration expectedCycleTime() const
const_iterator(const field< oT > &in_M, const bool at_end=false)
const arma::vec & getMean() const
std::string output_frame_id_
bool transformOrientation(const pbl::PDF &pdf_in, const std::string &frame_in, pbl::Gaussian &pdf_out) const
const std::list< SemanticObject * > & getMAPObjects() const
std::list< wire_msgs::WorldEvidence > evidence_buffer_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
arma_warn_unused eT max() const
bool hypothesisToMsg(const mhf::Hypothesis &hyp, wire_msgs::WorldState &msg) const
#define ROS_WARN_STREAM(args)
bool parse(KnowledgeDatabase &obj_models)
ros::ServiceServer srv_reset_
const pbl::PDF & getValue() const
bool getParam(const std::string &key, std::string &s) const
boost::thread processing_thread_
void propagate(const Time &time)
Propagates the internal state to Time time.
void evidenceCallback(const wire_msgs::WorldEvidence::ConstPtr &world_evidence_msg)
const std::list< SemanticObject * > & getMAPObjects() const
#define ROS_ERROR_STREAM(args)
const std::list< SemanticObject * > & getObjects() const
tf::TransformListener * tf_listener_
double last_update_duration
ROSCPP_DECL void spinOnce()
std::string world_model_frame_id_
void setCovariance(const arma::mat &cov)
const Gaussian * PDFtoGaussian(const PDF &pdf)
void PDFtoMsg(const PDF &pdf, problib::PDF &msg)
std::stringstream warnings_
bool transformPosition(const pbl::PDF &pdf_in, const std::string &frame_in, pbl::Gaussian &pdf_out) const