Quad-SDK
Loading...
Searching...
No Matches
comp_filter_estimator.h
1#ifndef COMP_FILTER_H
2#define COMP_FILTER_H
3
4#include <robot_driver/estimators/state_estimator.h>
5
8 public:
14
19 void init(ros::NodeHandle& nh);
20
24 void mocapCallBackHelper(const geometry_msgs::PoseStamped::ConstPtr& msg,
25 const Eigen::Vector3d& pos);
26
31 bool updateOnce(quad_msgs::RobotState& last_robot_state_msg);
32
33 private:
35 struct Filter {
36 // State-space model
37 Eigen::Matrix<double, 2, 2> A;
38 Eigen::Matrix<double, 2, 1> B;
39 Eigen::Matrix<double, 1, 2> C;
40 Eigen::Matrix<double, 1, 1> D;
41
42 // Filter states
43 std::vector<Eigen::Matrix<double, 2, 1>> x;
44
45 // Filter initialization indicator
46 bool init;
47 };
48
51
54
56 std::vector<double> high_pass_a_;
57 std::vector<double> high_pass_b_;
58 std::vector<double> high_pass_c_;
59 std::vector<double> high_pass_d_;
60
62 std::vector<double> low_pass_a_;
63 std::vector<double> low_pass_b_;
64 std::vector<double> low_pass_c_;
65 std::vector<double> low_pass_d_;
66
68 Eigen::Vector3d vel_estimate_;
69
71 Eigen::Vector3d mocap_vel_estimate_;
72
74 Eigen::Vector3d imu_vel_estimate_;
75
78
80 ros::NodeHandle nh_;
81};
82#endif // COMP_FILTER_H
Implements complementary filter as an estimator within the ROS framework.
Definition comp_filter_estimator.h:7
Eigen::Vector3d imu_vel_estimate_
Best estimate of imu velocity.
Definition comp_filter_estimator.h:74
std::vector< double > low_pass_a_
Low Pass States.
Definition comp_filter_estimator.h:62
void mocapCallBackHelper(const geometry_msgs::PoseStamped::ConstPtr &msg, const Eigen::Vector3d &pos)
Helper function to filter mocap data.
Definition comp_filter_estimator.cpp:109
ros::NodeHandle nh_
Nodehandle to get param.
Definition comp_filter_estimator.h:80
Eigen::Vector3d mocap_vel_estimate_
Best estimate of velocity from mocap diff.
Definition comp_filter_estimator.h:71
bool updateOnce(quad_msgs::RobotState &last_robot_state_msg)
Perform CF update once.
Definition comp_filter_estimator.cpp:40
Filter low_pass_filter
Low pass filter.
Definition comp_filter_estimator.h:50
ros::Time last_mocap_time_
Last mocap time.
Definition comp_filter_estimator.h:77
CompFilterEstimator()
Constructor for CompFilterEstimator.
Definition comp_filter_estimator.cpp:3
Filter high_pass_filter
High pass filter.
Definition comp_filter_estimator.h:53
void init(ros::NodeHandle &nh)
Initialize Complementary Filter.
Definition comp_filter_estimator.cpp:5
Eigen::Vector3d vel_estimate_
Best estimate of velocity.
Definition comp_filter_estimator.h:68
std::vector< double > high_pass_a_
High Pass States.
Definition comp_filter_estimator.h:56
Definition state_estimator.h:18
Struct of second-order low/high pass filter with derivative/intergral.
Definition comp_filter_estimator.h:35