Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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();
00035 std::string name = unresolvedName(resolved_name);
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 }