test_moving_average_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 <string>
19 #include <ros/ros.h>
20 #include <std_msgs/Float64.h>
22 
23 
25 {
26 public:
28  {
29  ma_.reset(ma);
30  output_pub_ = nh_.advertise<std_msgs::Float64>(out, 1);
32  }
33 
35  {}
36 
37  void input_cb(const std_msgs::Float64::ConstPtr& input)
38  {
39  std_msgs::Float64 output;
40 
41  ma_->addElement(input->data);
42  if (ma_->calcMovingAverage(output.data))
43  {
44  output_pub_.publish(output);
45  }
46  }
47 
51 
53 };
54 
55 
56 
57 int main(int argc, char **argv)
58 {
59  ros::init(argc, argv, "test_moving_average_node");
60 
62  MovingAverageTester mat("output_ma", ma_3);
64  MovingAverageTester maw_3t("output_maw", maw_3);
66  MovingAverageTester mae_03t("output_mae", mae_03);
68  MovingAverageTester mae_05t("output_mae05", mae_05);
69 
70  ros::spin();
71  return 0;
72 }
MovingAverageExponential< double > MovingAvgExponential_double_t
MovingAverageWeighted< double > MovingAvgWeighted_double_t
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void input_cb(const std_msgs::Float64::ConstPtr &input)
ROSCPP_DECL void spin(Spinner &spinner)
boost::shared_ptr< MovingAvgBase_double_t > ma_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
int main(int argc, char **argv)
MovingAverageTester(std::string out, MovingAvgBase_double_t *ma)
MovingAverageSimple< double > MovingAvgSimple_double_t


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