Go to the documentation of this file.00001
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #include <pr2_controller_interface/controller.h>
00049 #include <pr2_mechanism_model/joint.h>
00050 #include <ros/ros.h>
00051 #include <control_toolbox/pid.h>
00052 #include <geometry_msgs/Twist.h>
00053 #include <nav_msgs/Odometry.h>
00054 #include <boost/scoped_ptr.hpp>
00055 #include <boost/thread/condition.hpp>
00056 #include <realtime_tools/realtime_publisher.h>
00057 #include <tf/transform_broadcaster.h>
00058 #include <pr2_mechanism_controllers/Odometer.h>
00059 #include <pr2_mechanism_controllers/BaseOdometryState.h>
00060
00061 namespace controller
00062 {
00063
00064
00065 class BaseOdometry : public pr2_controller_interface::Controller
00066 {
00067 private:
00072 void updateOdometry();
00073
00078 void computeBaseVelocity();
00079
00084 void publish();
00085
00090 void getOdometryMessage(nav_msgs::Odometry &msg);
00091
00096 void populateCovariance(nav_msgs::Odometry &msg);
00097
00101 void publishTransform();
00102
00103 ros::NodeHandle n;
00104
00105 pr2_mechanism_model::RobotState *robot_;
00106
00108 boost::scoped_ptr<realtime_tools::RealtimePublisher <nav_msgs::Odometry> > odometry_publisher_ ;
00109
00110 boost::scoped_ptr<realtime_tools::RealtimePublisher <tf::tfMessage> > transform_publisher_ ;
00112
00113 double odometry_publish_rate_;
00115 bool publish_odometry_, publish_tf_ ;
00117
00118 geometry_msgs::Point odometry_;
00119 geometry_msgs::Twist odometry_vel_;
00120
00121 std::string odometry_frame_;
00122 std::string base_link_frame_;
00123 std::string base_footprint_frame_;
00124 std::string tf_prefix_;
00125
00127
00128 double sigma_x_,sigma_y_,sigma_theta_,cov_x_y_,cov_x_theta_,cov_y_theta_;
00130
00132 ros::Time last_time_;
00133 ros::Time current_time_;
00134
00135 ros::Time last_odometry_publish_time_, last_transform_publish_time_;
00136
00137 double expected_publish_time_;
00138 double update_time;
00140
00142 pr2_mechanism_model::JointState* wheel_inner_left_front_state;
00143 pr2_mechanism_model::JointState* wheel_inner_left_rear_state;
00144 pr2_mechanism_model::JointState* wheel_inner_right_front_state;
00145 pr2_mechanism_model::JointState* wheel_inner_right_rear_state;
00146 double current_vel_wheel_inner_left_front, current_vel_wheel_inner_right_front, current_vel_wheel_inner_left_rear, current_vel_wheel_inner_right_rear;
00148
00150 double current_vel_x, current_vel_y, current_vel_phi;
00152
00153 public:
00154
00158 bool init(pr2_mechanism_model::RobotState *robot, ros::NodeHandle &n);
00159
00163 void starting();
00164
00170 void update();
00171
00175 void stopping();
00176
00177 };
00178 }
00179