00001 // Copyright (C) 2010-2011 Institut de Robotica i Informatica Industrial, CSIC-UPC. 00002 // Author 00003 // All rights reserved. 00004 // 00005 // This file is part of iri-ros-pkg 00006 // iri-ros-pkg is free software: you can redistribute it and/or modify 00007 // it under the terms of the GNU Lesser General Public License as published by 00008 // the Free Software Foundation, either version 3 of the License, or 00009 // at your option) any later version. 00010 // 00011 // This program is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU Lesser General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public License 00017 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 // 00019 // IMPORTANT NOTE: This code has been generated through a script from the 00020 // iri_ros_scripts. Please do NOT delete any comments to guarantee the correctness 00021 // of the scripts. ROS topics can be easly add by using those scripts. Please 00022 // refer to the IRI wiki page for more information: 00023 // http://wikiri.upc.es/index.php/Robotics_Lab 00024 00025 #ifndef _segway_rmp400_odom_alg_node_h_ 00026 #define _segway_rmp400_odom_alg_node_h_ 00027 00028 #include <iri_base_algorithm/iri_base_algorithm.h> 00029 #include "segway_rmp400_odom_alg.h" 00030 00031 #include <geometry_msgs/PoseWithCovariance.h> 00032 #include <geometry_msgs/TwistWithCovariance.h> 00033 #include <geometry_msgs/Transform.h> 00034 00035 #include <tf/transform_broadcaster.h> 00036 00037 #include <Eigen/Core> 00038 #include <Eigen/Geometry> 00039 00040 #ifndef PI 00041 #define PI 3.141592 00042 #endif 00043 00044 // [publisher subscriber headers] 00045 #include <nav_msgs/Odometry.h> 00046 #include <iri_segway_rmp_msgs/SegwayRMP400Status.h> 00047 #include <sensor_msgs/Imu.h> 00048 00049 // [service client headers] 00050 00051 // [action server client headers] 00052 00057 class SegwayRmp400OdomAlgNode : public algorithm_base::IriBaseAlgorithm<SegwayRmp400OdomAlgorithm> 00058 { 00059 private: 00060 // [publisher attributes] 00061 ros::Publisher odom_publisher_; 00062 nav_msgs::Odometry Odometry_msg_; 00063 00064 // [subscriber attributes] 00065 ros::Subscriber segway_status_subscriber_; 00066 void segway_status_callback(const iri_segway_rmp_msgs::SegwayRMP400Status::ConstPtr& msg); 00067 CMutex segway_status_mutex_; 00068 00069 ros::Subscriber imu_subscriber_; 00070 void imu_callback(const sensor_msgs::Imu::ConstPtr& msg); 00071 CMutex imu_mutex_; 00072 00073 // [service attributes] 00074 00075 // [client attributes] 00076 00077 // [action server attributes] 00078 00079 // [action client attributes] 00080 00081 // odometry variables 00082 double left_wheels_velocity_; 00083 double right_wheels_velocity_; 00084 double yaw_rate_; 00085 double pitch_rate_; 00086 double roll_rate_; 00087 double vrimu_; 00088 double vpimu_; 00089 double vyimu_; 00090 ros::Time last_time_; 00091 ros::Time current_time_; 00092 00093 geometry_msgs::Transform accum_; 00094 Eigen::Matrix4f H; 00095 Eigen::Vector3f w; 00096 Eigen::Vector3f wt; 00097 Eigen::Vector3f ww; 00098 Eigen::Vector3f v; 00099 Eigen::Matrix3f wt_hat; 00100 double wt_norm; 00101 double epsilon; 00102 Eigen::Matrix3f R; 00103 Eigen::Matrix3f I; 00104 Eigen::Vector3f t; 00105 Eigen::Vector3f ta, tb; 00106 Eigen::Matrix4f g; 00107 Eigen::Vector4f d; 00108 Eigen::Vector4f q; // quaternion vector in q(0)-q(2), scalar part in q(3) 00109 geometry_msgs::PoseWithCovariance pose_; 00110 geometry_msgs::TwistWithCovariance twist_; 00111 geometry_msgs::Transform transform_; 00112 00113 // parameter variables 00114 std::string tf_prefix_; 00115 std::string odom_id_; 00116 std::string base_link_id_; 00117 bool publish_tf_; 00118 00119 public: 00126 SegwayRmp400OdomAlgNode(void); 00127 00134 ~SegwayRmp400OdomAlgNode(void); 00135 00136 protected: 00137 00138 tf::TransformBroadcaster odom_broadcaster_; 00139 00152 void mainNodeThread(void); 00153 00166 void node_config_update(Config &config, uint32_t level); 00167 00174 void addNodeDiagnostics(void); 00175 00176 // [diagnostic functions] 00177 00178 // [test functions] 00179 }; 00180 00181 #endif