velocity_smoother.h
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 #ifndef VELOCITY_SMOOTHER_HPP_
19 #define VELOCITY_SMOOTHER_HPP_
20 
21 /*****************************************************************************
22  ** Includes
23  *****************************************************************************/
24 
25 #include <ros/ros.h>
26 #include <dynamic_reconfigure/server.h>
27 #include <cob_base_velocity_smoother/paramsConfig.h>
28 #include <nav_msgs/Odometry.h>
29 
30 /*****************************************************************************
31 ** Namespaces
32 *****************************************************************************/
33 
35 
36 /*****************************************************************************
37 ** VelocitySmoother
38 *****************************************************************************/
39 
41 {
42 public:
43  VelocitySmoother(const std::string &name);
44 
46  {
47  if (dynamic_reconfigure_server != NULL)
49  }
50 
51  bool init(ros::NodeHandle& nh);
52  void spin();
53  void shutdown() { shutdown_req = true; };
54 
55 private:
57  {
61  } robot_feedback;
63  std::string name;
68 
69  double frequency;
70 
71  geometry_msgs::Twist last_cmd_vel;
72  geometry_msgs::Twist current_vel;
73  geometry_msgs::Twist target_vel;
74 
75  bool shutdown_req;
77  double cb_avg_time;
79  std::vector<double> period_record;
80  unsigned int pr_next;
87  void velocityCB(const geometry_msgs::Twist::ConstPtr& msg);
88  void robotVelCB(const geometry_msgs::Twist::ConstPtr& msg);
89  void odometryCB(const nav_msgs::Odometry::ConstPtr& msg);
90 
91  double sign(double x) { return x < 0.0 ? -1.0 : +1.0; };
92 
93  double median(std::vector<double> values) {
94  // Return the median element of an doubles vector
95  nth_element(values.begin(), values.begin() + values.size()/2, values.end());
96  return values[values.size()/2];
97  };
98 
99  /*********************
100  ** Dynamic Reconfigure
101  **********************/
102  dynamic_reconfigure::Server<cob_base_velocity_smoother::paramsConfig> * dynamic_reconfigure_server;
103  dynamic_reconfigure::Server<cob_base_velocity_smoother::paramsConfig>::CallbackType dynamic_reconfigure_callback;
104  void reconfigCB(cob_base_velocity_smoother::paramsConfig &config, uint32_t unused_level);
105 };
106 
107 } // cob_base_velocity_smoother
108 
109 #endif /* VELOCITY_SMOOTHER_HPP_ */
void velocityCB(const geometry_msgs::Twist::ConstPtr &msg)
enum cob_base_velocity_smoother::VelocitySmoother::RobotFeedbackType robot_feedback
dynamic_reconfigure::Server< cob_base_velocity_smoother::paramsConfig >::CallbackType dynamic_reconfigure_callback
void reconfigCB(cob_base_velocity_smoother::paramsConfig &config, uint32_t unused_level)
dynamic_reconfigure::Server< cob_base_velocity_smoother::paramsConfig > * dynamic_reconfigure_server
double median(std::vector< double > values)
void robotVelCB(const geometry_msgs::Twist::ConstPtr &msg)
void odometryCB(const nav_msgs::Odometry::ConstPtr &msg)


cob_base_velocity_smoother
Author(s): Florian Mirus , Benjamin Maidel
autogenerated on Thu Apr 8 2021 02:39:30