diff --git a/external/vectornav b/external/vectornav new file mode 160000 index 00000000..2859fe18 --- /dev/null +++ b/external/vectornav @@ -0,0 +1 @@ +Subproject commit 2859fe18a3c4a5e6d3dafcef9923df9a854a2660 diff --git a/urc_bringup/launch/bringup.launch.py b/urc_bringup/launch/bringup.launch.py index 43200aef..dc50a183 100644 --- a/urc_bringup/launch/bringup.launch.py +++ b/urc_bringup/launch/bringup.launch.py @@ -81,6 +81,16 @@ def generate_launch_description(): arguments=["-p", controller_config_file_dir, "status_light_controller"], ) + vectornav_node = Node( + package="vectornav", + executable="vectornav" + ) + + imu_parser_node = Node( + package="urc_platform", + executable="urc_platform_IMUParser" + ) + # load_arm_controller = Node( # package="controller_manager", # executable="spawner", @@ -160,6 +170,8 @@ def generate_launch_description(): launch_gps, launch_imu, rosbridge_server_node, - odom_frame_node + odom_frame_node, + vectornav_node, + imu_parser_node ] ) diff --git a/urc_platform/CMakeLists.txt b/urc_platform/CMakeLists.txt index adf31705..b8df6c02 100644 --- a/urc_platform/CMakeLists.txt +++ b/urc_platform/CMakeLists.txt @@ -11,6 +11,7 @@ find_package(std_msgs REQUIRED) find_package(sensor_msgs REQUIRED) find_package(diagnostic_updater REQUIRED) find_package(usb_cam REQUIRED) +find_package(vectornav_msgs REQUIRED) include_directories( include @@ -19,6 +20,7 @@ include_directories( # Library creation add_library(${PROJECT_NAME} SHARED src/joystick_driver.cpp + src/imu_parser.cpp ) set(dependencies @@ -28,6 +30,7 @@ set(dependencies sensor_msgs diagnostic_updater usb_cam + vectornav_msgs ) ament_target_dependencies(${PROJECT_NAME} @@ -41,6 +44,12 @@ rclcpp_components_register_node( EXECUTABLE ${PROJECT_NAME}_JoystickDriver ) +rclcpp_components_register_node( + ${PROJECT_NAME} + PLUGIN "imu_parser::IMUParser" + EXECUTABLE ${PROJECT_NAME}_IMUParser +) + # Install launch files. install( DIRECTORY diff --git a/urc_platform/include/imu_parser.hpp b/urc_platform/include/imu_parser.hpp new file mode 100644 index 00000000..43e28afb --- /dev/null +++ b/urc_platform/include/imu_parser.hpp @@ -0,0 +1,33 @@ +#ifndef IMU_PARSER_H +#define IMU_PARSER_H + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace imu_parser +{ + +class IMUParser : public rclcpp::Node +{ +public: + explicit IMUParser(const rclcpp::NodeOptions & options); + +private: + rclcpp::Publisher::SharedPtr + imu_publisher; + + rclcpp::Subscription::SharedPtr vectornav_subscriber; + + void VectornavCallback(const vectornav_msgs::msg::CommonGroup & msg); + +}; + +} // namespace imu_parser + +#endif diff --git a/urc_platform/package.xml b/urc_platform/package.xml index faef788f..f8fb5cab 100644 --- a/urc_platform/package.xml +++ b/urc_platform/package.xml @@ -21,6 +21,7 @@ usb_cam image_transport image_transport_plugins + vectornav_msgs ament_lint_auto ament_lint_common diff --git a/urc_platform/src/imu_parser.cpp b/urc_platform/src/imu_parser.cpp new file mode 100644 index 00000000..d80eb1b4 --- /dev/null +++ b/urc_platform/src/imu_parser.cpp @@ -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/raw/common", rclcpp::SystemDefaultsQoS(), + [this](const vectornav_msgs::msg::CommonGroup msg) {VectornavCallback(msg);}); + + imu_publisher = create_publisher( + "/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)