Tetrapod Project
state_estimator.h
Go to the documentation of this file.
1 #ifndef state_estimator_h
2 #define state_estimator_h
3 
4 #include "ros/ros.h"
5 #include "ros/console.h"
6 #include "std_msgs/Float64MultiArray.h"
7 #include "geometry_msgs/Twist.h"
8 
9 #include <Eigen/Core>
10 
11 #include <bits/stdc++.h>
12 
14 {
15  public: StateEstimator(double gait_period, double controller_frequency);
16 
17  public: void PrintStates();
18 
19  public: void PublishBodyTwistState();
20 
21  public: void UpdateStates();
22 
23  private: Eigen::Matrix<double, 3, 1> _attitude = Eigen::Matrix<double, 3, 1>::Zero();
24 
25  private: Eigen::Matrix<double, 3, 1> _lin_vel_body = Eigen::Matrix<double, 3, 1>::Zero();
26 
27  private: Eigen::Matrix<double, 3, 1> _ang_vel = Eigen::Matrix<double, 3, 1>::Zero();
28 
29  private: Eigen::Matrix<double, 3, 1> _lin_vel_world = Eigen::Matrix<double, 3, 1>::Zero();
30 
31  private: double _avg_lin_gait_vel_x = 0.0;
32 
33  private: double _avg_lin_gait_vel_y = 0.0;
34 
35  private: double _avg_ang_gait_vel_z = 0.0;
36 
37  private: std::vector<double> _lin_vel_body_x_history;
38 
39  private: std::vector<double> _lin_vel_body_y_history;
40 
41  private: std::vector<double> _ang_vel_body_z_history;
42 
43  private: int gait_iteration = 0;
44 
46 
47  private: std::string _node_name = "state_estimation_node";
48 
49  private: ros::NodeHandlePtr _node_handle;
50 
51  private: ros::Subscriber _generalized_position_subscriber;
52 
53  private: ros::Subscriber _generalized_velocity_subscriber;
54 
55  private: ros::Publisher _body_twist_state_publisher;
56 
57  private: void InitializeROS();
58 
59  private: void GeneralizedPositionCallback(const std_msgs::Float64MultiArrayConstPtr &msg);
60 
61  private: void GeneralizedVelocityCallback(const std_msgs::Float64MultiArrayConstPtr &msg);
62 };
63 
64 #endif
ros::Subscriber _generalized_position_subscriber
Eigen::Matrix< double, 3, 1 > _attitude
std::vector< double > _ang_vel_body_z_history
std::vector< double > _lin_vel_body_y_history
double _avg_ang_gait_vel_z
Eigen::Matrix< double, 3, 1 > _lin_vel_body
double _avg_lin_gait_vel_y
ros::Publisher _body_twist_state_publisher
ros::Subscriber _generalized_velocity_subscriber
StateEstimator(double gait_period, double controller_frequency)
std::string _node_name
int number_of_gait_iterations
Eigen::Matrix< double, 3, 1 > _lin_vel_world
std::vector< double > _lin_vel_body_x_history
void GeneralizedPositionCallback(const std_msgs::Float64MultiArrayConstPtr &msg)
void PublishBodyTwistState()
void GeneralizedVelocityCallback(const std_msgs::Float64MultiArrayConstPtr &msg)
double _avg_lin_gait_vel_x
ros::NodeHandlePtr _node_handle
Eigen::Matrix< double, 3, 1 > _ang_vel