test_twist_command_sine_node.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
18 #include <vector>
19 #include <string>
20 
21 #include <ros/ros.h>
22 #include <geometry_msgs/Twist.h>
23 
25 {
26 public:
28  {
29  output_pub_ = nh_.advertise<geometry_msgs::Twist>("command", 1);
30 
31  ros::Duration(1.0).sleep();
32  }
33 
34 
36  {}
37 
38  void run()
39  {
40  ros::Rate r(50.0);
41 
42  ros::Time time = ros::Time::now();
43  ros::Time start_time = time;
44  double x = 0.0;
45 
46  double a = 0.6, b = 0.4, c = 0, d = 0;
47 
48  geometry_msgs::Twist command_msg;
49 
50  while (ros::ok())
51  {
52  time = ros::Time::now();
53  x = (time - start_time).toSec();
54 
55  double vel = a*sin(b*x+c) + d;
56 
57  command_msg.angular.z = vel;
58 
59  output_pub_.publish(command_msg);
60 
61  ros::spinOnce();
62  r.sleep();
63  }
64  }
65 
66 
69 };
70 
71 
72 
73 int main(int argc, char **argv)
74 {
75  ros::init(argc, argv, "test_twist_command_execution_node");
76 
78  tcet.run();
79  ros::spin();
80  return 0;
81 }
d
void publish(const boost::shared_ptr< M > &message) const
bool sleep() const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROSCPP_DECL void spin(Spinner &spinner)
int main(int argc, char **argv)
ROSCPP_DECL bool ok()
TFSIMD_FORCE_INLINE const tfScalar & x() const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
r
bool sleep()
static Time now()
ROSCPP_DECL void spinOnce()
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)


cob_twist_controller
Author(s): Felix Messmer , Marco Bezzon , Christoph Mark , Francisco Moreno
autogenerated on Thu Apr 8 2021 02:40:01