robot_Information.cpp
Go to the documentation of this file.
00001 /*
00002  *  Copyright 2018, Sebastian Pütz
00003  *
00004  *  Redistribution and use in source and binary forms, with or without
00005  *  modification, are permitted provided that the following conditions
00006  *  are met:
00007  *
00008  *  1. Redistributions of source code must retain the above copyright
00009  *     notice, this list of conditions and the following disclaimer.
00010  *
00011  *  2. Redistributions in binary form must reproduce the above
00012  *     copyright notice, this list of conditions and the following
00013  *     disclaimer in the documentation and/or other materials provided
00014  *     with the distribution.
00015  *
00016  *  3. Neither the name of the copyright holder nor the names of its
00017  *     contributors may be used to endorse or promote products derived
00018  *     from this software without specific prior written permission.
00019  *
00020  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00021  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00022  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00023  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00024  *  COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00025  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00026  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00027  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00028  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00029  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00030  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00031  *  POSSIBILITY OF SUCH DAMAGE.
00032  *
00033  *  robot_information.cpp
00034  *
00035  *  author: Sebastian Pütz <spuetz@uni-osnabrueck.de>
00036  *
00037  */
00038 
00039 #include "mbf_abstract_nav/robot_information.h"
00040 #include "mbf_utility/navigation_utility.h"
00041 
00042 namespace mbf_abstract_nav{
00043 
00044 RobotInformation::RobotInformation(TF &tf_listener,
00045                                    const std::string &global_frame,
00046                                    const std::string &robot_frame,
00047                                    const ros::Duration &tf_timeout)
00048  : tf_listener_(tf_listener), global_frame_(global_frame), robot_frame_(robot_frame), tf_timeout_(tf_timeout)
00049 {
00050 
00051 }
00052 
00053 
00054 
00055 bool RobotInformation::getRobotPose(geometry_msgs::PoseStamped &robot_pose) const
00056 {
00057   bool tf_success = mbf_utility::getRobotPose(tf_listener_, robot_frame_, global_frame_,
00058                                               ros::Duration(tf_timeout_), robot_pose);
00059   robot_pose.header.stamp = ros::Time::now(); // would be 0 if not, as we ask tf listener for the last pose available
00060   if (!tf_success)
00061   {
00062     ROS_ERROR_STREAM("Can not get the robot pose in the global frame. - robot frame: \""
00063                          << robot_frame_ << "\"   global frame: \"" << global_frame_ << std::endl);
00064     return false;
00065   }
00066   return true;
00067 }
00068 
00069 bool RobotInformation::getRobotVelocity(geometry_msgs::TwistStamped &robot_velocity, ros::Duration look_back_duration) const
00070 {
00071   // TODO implement and filter tf data to compute velocity.
00072   return false;
00073 }
00074 
00075 const std::string& RobotInformation::getGlobalFrame() const {return global_frame_;};
00076 
00077 const std::string& RobotInformation::getRobotFrame() const {return robot_frame_;};
00078 
00079 const TF& RobotInformation::getTransformListener() const {return tf_listener_;};
00080 
00081 const ros::Duration& RobotInformation::getTfTimeout() const {return tf_timeout_;}
00082 
00083 }


mbf_abstract_nav
Author(s): Sebastian Pütz
autogenerated on Mon Jun 17 2019 20:11:35