velocity_smoother_node.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *   http://www.apache.org/licenses/LICENSE-2.0
00009 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 
00018 #include <ros/ros.h>
00019 #include <boost/thread.hpp>
00020 
00021 #include <cob_base_velocity_smoother/velocity_smoother.h>
00022 
00023 using namespace cob_base_velocity_smoother;
00024 
00025 std::string unresolvedName(const std::string &name){
00026     size_t pos = name.find_last_of('/');
00027     return name.substr(pos + 1);
00028 }
00029 
00030 int main(int argc, char** argv)
00031 {
00032   ros::init(argc, argv, "velocity_smoother");
00033   ros::NodeHandle nh_p("~");
00034   std::string resolved_name = nh_p.getUnresolvedNamespace(); // this always returns like /robosem/goo_arm - why not unresolved?
00035   std::string name = unresolvedName(resolved_name); // unresolve it ourselves
00036 
00037   boost::shared_ptr<VelocitySmoother> vel_smoother_;
00038   boost::shared_ptr<boost::thread>   worker_thread_;
00039 
00040   vel_smoother_.reset(new VelocitySmoother(name));
00041   if (vel_smoother_->init(nh_p))
00042   {
00043     ROS_DEBUG_STREAM("Velocity Smoother: initialised [" << name << "]");
00044     worker_thread_.reset(new boost::thread(&VelocitySmoother::spin, vel_smoother_));
00045   }
00046   else
00047   {
00048     ROS_ERROR_STREAM("Velocity Smoother: initialisation failed [" << name << "]");
00049   }
00050 
00051   ros::Rate r(100);
00052   while (ros::ok())
00053   {
00054     ros::spinOnce();
00055     r.sleep();
00056   }
00057 
00058   vel_smoother_->shutdown();
00059   worker_thread_->join();
00060   
00061   return 0;
00062 }


cob_base_velocity_smoother
Author(s): Florian Mirus , Benjamin Maidel
autogenerated on Thu Jun 6 2019 21:18:55