28 #include <nav_msgs/Odometry.h> 29 #include <std_srvs/Trigger.h> 48 ROS_ERROR(
"Parameter 'steer_joint' not set");
52 ROS_ERROR(
"Parameter 'drive_joint' not set");
60 std::string description_name;
61 bool has_model = nh.
searchParam(
"robot_description", description_name) && model.
initParam(description_name);
63 urdf::Vector3 steer_pos;
64 urdf::JointConstSharedPtr steer_joint;
81 if (!nh.
getParam(
"publish_rate", publish_rate)){
82 ROS_ERROR(
"Parameter 'publish_rate' not set");
85 if(publish_rate <= 0){
90 const std::string frame_id = nh.
param(
"frame_id", std::string(
"odom"));
91 const std::string child_frame_id = nh.
param(
"child_frame_id", std::string(
"base_footprint"));
92 const double cov_pose = nh.
param(
"cov_pose", 0.1);
93 const double cov_twist = nh.
param(
"cov_twist", 0.1);
100 bool broadcast_tf =
true;
101 nh.
getParam(
"broadcast_tf", broadcast_tf);
104 odom_tf_.header.frame_id = frame_id;
105 odom_tf_.child_frame_id = child_frame_id;
120 virtual bool srv_reset(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res)
123 res.message =
"not running";
126 boost::mutex::scoped_lock lock(
mutex_);
130 ROS_INFO(
"Resetting odometry to zero.");
142 boost::mutex::scoped_try_lock lock(
mutex_);
174 boost::mutex::scoped_lock lock(mutex_);
176 topic_pub_odometry_.
publish(odom_);
178 if(tf_broadcast_odometry_){
181 odom_tf_.header.stamp = odom_.header.stamp;
183 odom_tf_.transform.translation.x = odom_.pose.pose.position.x;
184 odom_tf_.transform.translation.y = odom_.pose.pose.position.y;
185 odom_tf_.transform.rotation = odom_.pose.pose.orientation;
188 tf_broadcast_odometry_->sendTransform(odom_tf_);
201 double r_base = wheel_state_.
pos_x * wheel_state_.
sign;
203 platform_state_.
velY = 0.0;
boost::scoped_ptr< tf::TransformBroadcaster > tf_broadcast_odometry_
void publish(const boost::shared_ptr< M > &message) const
virtual void update(const ros::Time &time, const ros::Duration &period)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
virtual void stopping(const ros::Time &time)
ros::Timer publish_timer_
virtual void starting(const ros::Time &time)
tf2Scalar getAngle() const
ros::ServiceServer service_reset_
void publish(const ros::TimerEvent &)
geometry_msgs::TransformStamped odom_tf_
bool searchParam(const std::string &key, std::string &result) const
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
virtual bool srv_reset(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res)
virtual bool init(hardware_interface::JointStateInterface *hw, ros::NodeHandle &nh)
Timer createTimer(Rate r, Handler h, Obj o, bool oneshot=false, bool autostart=true) const
bool parseWheelTransform(const std::string &joint_name, const std::string &parent_link_name, tf2::Transform &transform, urdf::Model *model)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
URDF_EXPORT bool initParam(const std::string ¶m)
double getPosition() const
double getVelocity() const
ros::Publisher topic_pub_odometry_
JointStateHandle getHandle(const std::string &name)
hardware_interface::JointStateHandle drive_joint_
bool getParam(const std::string &key, std::string &s) const
hardware_interface::JointStateHandle steer_joint_
#define ROS_ERROR_STREAM(args)
boost::scoped_ptr< OdometryTracker > odom_tracker_
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
PlatformState platform_state_