3 #include <boost/foreach.hpp> 4 #include <boost/numeric/ublas/matrix.hpp> 14 btm.
setValue(trans(0,0),trans(0,1),trans(0,2),
15 trans(1,0),trans(1,1),trans(1,2),
16 trans(2,0),trans(2,1),trans(2,2));
26 btm.
setValue(trans(0,0),trans(0,1),trans(0,2),
27 trans(1,0),trans(1,1),trans(1,2),
28 trans(2,0),trans(2,1),trans(2,2));
36 double environment_motion_threshold) :
48 this->
_pose = Eigen::Matrix4d::Identity();
49 this->
_velocity = Eigen::Twistd(0.,0.,0.,0.,0.,0);
83 Eigen::Twistd predicted_delta_pose_vh = (this->
_velocity*time_interval_ns/1e9);
95 ROS_ERROR_STREAM_NAMED(
"StaticEnvironmentFilter.predictState",
"Wrong StaticEnvironment computation_type!");
104 static bool first_time =
true;
114 this->
_velocity = Eigen::Twistd(0,0,0,0,0,0);
132 Eigen::Matrix4d set_setnext_T;
135 Eigen::Twistd set_setnext_Twist;
157 ROS_ERROR_STREAM_NAMED(
"StaticEnvironmentFilter.correctState",
"Wrong StaticEnvironment computation_type!");
181 predicted_location_velocity = this->
_features_database->getFeatureLastLocation(supporting_feat_id);
187 predicted_location_brake = this->
_features_database->getFeatureLastLocation(supporting_feat_id);
196 pcl::PointCloud<pcl::PointXYZ> previous_locations, current_locations;
197 BOOST_FOREACH(
Feature::Id supporting_feat_id, supporting_features_ids)
203 previous_locations.push_back(pcl::PointXYZ(previous_location.get<0>(), previous_location.get<1>() ,previous_location.get<2>()));
204 current_locations.push_back(pcl::PointXYZ(current_location.get<0>(), current_location.get<1>() ,current_location.get<2>()));
208 if (previous_locations.size() ==0)
210 ROS_ERROR_STREAM_NAMED(
"StaticEnvironmentFilter.estimateDeltaMotion",
"There are no features supporting the static environment!");
213 iterativeICP(previous_locations, current_locations, previous_current_Tf);
218 pcl::PointCloud<pcl::PointXYZ>& current_locations,
tf::Transform& previous_current_Tf)
221 Eigen::Matrix4f previous_current_T;
222 previous_current_T.setIdentity();
225 std::vector<int> previous_indices, current_indices;
226 for(
int i=0; i<previous_locations.size();i++)
228 previous_indices.push_back(i);
229 current_indices.push_back(i);
232 for (
int iteration = 0; iteration < this->
_max_iterations; ++iteration)
235 Eigen::Matrix4f previous_current_T_new;
236 _svdecomposer.estimateRigidTransformation (previous_locations, previous_indices,
237 current_locations, current_indices,
238 previous_current_T_new);
241 pcl::transformPointCloud(previous_locations, previous_locations, previous_current_T_new);
244 previous_current_T = previous_current_T_new * previous_current_T;
247 double linear, angular;
249 previous_current_Tf =
Eigen2Tf(previous_current_T);
251 double trace = previous_current_Tf.
getBasis()[0][0] + previous_current_Tf.
getBasis()[1][1] + previous_current_Tf.
getBasis()[2][2];
252 angular = acos(std::min(1.0, std::max(-1.0, (trace - 1.0)/2.0)));
virtual void iterativeICP(pcl::PointCloud< pcl::PointXYZ > &previous_locations, pcl::PointCloud< pcl::PointXYZ > ¤t_locations, tf::Transform &previous_current_Tf)
Estimate the transformation between 2 sets of feature locations by iteratively estimating ICP until e...
FeatureCloudPCLwc::Ptr _predicted_measurement_pc_bh
std::map< Feature::Id, Feature::Location > _predicted_measurement_map_vh
boost::tuple< double, double, double > Location
#define ROS_ERROR_STREAM_NAMED(name, args)
FeatureCloudPCLwc::Ptr _predicted_measurement_pc_vh
virtual void estimateDeltaMotion(std::vector< Feature::Id > &supporting_features_ids, tf::Transform &previous_current_Tf)
Estimate the motion between the last 2 frames of the set of supporting features, assuming they are al...
virtual void correctState()
STATIC_ENVIRONMENT_ICP_TRACKER
void TransformMatrix2Twist(const Eigen::Matrix4d &transformation_matrix, Eigen::Twistd &twist)
virtual void predictState(double time_interval_ns)
void setValue(const tfScalar &xx, const tfScalar &xy, const tfScalar &xz, const tfScalar &yx, const tfScalar &yy, const tfScalar &yz, const tfScalar &zx, const tfScalar &zy, const tfScalar &zz)
virtual void correctState()
tf::Transform Eigen2Tf(Eigen::Matrix4f trans)
double _tf_epsilon_angular
std::map< Feature::Id, Feature::Location > _predicted_measurement_map_bh
virtual void setMotionConstraint(int motion_constraint)
Set a constraint for the motion of the RB Right now this is only used by the StaticEnvironmentFilter...
std::vector< Feature::Id > _supporting_features_ids
double _tf_epsilon_linear
virtual void addSupportingFeature(Feature::Id supporting_feat_id)
static_environment_tracker_t _computation_type
Eigen::Matrix< double, 6, 6 > _pose_covariance
FeaturesDataBase::Ptr _features_database
double _estimation_error_threshold
virtual void setComputationType(static_environment_tracker_t computation_type)
Set the computation type for the static environment Options: ICP based (t-1 to t) or EKF based (simil...
virtual void predictState(double time_interval_ns=-1.)
std::vector< Eigen::Matrix4d > _trajectory
void LocationAndId2FeaturePCLwc(const Feature::Location &feature_location, const Feature::Id &feature_id, omip::FeaturePCLwc &feature_pcl)
static_environment_tracker_t
pcl::registration::TransformationEstimationSVD< pcl::PointXYZ, pcl::PointXYZ > _svdecomposer
Eigen::Matrix4d _predicted_pose_bh
virtual void constrainMotion()
Function that constrains the last estimated pose of the static environment to the camera according to...
Eigen::Matrix4d _predicted_pose_vh
Eigen::Matrix< double, 6, 6 > _velocity_covariance
STATIC_ENVIRONMENT_EKF_TRACKER
TFSIMD_FORCE_INLINE tfScalar length() const
StaticEnvironmentFilter(double loop_period_ns, FeaturesDataBase::Ptr feats_database, double environment_motion_threshold)