3 #include "geometry_msgs/PoseArray.h" 4 #include <geometry_msgs/PoseWithCovarianceStamped.h> 8 #include <sensor_msgs/Range.h> 17 #if ROS_VERSION_MINIMUM(1, 11, 1) // if current ros version is >= 1.11.1 (indigo) 22 #define LINES_OF_TERMINAL_RBT 20 26 #define MAX_DELAY_BETWEEN_FT_AND_ST 0.02 31 _ransac_iterations(-1),
32 _estimation_error_threshold(-1.),
33 _static_motion_threshold(-1.),
34 _new_rbm_error_threshold(-1.),
35 _max_error_to_reassign_feats(-1.),
37 _processing_factor(0),
38 _supporting_features_threshold(-1),
39 _min_num_feats_for_new_rb(-1),
40 _min_num_frames_for_new_rb(-1),
41 _publishing_rbposes_with_cov(false),
42 _publishing_clustered_pc(true),
44 _printing_rb_poses(true),
45 _shape_tracker_received(false)
83 this->getROSParameter<int>(this->_namespace + std::string(
"/max_num_rb"), max_num_rb, max_num_rb);
86 int initial_cam_motion_constraint = 6;
87 this->getROSParameter<int>(this->_namespace + std::string(
"/cam_motion_constraint"), initial_cam_motion_constraint, initial_cam_motion_constraint);
90 int static_environment_tracker_type_int;
91 this->getROSParameter<int>(this->_namespace + std::string(
"/static_environment_type"), static_environment_tracker_type_int);
94 double meas_depth_factor;
95 this->getROSParameter<double>(this->_namespace + std::string(
"/cov_meas_depth_factor"), meas_depth_factor);
96 double min_cov_meas_x;
97 this->getROSParameter<double>(this->_namespace + std::string(
"/min_cov_meas_x"), min_cov_meas_x);
98 double min_cov_meas_y;
99 this->getROSParameter<double>(this->_namespace + std::string(
"/min_cov_meas_y"), min_cov_meas_y);
100 double min_cov_meas_z;
101 this->getROSParameter<double>(this->_namespace + std::string(
"/min_cov_meas_z"), min_cov_meas_z);
102 double prior_cov_pose;
103 this->getROSParameter<double>(this->_namespace + std::string(
"/prior_cov_pose"), prior_cov_pose);
104 double prior_cov_vel;
105 this->getROSParameter<double>(this->_namespace + std::string(
"/prior_cov_vel"), prior_cov_vel);
106 double cov_sys_acc_tx;
107 this->getROSParameter<double>(this->_namespace + std::string(
"/cov_sys_acc_tx"), cov_sys_acc_tx);
108 double cov_sys_acc_ty;
109 this->getROSParameter<double>(this->_namespace + std::string(
"/cov_sys_acc_ty"), cov_sys_acc_ty);
110 double cov_sys_acc_tz;
111 this->getROSParameter<double>(this->_namespace + std::string(
"/cov_sys_acc_tz"), cov_sys_acc_tz);
112 double cov_sys_acc_rx;
113 this->getROSParameter<double>(this->_namespace + std::string(
"/cov_sys_acc_rx"), cov_sys_acc_rx);
114 double cov_sys_acc_ry;
115 this->getROSParameter<double>(this->_namespace + std::string(
"/cov_sys_acc_ry"), cov_sys_acc_ry);
116 double cov_sys_acc_rz;
117 this->getROSParameter<double>(this->_namespace + std::string(
"/cov_sys_acc_rz"), cov_sys_acc_rz);
119 int min_num_points_in_segment;
120 this->getROSParameter<int>(this->_namespace + std::string(
"/min_num_points_in_segment"), min_num_points_in_segment);
121 double min_probabilistic_value;
122 this->getROSParameter<double>(this->_namespace + std::string(
"/min_probabilistic_value"), min_probabilistic_value);
123 double max_fitness_score;
124 this->getROSParameter<double>(this->_namespace + std::string(
"/max_fitness_score"), max_fitness_score);
126 double min_amount_translation_for_new_rb;
127 this->getROSParameter<double>(this->_namespace + std::string(
"/min_amount_translation_for_new_rb"), min_amount_translation_for_new_rb);
128 double min_amount_rotation_for_new_rb;
129 this->getROSParameter<double>(this->_namespace + std::string(
"/min_amount_rotation_for_new_rb"), min_amount_rotation_for_new_rb);
131 int min_num_supporting_feats_to_correct;
132 this->getROSParameter<int>(this->_namespace + std::string(
"/min_num_supporting_feats_to_correct"), min_num_supporting_feats_to_correct);
135 "MultiRBTrackerNode Parameters: " <<
136 "\n\tmax_num_rb: " << max_num_rb <<
137 "\n\tmeas_depth_factor: " << meas_depth_factor <<
138 "\n\tmin_cov_meas_x: " << min_cov_meas_x <<
139 "\n\tmin_cov_meas_y: " << min_cov_meas_y <<
140 "\n\tmin_cov_meas_z: " << min_cov_meas_z <<
141 "\n\tprior_cov_pose: " << prior_cov_pose <<
142 "\n\tprior_cov_vel: " << prior_cov_vel <<
143 "\n\tcov_sys_acc_tx: " << cov_sys_acc_tx <<
144 "\n\tcov_sys_acc_ty: " << cov_sys_acc_ty <<
145 "\n\tcov_sys_acc_tz: " << cov_sys_acc_tz <<
146 "\n\tcov_sys_acc_rx: " << cov_sys_acc_rx <<
147 "\n\tcov_sys_acc_ry: " << cov_sys_acc_ry <<
148 "\n\tcov_sys_acc_rz: " << cov_sys_acc_rz <<
149 "\n\tmin_num_points_in_segment: " << min_num_points_in_segment <<
150 "\n\tmin_probabilistic_value: " << min_probabilistic_value <<
151 "\n\tmax_fitness_score: " << max_fitness_score <<
152 "\n\tmin_amount_translation_for_new_rb: " << min_amount_translation_for_new_rb <<
153 "\n\tmin_amount_rotation_for_new_rb: " << min_amount_rotation_for_new_rb <<
154 "\n\tmin_num_supporting_feats_to_correct: " << min_num_supporting_feats_to_correct <<
155 "\n\tcam_motion_constraint: " << initial_cam_motion_constraint);
167 initial_cam_motion_constraint,
168 this->_static_environment_tracker_type
171 this->
_re_filter->setMeasurementDepthFactor(meas_depth_factor);
172 this->
_re_filter->setMinCovarianceMeasurementX(min_cov_meas_x);
173 this->
_re_filter->setMinCovarianceMeasurementY(min_cov_meas_y);
174 this->
_re_filter->setMinCovarianceMeasurementZ(min_cov_meas_z);
175 this->
_re_filter->setPriorCovariancePose(prior_cov_pose);
176 this->
_re_filter->setPriorCovarianceVelocity(prior_cov_vel);
177 this->
_re_filter->setCovarianceSystemAccelerationTx(cov_sys_acc_tx);
178 this->
_re_filter->setCovarianceSystemAccelerationTy(cov_sys_acc_ty);
179 this->
_re_filter->setCovarianceSystemAccelerationTz(cov_sys_acc_tz);
180 this->
_re_filter->setCovarianceSystemAccelerationRx(cov_sys_acc_rx);
181 this->
_re_filter->setCovarianceSystemAccelerationRy(cov_sys_acc_ry);
182 this->
_re_filter->setCovarianceSystemAccelerationRz(cov_sys_acc_rz);
184 this->
_re_filter->setMinNumPointsInSegment(min_num_points_in_segment);
185 this->
_re_filter->setMinProbabilisticValue(min_probabilistic_value);
186 this->
_re_filter->setMaxFitnessScore(max_fitness_score);
187 this->
_re_filter->setMinAmountTranslationForNewRB(min_amount_translation_for_new_rb);
188 this->
_re_filter->setMinAmountRotationForNewRB(min_amount_rotation_for_new_rb);
189 this->
_re_filter->setMinNumberOfSupportingFeaturesToCorrectPredictedState(min_num_supporting_feats_to_correct);
207 this->
_re_filter->setDynamicReconfigureValues(config);
227 this->getROSParameter<double>(std::string(
"/omip/sensor_fps"), this->
_sensor_fps);
228 this->getROSParameter<int>(std::string(
"/omip/processing_factor"), this->
_processing_factor);
231 this->getROSParameter<int>(std::string(
"/feature_tracker/number_features"), this->
_num_tracked_feats);
235 "MultiRBTrackerNode Parameters: " << std::endl
284 double period_between_frames = 1.0/this->
_sensor_fps;
287 int frames_between_meas = round((time_between_meas.
toSec())/period_between_frames);
290 if( this->_previous_measurement_time.toSec() == 0.)
292 ROS_ERROR(
"First iteration. We predict after correct");
304 ROS_ERROR_STREAM_NAMED(
"MultiRBTrackerNode.measurementCallback",
"The prediction from higher level can be used to predict next measurement before correction");
308 "The prediction from higher level can NOT be used to predict next measurement before correction. Delay: " 315 ROS_INFO(
"Frames between measurements:%3d.", frames_between_meas);
320 if(this->_previous_measurement_time.toSec() != 0.)
338 loop_duration.
sleep();
346 ROS_ERROR_STREAM_NAMED(
"MultiRBTrackerNode.measurementCallback",
"The prediction from higher level can be used to predict next measurement after correction");
350 "The prediction from higher level can NOT be used to predict next measurment after correction. Delay: " 363 ROS_WARN_STREAM(
"Total meas processing time vision: " << (tend-tinit).toSec()*1000 <<
" ms");
376 poses_and_vels_msg.header.frame_id =
"camera_rgb_optical_frame";
382 poses_and_vels_msg_corrected.header.frame_id =
"camera_rgb_optical_frame";
391 FeatureCloudPCLwc::Ptr predicted_locations = this->
_re_filter->getPredictedMeasurement();
392 predicted_locations->header.frame_id =
"camera_rgb_optical_frame";
394 sensor_msgs::PointCloud2 predicted_locations_ros;
395 pcl::toROSMsg(*predicted_locations, predicted_locations_ros);
405 std::vector<Eigen::Matrix4d> tracked_bodies_motion = this->
_re_filter->getPoses();
407 Eigen::Twistd pose_in_ec;
410 int num_supporting_feats = 0;
411 for (
size_t poses_idx = 0; poses_idx < tracked_bodies_motion.size(); poses_idx++)
414 num_supporting_feats = this->
_re_filter->getNumberSupportingFeatures(poses_idx);
417 ROS_INFO_NAMED(
"MultiRBTrackerNode::_PublishRBPoses",
"RB%2d: Supporting feats: %d, Pose (vx,vy,vz,rx,ry,rz): % 2.2f,% 2.2f,% 2.2f,% 2.2f,% 2.2f,% 2.2f",
419 num_supporting_feats,
435 std::vector<geometry_msgs::PoseWithCovariancePtr> tracked_poses_with_cov = this->
_re_filter->getPosesWithCovariance();
438 for (
size_t poses_idx = 0; poses_idx < tracked_poses_with_cov.size(); poses_idx++)
441 std::ostringstream oss;
442 oss <<
"ip/rb" << RB_id;
451 geometry_msgs::PoseWithCovarianceStamped pose_with_cov_stamped;
453 pose_with_cov_stamped.header.frame_id =
"camera_rgb_optical_frame";
454 pose_with_cov_stamped.pose = *(tracked_poses_with_cov[poses_idx]);
467 std::vector<geometry_msgs::PoseWithCovariancePtr> tracked_poses_with_cov = this->
_re_filter->getPosesWithCovariance();
469 for (
size_t poses_idx = 0; poses_idx < tracked_poses_with_cov.size(); poses_idx++)
472 std::ostringstream oss;
473 oss <<
"ip/rb" << RB_id;
477 transform_auxiliar.
setOrigin(
tf::Vector3(tracked_poses_with_cov[poses_idx]->pose.position.x, tracked_poses_with_cov[poses_idx]->pose.position.y,
478 tracked_poses_with_cov[poses_idx]->pose.position.z));
479 transform_auxiliar.
setRotation(
tf::Quaternion(tracked_poses_with_cov.at(poses_idx)->pose.orientation.x,tracked_poses_with_cov.at(poses_idx)->pose.orientation.y,
480 tracked_poses_with_cov.at(poses_idx)->pose.orientation.z, tracked_poses_with_cov.at(poses_idx)->pose.orientation.w));
483 RB_id == 0 ?
"static_environment" : oss.str().c_str()));
493 clustered_pc.header.frame_id =
"camera_rgb_optical_frame";
496 sensor_msgs::PointCloud2 feature_set_ros;
502 freefeats_pc.header.frame_id =
"camera_rgb_optical_frame";
505 sensor_msgs::PointCloud2 freefeats_pc_ros;
510 predictedfeats_pc.header.frame_id =
"camera_rgb_optical_frame";
513 sensor_msgs::PointCloud2 predictedfeats_pc_ros;
518 atbirthfeats_pc.header.frame_id =
"camera_rgb_optical_frame";
521 sensor_msgs::PointCloud2 atbirthfeats_pc_ros;
527 int main(
int argc,
char** argv)
int _supporting_features_threshold
virtual void _PublishPosesWithCovariance()
ros::Time _previous_measurement_time
ros::Time _current_measurement_time
#define ROS_INFO_NAMED(name,...)
ros::NodeHandle _measurements_node_handle
void publish(const boost::shared_ptr< M > &message) const
#define ROS_ERROR_STREAM_NAMED(name, args)
ros::Publisher _clustered_pc_publisher
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
virtual void _PublishClusteredFeatures()
Publish the tracked features clustered in RBs (the cluster id is written in the "label" field of the ...
void MeasurementFromShapeTrackerCallback(const boost::shared_ptr< omip_msgs::ShapeTrackerStates const > &shape_tracker_states)
ros::Publisher _atbirthfeats_pc_publisher
ros::Publisher _predictedfeats_pc_publisher
ros::Subscriber _meas_from_st_subscriber
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void TransformMatrix2Twist(const Eigen::Matrix4d &transformation_matrix, Eigen::Twistd &twist)
virtual void _publishState() const
Publish the current state of this RE level.
void fromROSMsg(const sensor_msgs::PointCloud2 &cloud, pcl::PointCloud< T > &pcl_cloud)
omip_msgs::RigidBodyPosesAndVelsMsg rbt_state_t
#define ROS_INFO_STREAM_NAMED(name, args)
std::map< RB_id_t, ros::Publisher * > _est_body_publishers
ros::Publisher _state_publisher2
virtual ~MultiRBTrackerNode()
ros::Publisher _state_publisher
sensor_msgs::PointCloud2 ft_state_ros_t
virtual void _PrintResults() const
Print the results of the RB tracker on the terminal.
rbt_state_t _last_predictions_kh
dynamic_reconfigure::Server< rb_tracker::RBTrackerDynReconfConfig > _dr_srv
int main(int argc, char **argv)
dynamic_reconfigure::Server< rb_tracker::RBTrackerDynReconfConfig >::CallbackType _dr_callback
static_environment_tracker_t _static_environment_tracker_type
RecursiveEstimatorFilterClass * _re_filter
double _max_error_to_reassign_feats
virtual void measurementCallback(const boost::shared_ptr< rbt_measurement_ros_t const > &features_pc)
Callback for the measurements for this RE level (3D features from the lower level, FT)
ros::Publisher _freefeats_pc_publisher
virtual void _PublishTF()
double _static_motion_threshold
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ros::Publisher _measurement_prediction_publisher
#define ROS_WARN_STREAM(args)
int _min_num_feats_for_new_rb
ros::Subscriber _state_prediction_subscriber
bool _publishing_clustered_pc
std::vector< ros::NodeHandle > _state_prediction_node_handles
bool _publishing_rbposes_with_cov
pcl::PointCloud< FeaturePCL > FeatureCloudPCL
virtual void statePredictionCallback(const boost::shared_ptr< rbt_state_t const > &predicted_next_state)
Callback for the predictions about the state of this RE level coming from the higher level of the hie...
bool _shape_tracker_received
double _new_rbm_error_threshold
ros::Subscriber _measurement_subscriber
omip_msgs::ShapeTrackerStates _shape_tracker_meas
void toROSMsg(const sensor_msgs::PointCloud2 &cloud, sensor_msgs::Image &image)
pcl::PointCloud< FeaturePCLwc > FeatureCloudPCLwc
static_environment_tracker_t
int _min_num_frames_for_new_rb
FeatureCloudPCLwc::Ptr rbt_measurement_t
double _estimation_error_threshold
void toPCL(const ros::Time &stamp, pcl::uint64_t &pcl_stamp)
virtual void _publishPredictedMeasurement() const
Publish the prediction about the next measurement by this RE level.
void DynamicReconfigureCallback(rb_tracker::RBTrackerDynReconfConfig &config, uint32_t level)
Callback for the Dynamic Reconfigure parameters.