-
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
bf175b8
commit 0c2c8e9
Showing
6 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
Submodule vectornav
added at
2859fe
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
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,33 @@ | ||
#ifndef IMU_PARSER_H | ||
#define IMU_PARSER_H | ||
|
||
#include <bits/stdc++.h> | ||
#include <math.h> | ||
#include <rclcpp/qos.hpp> | ||
#include <rclcpp/rclcpp.hpp> | ||
#include <rclcpp_components/register_node_macro.hpp> | ||
#include <sensor_msgs/msg/imu.hpp> | ||
#include <unistd.h> | ||
#include <vectornav_msgs/msg/common_group.hpp> | ||
|
||
namespace imu_parser | ||
{ | ||
|
||
class IMUParser : public rclcpp::Node | ||
{ | ||
public: | ||
explicit IMUParser(const rclcpp::NodeOptions & options); | ||
|
||
private: | ||
rclcpp::Publisher<sensor_msgs::msg::Imu>::SharedPtr | ||
imu_publisher; | ||
|
||
rclcpp::Subscription<vectornav_msgs::msg::CommonGroup>::SharedPtr vectornav_subscriber; | ||
|
||
void VectornavCallback(const vectornav_msgs::msg::CommonGroup & msg); | ||
|
||
}; | ||
|
||
} // namespace imu_parser | ||
|
||
#endif |
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,32 @@ | ||
#include "imu_parser.hpp" | ||
|
||
namespace imu_parser | ||
{ | ||
|
||
int header = 0; | ||
IMUParser::IMUParser(const rclcpp::NodeOptions & options) | ||
: rclcpp::Node("imu_parser", options) | ||
{ | ||
vectornav_subscriber = create_subscription<vectornav_msgs::msg::CommonGroup>( | ||
"/vectornav/raw/common", rclcpp::SystemDefaultsQoS(), | ||
[this](const vectornav_msgs::msg::CommonGroup msg) {VectornavCallback(msg);}); | ||
|
||
imu_publisher = create_publisher<sensor_msgs::msg::Imu>( | ||
"/imu", rclcpp::SystemDefaultsQoS()); | ||
} | ||
|
||
void IMUParser::VectornavCallback(const vectornav_msgs::msg::CommonGroup & msg) | ||
{ | ||
sensor_msgs::msg::Imu result; | ||
// result.header.seq = header++; | ||
result.header.frame_id = std::to_string(header); | ||
result.orientation.x = msg.quaternion.x; | ||
result.orientation.y = msg.quaternion.y; | ||
result.orientation.z = msg.quaternion.z; | ||
result.orientation.w = msg.quaternion.w; | ||
imu_publisher->publish(result); | ||
} | ||
|
||
} // namespace orchestrator | ||
|
||
RCLCPP_COMPONENTS_REGISTER_NODE(imu_parser::IMUParser) |