test_twist_command_sine_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 <vector>
00019 #include <string>
00020 
00021 #include <ros/ros.h>
00022 #include <geometry_msgs/Twist.h>
00023 
00024 class TwistCommandExecutionTester
00025 {
00026 public:
00027     TwistCommandExecutionTester()
00028     {
00029         output_pub_ = nh_.advertise<geometry_msgs::Twist>("command", 1);
00030 
00031         ros::Duration(1.0).sleep();
00032     }
00033 
00034 
00035     ~TwistCommandExecutionTester()
00036     {}
00037 
00038     void run()
00039     {
00040         ros::Rate r(50.0);
00041 
00042         ros::Time time = ros::Time::now();
00043         ros::Time start_time = time;
00044         double x = 0.0;
00045 
00046         double a = 0.6, b = 0.4, c = 0, d = 0;
00047 
00048         geometry_msgs::Twist command_msg;
00049 
00050         while (ros::ok())
00051         {
00052             time = ros::Time::now();
00053             x = (time - start_time).toSec();
00054 
00055             double vel = a*sin(b*x+c) + d;
00056 
00057             command_msg.angular.z = vel;
00058 
00059             output_pub_.publish(command_msg);
00060 
00061             ros::spinOnce();
00062             r.sleep();
00063         }
00064     }
00065 
00066 
00067     ros::NodeHandle nh_;
00068     ros::Publisher output_pub_;
00069 };
00070 
00071 
00072 
00073 int main(int argc, char **argv)
00074 {
00075     ros::init(argc, argv, "test_twist_command_execution_node");
00076 
00077     TwistCommandExecutionTester tcet;
00078     tcet.run();
00079     ros::spin();
00080     return 0;
00081 }


cob_twist_controller
Author(s): Felix Messmer , Marco Bezzon , Christoph Mark , Francisco Moreno
autogenerated on Thu Jun 6 2019 21:19:26