Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00039 #define EIGEN2_SUPPORT
00040
00041 #include <Eigen/SVD>
00042 #include <nav_msgs/Odometry.h>
00043 #include <realtime_tools/realtime_publisher.h>
00044 #include <tf/tfMessage.h>
00045 #include <tf/tf.h>
00046 #include <pr2_mechanism_controllers/base_kinematics.h>
00047 #include <angles/angles.h>
00048
00049 #include <boost/scoped_ptr.hpp>
00050
00051 typedef Eigen::Matrix<float, 3, 1> OdomMatrix3x1;
00052 typedef Eigen::Matrix<float, 16, 1> OdomMatrix16x1;
00053 typedef Eigen::Matrix<float, 16, 3> OdomMatrix16x3;
00054 typedef Eigen::Matrix<float, 16, 16> OdomMatrix16x16;
00055
00056 namespace controller
00057 {
00061 class RosieOdometry : public pr2_controller_interface::Controller
00062 {
00063 public:
00064
00068 RosieOdometry();
00069
00073 ~RosieOdometry();
00074
00081 bool initXml(pr2_mechanism_model::RobotState *robot_state, TiXmlElement *config);
00082
00089 bool init(pr2_mechanism_model::RobotState *robot_state, ros::NodeHandle &node);
00090
00091
00092
00093
00094
00095
00096 void starting();
00097
00102 void update();
00103
00107 void publish();
00108
00109
00110 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00111
00112 private:
00113
00114 ros::NodeHandle node_;
00115
00119 BaseKinematics base_kin_;
00120
00124 void updateOdometry();
00125
00130 void getOdometryMessage(nav_msgs::Odometry &msg);
00131
00141 void getOdometry(double &x, double &y, double &yaw, double &vx, double &vy, double &vw);
00142
00148 void getOdometry(geometry_msgs::Point &odom, geometry_msgs::Twist &odom_vel);
00149
00153 void computeBaseVelocity();
00154
00159 double getCorrectedWheelSpeed(int index);
00160
00164 Eigen::MatrixXf iterativeLeastSquares(Eigen::MatrixXf lhs, Eigen::MatrixXf rhs, std::string weight_type, int max_iter);
00165
00169 Eigen::MatrixXf findWeightMatrix(Eigen::MatrixXf residual, std::string weight_type);
00170
00174 double odometer_distance_;
00175
00179 double odometer_angle_;
00180
00184 ros::Time last_time_,current_time_;
00185
00189 Eigen::MatrixXf cbv_rhs_, fit_rhs_, fit_residual_, odometry_residual_, cbv_lhs_, fit_lhs_, cbv_soln_,fit_soln_, weight_matrix_;
00190
00194 geometry_msgs::Point odom_;
00195
00199 geometry_msgs::Twist odom_vel_;
00200
00204 std::string ils_weight_type_;
00205
00209 int ils_max_iterations_;
00210
00214 double odometry_residual_max_;
00215
00219 std::string odom_frame_;
00220
00224 std::string base_link_frame_;
00225
00226
00230 ros::Time last_publish_time_;
00231
00235 double expected_publish_time_;
00236
00240 boost::scoped_ptr<realtime_tools::RealtimePublisher <nav_msgs::Odometry> > odometry_publisher_ ;
00241
00245 boost::scoped_ptr<realtime_tools::RealtimePublisher <tf::tfMessage> > transform_publisher_ ;
00246
00247 double sigma_x_,sigma_y_,sigma_theta_,cov_x_y_,cov_x_theta_,cov_y_theta_;
00248
00249
00253 void populateCovariance(double residual, nav_msgs::Odometry &msg);
00254
00255 };
00256 }