output_recorder.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 OUTPUT_RECORDER_H
19 #define OUTPUT_RECORDER_H
20 
21 #include <termios.h>
22 #include <signal.h>
23 #include <string>
24 #include <vector>
25 
26 #include <ros/ros.h>
27 
28 #include <std_srvs/Empty.h>
29 #include <geometry_msgs/Pose.h>
30 #include <geometry_msgs/Twist.h>
31 #include <sensor_msgs/JointState.h>
32 
34 #include <tf/transform_listener.h>
35 
36 #include <Eigen/Dense>
37 #include <Eigen/SVD>
38 
40 #include <kdl/chainiksolvervel_pinv.hpp>
41 #include <kdl/chainfksolvervel_recursive.hpp>
42 #include <kdl/frames.hpp>
43 #include <kdl/framevel.hpp>
44 #include <kdl/jntarray.hpp>
45 #include <kdl/jntarrayvel.hpp>
46 
47 #include <boost/thread.hpp>
48 
49 
51 {
52 public:
53  bool initialize();
54  void run();
55  void stopRecording();
56  void quit(int sig);
57 
58  void jointstateCallback(const sensor_msgs::JointState::ConstPtr& msg);
59  void twistCallback(const geometry_msgs::TwistStamped::ConstPtr& msg);
60 
61  geometry_msgs::Pose getEndeffectorPose();
62 
63  double calculateLS(std::vector<double>* vec_out, std::vector<double>* vec_in, int model_order,
64  double& a1, double& a2, double& a3,
65  double& b1, double& b2, double& b3);
66  void pseudoInverse(const Eigen::MatrixXd& matrix, Eigen::MatrixXd& matrix_inv, double tolerance);
67  void euler(std::vector<double>* out, double in, double dt);
68  void fillDataVectors(double x_dot_lin_in, double x_dot_lin_out,
69  double y_dot_lin_in, double y_dot_lin_out,
70  double z_dot_lin_in, double z_dot_lin_out,
71  double x_dot_rot_in, double x_dot_rot_out,
72  double y_dot_rot_in, double y_dot_rot_out,
73  double z_dot_rot_in, double z_dot_rot_out,
74  double x_lin_out, double y_lin_out, double z_lin_out, double x_rot_out, double y_rot_out, double z_rot_out);
75  void stepResponsePlot(std::string file_name, std::vector<double>* in,
76  std::vector<double>* x_lin_out, std::vector<double>* y_lin_out, std::vector<double>* z_lin_out,
77  std::vector<double>* x_rot_out, std::vector<double>* y_rot_out, std::vector<double>* z_rot_out);
78  void writeToMFile(std::string file_name, std::vector<double>* dot_in, std::vector<double>* dot_out, std::vector<double>* pos_out, std::vector<double>* dot_integrated);
79 
80 private:
84 
87  std::string output_file_path_;
88  std::string chain_base_link_;
89  std::string chain_tip_link_;
92  std::vector<std::string> joints_;
94  unsigned int dof_;
96 
98  // Velocity
101 
102  // Position
106 
110 
113 
116 
118  double dt_;
119 
120  bool start_;
122  std::vector<double> time_vec_;
123 
125  char c;
126  int kfd;
127  struct termios cooked, raw;
128 };
129 
130 #endif
131 
std::vector< double > x_dot_lin_vec_out_
Outputs.
std::vector< double > z_dot_lin_vec_in_
void jointstateCallback(const sensor_msgs::JointState::ConstPtr &msg)
std::vector< double > x_dot_rot_vec_out_
std::vector< double > y_dot_lin_vec_out_
KDL::ChainFkSolverVel_recursive * jntToCartSolver_vel_
ros::NodeHandle nh_
std::vector< double > z_dot_rot_vec_out_
void pseudoInverse(const Eigen::MatrixXd &matrix, Eigen::MatrixXd &matrix_inv, double tolerance)
ros::Subscriber twist_sub_
void writeToMFile(std::string file_name, std::vector< double > *dot_in, std::vector< double > *dot_out, std::vector< double > *pos_out, std::vector< double > *dot_integrated)
tf::TransformListener listener_
Transform Listener.
std::vector< double > x_lin_vec_out_
std::vector< double > x_dot_lin_vec_in_
Inputs.
std::vector< double > time_vec_
std::vector< double > z_dot_rot_vec_in_
std::vector< double > y_dot_rot_vec_in_
void twistCallback(const geometry_msgs::TwistStamped::ConstPtr &msg)
std::vector< double > y_dot_rot_vec_out_
KDL::JntArray last_q_dot_
unsigned int dof_
std::vector< double > x_dot_rot_vec_in_
std::vector< double > z_lin_vec_out_
std::vector< double > z_dot_lin_vec_out_
KDL::Vector vector_vel_
KDL::Vector vector_rot_
std::vector< double > y_rot_vec_out_
std::vector< double > x_rot_vec_out_
ros::Subscriber jointstate_sub_
geometry_msgs::Pose getEndeffectorPose()
double calculateLS(std::vector< double > *vec_out, std::vector< double > *vec_in, int model_order, double &a1, double &a2, double &a3, double &b1, double &b2, double &b3)
std::vector< double > z_rot_vec_out_
KDL::Chain chain_
KDL Conversion.
struct termios cooked raw
void euler(std::vector< double > *out, double in, double dt)
char c
For Keyboard commands.
void stepResponsePlot(std::string file_name, std::vector< double > *in, std::vector< double > *x_lin_out, std::vector< double > *y_lin_out, std::vector< double > *z_lin_out, std::vector< double > *x_rot_out, std::vector< double > *y_rot_out, std::vector< double > *z_rot_out)
std::string chain_base_link_
std::string output_file_path_
KDL::JntArray last_q_
std::vector< double > y_dot_lin_vec_in_
double dt_
Euler Integration.
std::vector< std::string > joints_
void quit(int sig)
std::string chain_tip_link_
std::vector< double > y_lin_vec_out_
void fillDataVectors(double x_dot_lin_in, double x_dot_lin_out, double y_dot_lin_in, double y_dot_lin_out, double z_dot_lin_in, double z_dot_lin_out, double x_dot_rot_in, double x_dot_rot_out, double y_dot_rot_in, double y_dot_rot_out, double z_dot_rot_in, double z_dot_rot_out, double x_lin_out, double y_lin_out, double z_lin_out, double x_rot_out, double y_rot_out, double z_rot_out)


cob_model_identifier
Author(s): Christoph Mark
autogenerated on Thu Apr 8 2021 02:39:44