Skip to content

Commit

Permalink
change function input, fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
qishuny committed May 25, 2022
1 parent 05a077a commit 82c665d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class CompFilterEstimator : public StateEstimator {
void mocapCallBackHelper(const geometry_msgs::PoseStamped::ConstPtr& msg,
const Eigen::Vector3d& pos,
geometry_msgs::PoseStamped::ConstPtr last_mocap_msg_,
const double mocap_rate_,
const double mocap_dropout_threshold_);
const double& mocap_rate_,
const double& mocap_dropout_threshold_);

/**
* @brief update CF state once
Expand All @@ -54,19 +54,17 @@ class CompFilterEstimator : public StateEstimator {

/**
* @brief update CF state once
* @param[in] hardware_interface_
* @param[in] fully_populated
* @param[in] last_imu_msg_
* @param[in] last_joint_state_msg_
* @param[in] last_mocap_msg_
* @param[in] user_rx_data_
* @param[out] last_robot_state_msg_
*/

bool updateState(std::shared_ptr<HardwareInterface> hardware_interface_,
sensor_msgs::Imu& last_imu_msg_,
bool updateState(const bool& fully_populated, sensor_msgs::Imu& last_imu_msg_,
sensor_msgs::JointState& last_joint_state_msg_,
geometry_msgs::PoseStamped::ConstPtr last_mocap_msg_,
Eigen::VectorXd& user_rx_data_,
quad_msgs::RobotState& last_robot_state_msg_);

bool initiated;
Expand Down
12 changes: 3 additions & 9 deletions robot_driver/src/estimators/comp_filter_estimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,11 @@ bool CompFilterEstimator::updateState() {
}

bool CompFilterEstimator::updateState(
std::shared_ptr<HardwareInterface> hardware_interface_,
sensor_msgs::Imu& last_imu_msg_,
const bool& fully_populated, sensor_msgs::Imu& last_imu_msg_,
sensor_msgs::JointState& last_joint_state_msg_,
geometry_msgs::PoseStamped::ConstPtr last_mocap_msg_,
Eigen::VectorXd& user_rx_data_,
quad_msgs::RobotState& last_robot_state_msg_) {
std::cout << "CF Estimator Updated Once" << std::endl;
// Get the newest data from the robot (BLOCKING)
bool fully_populated = hardware_interface_->recv(
last_joint_state_msg_, last_imu_msg_, user_rx_data_);

ros::Time state_timestamp = ros::Time::now();

// Check if robot data was recieved
Expand Down Expand Up @@ -147,7 +141,7 @@ bool CompFilterEstimator::updateState(
void CompFilterEstimator::mocapCallBackHelper(
const geometry_msgs::PoseStamped::ConstPtr& msg, const Eigen::Vector3d& pos,
geometry_msgs::PoseStamped::ConstPtr last_mocap_msg_,
const double mocap_rate_, const double mocap_dropout_threshold_) {
const double& mocap_rate_, const double& mocap_dropout_threshold_) {
if (low_pass_filter.init) {
// Record time diff between messages
ros::Time t_now = ros::Time::now();
Expand Down Expand Up @@ -191,4 +185,4 @@ void CompFilterEstimator::mocapCallBackHelper(

low_pass_filter.init = true;
}
};
}
9 changes: 6 additions & 3 deletions robot_driver/src/robot_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void RobotDriver::initStateEstimator() {
if (estimator_id_ == "comp_filter") {
comp_filter_estimator_ = std::make_shared<CompFilterEstimator>();
} else if (estimator_id_ == "ekf_filter") {
state_estimator_ = std::make_shared<EKFFilterEstimator>();
ekf_estimatror_ = std::make_shared<EKFFilterEstimator>();
} else {
ROS_ERROR_STREAM("Invalid estimator id " << estimator_id_
<< ", returning nullptr");
Expand Down Expand Up @@ -299,9 +299,12 @@ void RobotDriver::checkMessagesForSafety() {
bool RobotDriver::updateState() {
if (is_hardware_) {
if (estimator_id_ == "comp_filter") {
// Get the newest data from the robot (BLOCKING)
bool fully_populated = hardware_interface_->recv(
last_joint_state_msg_, last_imu_msg_, user_rx_data_);
return comp_filter_estimator_->updateState(
hardware_interface_, last_imu_msg_, last_joint_state_msg_,
last_mocap_msg_, user_rx_data_, last_robot_state_msg_);
fully_populated, last_imu_msg_, last_joint_state_msg_,
last_mocap_msg_, last_robot_state_msg_);
} else if (estimator_id_ == "ekf_filter") {
return ekf_estimatror_->updateState();
} else {
Expand Down

0 comments on commit 82c665d

Please sign in to comment.