test_simpson_integrator_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 <ros/ros.h>
20 #include <std_msgs/Float64.h>
21 #include <kdl/jntarray.hpp>
23 
24 
26 {
27 public:
29  {
30  unsigned int dof = 1;
31  q_.resize(dof);
33  q_dot_.resize(dof);
35 
36  integrator_.reset(new SimpsonIntegrator(dof));
37  output_q_pub_ = nh_.advertise<std_msgs::Float64>("output_q", 1);
38  output_q_dot_pub_ = nh_.advertise<std_msgs::Float64>("output_q_dot", 1);
40  }
41 
43  {}
44 
45  void input_cb(const std_msgs::Float64::ConstPtr& input)
46  {
47  q_dot_(0) = input->data;
48 
49  std::vector<double> next_q;
50  std::vector<double> next_q_dot;
51 
52  if (integrator_->updateIntegration(q_dot_, q_, next_q, next_q_dot))
53  {
54  for (unsigned int i = 0; i < next_q.size(); i++)
55  {
56  q_(i) = next_q[i];
57  q_dot_(i) = next_q_dot[i];
58  }
59 
60  std_msgs::Float64 output_q;
61  output_q.data = q_(0);
62  std_msgs::Float64 output_q_dot;
63  output_q_dot.data = q_dot_(0);
64 
65  output_q_pub_.publish(output_q);
66  output_q_dot_pub_.publish(output_q_dot);
67  }
68  }
69 
74 
77 
79 };
80 
81 
82 
83 int main(int argc, char **argv)
84 {
85  ros::init(argc, argv, "test_simpson_integrator_node");
86 
88 
89  ros::spin();
90  return 0;
91 }
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())
void input_cb(const std_msgs::Float64::ConstPtr &input)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROSCPP_DECL void spin(Spinner &spinner)
Eigen::VectorXd data
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void resize(unsigned int newSize)
void SetToZero(Jacobian &jac)
int main(int argc, char **argv)
boost::shared_ptr< SimpsonIntegrator > integrator_


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