-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f1d7bc
commit 56ee768
Showing
4 changed files
with
139 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "heading_filter.hpp" | ||
|
||
namespace mrover { | ||
|
||
HeadingFilter::HeadingFilter() : Node("heading_filter") { | ||
|
||
// publishers | ||
linearized_position_sub.subscribe(this, "/linearized_position", 1); | ||
imu_sub.subscribe(this, "/zed_imu/data_raw", 10); | ||
mag_sub.subscribe(this, "/zed_imu/mag", 10); | ||
rtk_heading_sub.subscribe(this, "/heading/fix", 1); | ||
rtk_heading_status_sub.subscribe(this, "/heading_fix_status", 1); | ||
|
||
// synchronizer | ||
uint32_t queue_size = 10; | ||
sync = std::make_shared<message_filters::Synchronizer<message_filters::sync_policies::ApproximateTime | ||
<geometry_msgs::msg::Vector3Stamped, sensor_msgs::msg::Imu, sensor_msgs::msg::MagneticField, mrover::msg::Heading, mrover::msg::FixStatus>>>( | ||
message_filters::sync_policies::ApproximateTime<geometry_msgs::msg::Vector3Stamped, sensor_msgs::msg::Imu, sensor_msgs::msg::MagneticField, mrover::msg::Heading, mrover::msg::FixStatus>(queue_size), | ||
linearized_position_sub, | ||
imu_sub, | ||
mag_sub, | ||
rtk_heading_sub, | ||
rtk_heading_status_sub | ||
); | ||
|
||
sync->setAgePenalty(0.50); | ||
sync->registerCallback(std::bind(&HeadingFilter::synced_position_orientation_callback, this, _1, _2)); | ||
|
||
} | ||
|
||
void HeadingFilter::synced_position_orientation_callback(const geometry_msgs::msg::Vector3Stamped::ConstSharedPtr &position, | ||
const sensor_msgs::msg::Imu::ConstSharedPtr &imu, | ||
const sensor_msgs::msg::MagneticField::ConstSharedPtr &mag, | ||
const mrover::msg::Heading::ConstSharedPtr &rtk_heading, | ||
const mrover::msg::FixStatus::ConstSharedPtr &rtk_heading_status) { | ||
|
||
// to be implemented... | ||
|
||
} | ||
} // namespace mrover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#pragma once | ||
|
||
#include "pch.hpp" | ||
#include <geometry_msgs/msg/detail/vector3_stamped__struct.hpp> | ||
#include <sensor_msgs/msg/detail/magnetic_field__struct.hpp> | ||
|
||
namespace mrover { | ||
|
||
using std::placeholders::_1; | ||
using std::placeholders::_2; | ||
|
||
class HeadingFilter : public rclcpp::Node { | ||
|
||
private: | ||
|
||
void correct_and_publish(const geometry_msgs::msg::Vector3Stamped::ConstSharedPtr &position); | ||
|
||
// subscribers | ||
rclcpp::Subscription<geometry_msgs::msg::Vector3Stamped>::SharedPtr linearized_position_sub; | ||
rclcpp::Subscription<sensor_msgs::msg::Imu>::SharedPtr imu_sub; | ||
rclcpp::Subscription<sensor_msgs::msg::MagneticField>::SharedPtr mag_sub; | ||
|
||
message_filters::Subscriber<mrover::msg::Heading> rtk_heading_sub; | ||
message_filters::Subscriber<mrover::msg::FixStatus> rtk_heading_status_sub; | ||
|
||
// rclcpp::Subscription<mrover::msg::Heading>::SharedPtr rtk_heading_sub; | ||
rclcpp::Subscription<mrover::msg::FixStatus>::SharedPtr rtk_heading_status_sub; | ||
|
||
// rtk heading data watchdog | ||
rclcpp::TimerBase::SharedPtr rtk_heading_watchdog; | ||
|
||
// data store | ||
std::optional<double> last_rtk_heading; | ||
std::optional<builtin_interfaces::msg::Time> last_rtk_heading_time; | ||
std::optional<SO3d> rtk_heading_correction_rotation; | ||
|
||
// thresholding for data | ||
constexpr static float HEADING_THRESHOLD = 10; | ||
constexpr static bool HEADING_CORRECTED = false; | ||
|
||
|
||
|
||
// void synced_position_orientation_callback(const geometry_msgs::msg::Vector3Stamped::ConstSharedPtr &position, | ||
// const sensor_msgs::msg::Imu::ConstSharedPtr &imu, | ||
// const sensor_msgs::msg::MagneticField::ConstSharedPtr &mag, | ||
// const mrover::msg::Heading::ConstSharedPtr &rtk_heading, | ||
// const mrover::msg::FixStatus::ConstSharedPtr &rtk_heading_status); | ||
|
||
// // subscribers | ||
// message_filters::Subscriber<geometry_msgs::msg::Vector3Stamped> linearized_position_sub; | ||
// message_filters::Subscriber<sensor_msgs::msg::Imu> imu_sub; | ||
// message_filters::Subscriber<sensor_msgs::msg::MagneticField> mag_sub; | ||
// message_filters::Subscriber<mrover::msg::Heading> rtk_heading_sub; | ||
// message_filters::Subscriber<mrover::msg::FixStatus> rtk_heading_status_sub; | ||
|
||
// // synchronizer | ||
// std::shared_ptr<message_filters::Synchronizer<message_filters::sync_policies::ApproximateTime | ||
// <geometry_msgs::msg::Vector3Stamped, sensor_msgs::msg::Imu, sensor_msgs::msg::MagneticField, mrover::msg::Heading, mrover::msg::FixStatus>>> sync; | ||
|
||
|
||
public: | ||
|
||
HeadingFilter(); | ||
void spin(); | ||
|
||
|
||
} // class HeadingFilter | ||
|
||
} // namespace mrover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
|
||
#include <rclcpp/node.hpp> | ||
#include <rclcpp/executors.hpp> | ||
#include <rclcpp/rclcpp.hpp> | ||
|
||
#include <message_filters/subscriber.hpp> | ||
#include <message_filters/synchronizer.hpp> | ||
#include <mssage_filter/sync_policies/approximate_time.hpp> | ||
|
||
#include <geometry_msgs/msg/vector3_stamped.hpp> | ||
#include <sensor_msgs/msg/imu.hpp> | ||
#include <sensor_msgs/msg/magnetic_field.hpp> | ||
#include <mrover/msg/heading.hpp> | ||
#include <mrover/msg/fix_type.hpp> | ||
#include <mrover/msg/fix_status.hpp> | ||
#include <builtin_interfaces/msg/time.hpp> | ||
|
||
#include <lie.hpp> |