From 6c7b2a1f6677d0700f384a21966d42943e7d2000 Mon Sep 17 00:00:00 2001 From: Yichen Liu Date: Sat, 7 Jun 2025 13:03:57 -0400 Subject: [PATCH 1/5] teleop init --- .../teleop/rosbridge_listener/CMakeLists.txt | 45 +++++++++++++++++++ .../include/rosbridge_listener_core.hpp | 0 .../include/rosbridge_listener_node.hpp | 29 ++++++++++++ .../teleop/rosbridge_listener/package.xml | 21 +++++++++ .../src/rosbridge_listener_core.cpp | 0 .../src/rosbridge_listener_node.cpp | 37 +++++++++++++++ .../wato_msgs/sample_msgs/msg/HandPose.msg | 1 + 7 files changed, 133 insertions(+) create mode 100644 autonomy/teleop/rosbridge_listener/CMakeLists.txt create mode 100644 autonomy/teleop/rosbridge_listener/include/rosbridge_listener_core.hpp create mode 100644 autonomy/teleop/rosbridge_listener/include/rosbridge_listener_node.hpp create mode 100644 autonomy/teleop/rosbridge_listener/package.xml create mode 100644 autonomy/teleop/rosbridge_listener/src/rosbridge_listener_core.cpp create mode 100644 autonomy/teleop/rosbridge_listener/src/rosbridge_listener_node.cpp create mode 100644 autonomy/wato_msgs/sample_msgs/msg/HandPose.msg diff --git a/autonomy/teleop/rosbridge_listener/CMakeLists.txt b/autonomy/teleop/rosbridge_listener/CMakeLists.txt new file mode 100644 index 0000000..1a56c21 --- /dev/null +++ b/autonomy/teleop/rosbridge_listener/CMakeLists.txt @@ -0,0 +1,45 @@ +cmake_minimum_required(VERSION 3.8) +project(rosbridge_listener) + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + +# find dependencies +find_package(ament_cmake REQUIRED) +find_package(rclcpp REQUIRED) +find_package(sample_msgs REQUIRED) +# uncomment the following section in order to fill in +# further dependencies manually. +# find_package( REQUIRED) + +add_library(rosbridge_listener_lib + src/rosbridge_listener_core.cpp) + +target_include_directories(rosbridge_listener_lib + PUBLIC include) + +add_executable(rosbridge_listener_node src/rosbridge_listener_node.cpp) + +ament_target_dependencies(rosbridge_listener_node rclcpp std_msgs sample_msgs) +target_include_directories(rosbridge_listener_node PUBLIC + $ + $) +target_compile_features(rosbridge_listener_node PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17 + +install(TARGETS rosbridge_listener_node + DESTINATION lib/${PROJECT_NAME}) + +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + # the following line skips the linter which checks for copyrights + # comment the line when a copyright and license is added to all source files + set(ament_cmake_copyright_FOUND TRUE) + # the following line skips cpplint (only works in a git repo) + # comment the line when this package is in a git repo and when + # a copyright and license is added to all source files + set(ament_cmake_cpplint_FOUND TRUE) + ament_lint_auto_find_test_dependencies() +endif() + +ament_package() diff --git a/autonomy/teleop/rosbridge_listener/include/rosbridge_listener_core.hpp b/autonomy/teleop/rosbridge_listener/include/rosbridge_listener_core.hpp new file mode 100644 index 0000000..e69de29 diff --git a/autonomy/teleop/rosbridge_listener/include/rosbridge_listener_node.hpp b/autonomy/teleop/rosbridge_listener/include/rosbridge_listener_node.hpp new file mode 100644 index 0000000..edf6177 --- /dev/null +++ b/autonomy/teleop/rosbridge_listener/include/rosbridge_listener_node.hpp @@ -0,0 +1,29 @@ +#ifndef ROSBRIDGE_LISTENER_NODE_HPP_ +#define ROSBRIDGE_LISTENER_NODE_HPP_ + +#include "rclcpp/rclcpp.hpp" + +#include "sample_msgs/msg/hand_pose.hpp" + +#include "rosbridge_listener_core.hpp" + +/** + * Implementation of a ROS2 node that listens to the "unfiltered" and "filtered" + * topics and echoes the operating frequency of the topic to the console. + */ +class ROSbridgeListenerNode: public rclcpp::Node { +public: + + ROSbridgeListenerNode(); + +private: + + std::string hand_pose_to_string(const sample_msgs::msg::HandPose::SharedPtr pose); + + void hand_pose_callback(const sample_msgs::msg::HandPose::SharedPtr msg); + + rclcpp::Subscription::SharedPtr hand_pose_sub_; + +}; + +#endif \ No newline at end of file diff --git a/autonomy/teleop/rosbridge_listener/package.xml b/autonomy/teleop/rosbridge_listener/package.xml new file mode 100644 index 0000000..e70774a --- /dev/null +++ b/autonomy/teleop/rosbridge_listener/package.xml @@ -0,0 +1,21 @@ + + + + rosbridge_listener + 0.0.0 + TODO: Package description + yichen + TODO: License declaration + + ament_cmake + + rclcpp + sample_msgs + + ament_lint_auto + ament_lint_common + + + ament_cmake + + diff --git a/autonomy/teleop/rosbridge_listener/src/rosbridge_listener_core.cpp b/autonomy/teleop/rosbridge_listener/src/rosbridge_listener_core.cpp new file mode 100644 index 0000000..e69de29 diff --git a/autonomy/teleop/rosbridge_listener/src/rosbridge_listener_node.cpp b/autonomy/teleop/rosbridge_listener/src/rosbridge_listener_node.cpp new file mode 100644 index 0000000..3a43178 --- /dev/null +++ b/autonomy/teleop/rosbridge_listener/src/rosbridge_listener_node.cpp @@ -0,0 +1,37 @@ +#include "rosbridge_listener_node.hpp" + +#include +#include + +ROSbridgeListenerNode::ROSbridgeListenerNode() : Node("rosbridge_listener") +{ + + hand_pose_sub_ = this->create_subscription( + "teleop", 10, std::bind(&ROSbridgeListenerNode::hand_pose_callback, this, std::placeholders::_1)); +} + +std::string ROSbridgeListenerNode::hand_pose_to_string(const sample_msgs::msg::HandPose::SharedPtr pose) +{ + std::string s; + std::vector hand_pose = pose->data; + s += "["; + for(int i=0; i < hand_pose.size(); i++){ + s += std::to_string(hand_pose[i]); + s += ","; + } + s += "]"; + return s; +} + +void ROSbridgeListenerNode::hand_pose_callback(const sample_msgs::msg::HandPose::SharedPtr msg) +{ + RCLCPP_INFO(this->get_logger(), "Received Hand Data: %s", hand_pose_to_string(msg).c_str()); +} + + +int main(int argc, char **argv) { + rclcpp::init(argc, argv); + rclcpp::spin(std::make_shared()); + rclcpp::shutdown(); + return 0; +} \ No newline at end of file diff --git a/autonomy/wato_msgs/sample_msgs/msg/HandPose.msg b/autonomy/wato_msgs/sample_msgs/msg/HandPose.msg new file mode 100644 index 0000000..c5fd6c8 --- /dev/null +++ b/autonomy/wato_msgs/sample_msgs/msg/HandPose.msg @@ -0,0 +1 @@ +float32[] data \ No newline at end of file From a334c1bd7e7988d33daae2466d913e70ae449b62 Mon Sep 17 00:00:00 2001 From: Yichen Liu Date: Sat, 14 Jun 2025 17:32:32 -0400 Subject: [PATCH 2/5] Added example rosbridge publisher node --- .../teleop/rosbridge_publisher/CMakeLists.txt | 44 +++++++++++++++++++ .../include/rosbridge_publisher_core.hpp | 18 ++++++++ .../include/rosbridge_publisher_node.hpp | 31 +++++++++++++ .../teleop/rosbridge_publisher/package.xml | 22 ++++++++++ .../src/rosbridge_publisher_core.cpp | 19 ++++++++ .../src/rosbridge_publisher_node.cpp | 29 ++++++++++++ autonomy/wato_msgs/sample_msgs/CMakeLists.txt | 3 +- 7 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 autonomy/teleop/rosbridge_publisher/CMakeLists.txt create mode 100644 autonomy/teleop/rosbridge_publisher/include/rosbridge_publisher_core.hpp create mode 100644 autonomy/teleop/rosbridge_publisher/include/rosbridge_publisher_node.hpp create mode 100644 autonomy/teleop/rosbridge_publisher/package.xml create mode 100644 autonomy/teleop/rosbridge_publisher/src/rosbridge_publisher_core.cpp create mode 100644 autonomy/teleop/rosbridge_publisher/src/rosbridge_publisher_node.cpp diff --git a/autonomy/teleop/rosbridge_publisher/CMakeLists.txt b/autonomy/teleop/rosbridge_publisher/CMakeLists.txt new file mode 100644 index 0000000..61a2d10 --- /dev/null +++ b/autonomy/teleop/rosbridge_publisher/CMakeLists.txt @@ -0,0 +1,44 @@ +cmake_minimum_required(VERSION 3.8) +project(rosbridge_publisher) + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + +# find dependencies +find_package(ament_cmake REQUIRED) +find_package(rclcpp REQUIRED) +find_package(std_msgs REQUIRED) +find_package(sample_msgs REQUIRED) +# uncomment the following section in order to fill in +# further dependencies manually. +# find_package( REQUIRED) + +add_library(rosbridge_publisher_lib src/rosbridge_publisher_core.cpp) + +target_include_directories(rosbridge_publisher_lib PUBLIC include) + +add_executable(rosbridge_publisher_node src/rosbridge_publisher_node.cpp) +ament_target_dependencies(rosbridge_publisher_lib rclcpp std_msgs sample_msgs) +target_link_libraries(rosbridge_publisher_node rosbridge_publisher_lib) +target_include_directories(rosbridge_publisher_node PUBLIC + $ + $) +target_compile_features(rosbridge_publisher_node PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17 + +install(TARGETS rosbridge_publisher_node + DESTINATION lib/${PROJECT_NAME}) + +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + # the following line skips the linter which checks for copyrights + # comment the line when a copyright and license is added to all source files + set(ament_cmake_copyright_FOUND TRUE) + # the following line skips cpplint (only works in a git repo) + # comment the line when this package is in a git repo and when + # a copyright and license is added to all source files + set(ament_cmake_cpplint_FOUND TRUE) + ament_lint_auto_find_test_dependencies() +endif() + +ament_package() diff --git a/autonomy/teleop/rosbridge_publisher/include/rosbridge_publisher_core.hpp b/autonomy/teleop/rosbridge_publisher/include/rosbridge_publisher_core.hpp new file mode 100644 index 0000000..d45b6fa --- /dev/null +++ b/autonomy/teleop/rosbridge_publisher/include/rosbridge_publisher_core.hpp @@ -0,0 +1,18 @@ +#ifndef ROSBRIDGE_PUBLISHER_CORE_HPP_ +#define ROSBRIDGE_PUBLISHER_CORE_HPP_ + +#include "rclcpp/rclcpp.hpp" + +#include "sample_msgs/msg/hand_pose.hpp" + +class ROSbridgePublisherCore { +public: + + explicit ROSbridgePublisherCore(); + + std::string hand_pose_to_string(const sample_msgs::msg::HandPose pose); + +private: +}; + +#endif // AGGREGATOR_CORE_HPP_ diff --git a/autonomy/teleop/rosbridge_publisher/include/rosbridge_publisher_node.hpp b/autonomy/teleop/rosbridge_publisher/include/rosbridge_publisher_node.hpp new file mode 100644 index 0000000..f827225 --- /dev/null +++ b/autonomy/teleop/rosbridge_publisher/include/rosbridge_publisher_node.hpp @@ -0,0 +1,31 @@ +#ifndef ROSBRIDGE_PUBLISHER_NODE_HPP_ +#define ROSBRIDGE_PUBLISHER_NODE_HPP_ + +#include "rclcpp/rclcpp.hpp" + +#include "sample_msgs/msg/hand_pose.hpp" + +#include "rosbridge_publisher_core.hpp" + +/** + * Implementation of a ROS2 node that listens to the "unfiltered" and "filtered" + * topics and echoes the operating frequency of the topic to the console. + */ +class ROSbridgePublisherNode: public rclcpp::Node { +public: + + ROSbridgePublisherNode(); + +private: + + void timer_callback(); + + rclcpp::TimerBase::SharedPtr timer_; + + rclcpp::Publisher::SharedPtr hand_pose_pub_; + + ROSbridgePublisherCore rosbridge_publisher_; + +}; + +#endif \ No newline at end of file diff --git a/autonomy/teleop/rosbridge_publisher/package.xml b/autonomy/teleop/rosbridge_publisher/package.xml new file mode 100644 index 0000000..1137e05 --- /dev/null +++ b/autonomy/teleop/rosbridge_publisher/package.xml @@ -0,0 +1,22 @@ + + + + rosbridge_publisher + 0.0.0 + TODO: Package description + yichen + TODO: License declaration + + ament_cmake + + rclcpp + sample_msgs + std_msgs + + ament_lint_auto + ament_lint_common + + + ament_cmake + + diff --git a/autonomy/teleop/rosbridge_publisher/src/rosbridge_publisher_core.cpp b/autonomy/teleop/rosbridge_publisher/src/rosbridge_publisher_core.cpp new file mode 100644 index 0000000..f9a2336 --- /dev/null +++ b/autonomy/teleop/rosbridge_publisher/src/rosbridge_publisher_core.cpp @@ -0,0 +1,19 @@ +#include +#include + +#include "rosbridge_publisher_core.hpp" + +ROSbridgePublisherCore::ROSbridgePublisherCore(){} + +std::string ROSbridgePublisherCore::hand_pose_to_string(const sample_msgs::msg::HandPose pose) +{ + std::string s; + std::vector hand_pose = pose.data; + s += "["; + for(int i=0; i < hand_pose.size(); i++){ + s += std::to_string(hand_pose[i]); + s += ","; + } + s += "]"; + return s; +} \ No newline at end of file diff --git a/autonomy/teleop/rosbridge_publisher/src/rosbridge_publisher_node.cpp b/autonomy/teleop/rosbridge_publisher/src/rosbridge_publisher_node.cpp new file mode 100644 index 0000000..9ada886 --- /dev/null +++ b/autonomy/teleop/rosbridge_publisher/src/rosbridge_publisher_node.cpp @@ -0,0 +1,29 @@ +#include "rosbridge_publisher_node.hpp" + +#include +#include + +using namespace std::chrono_literals; + +ROSbridgePublisherNode::ROSbridgePublisherNode() : Node("rosbridge_publisher"), rosbridge_publisher_(ROSbridgePublisherCore()) +{ + + hand_pose_pub_ = this->create_publisher("teleop", 10); + timer_ = this->create_wall_timer( + 500ms, std::bind(&ROSbridgePublisherNode::timer_callback, this) + ); +} + +void ROSbridgePublisherNode::timer_callback(){ + auto message = sample_msgs::msg::HandPose(); + message.data = std::vector(17); + RCLCPP_INFO(this->get_logger(), "Publishing: '%s'", rosbridge_publisher_.hand_pose_to_string(message).c_str()); + hand_pose_pub_->publish(message); +} + +int main(int argc, char **argv) { + rclcpp::init(argc, argv); + rclcpp::spin(std::make_shared()); + rclcpp::shutdown(); + return 0; +} \ No newline at end of file diff --git a/autonomy/wato_msgs/sample_msgs/CMakeLists.txt b/autonomy/wato_msgs/sample_msgs/CMakeLists.txt index 008fc0e..1bd6487 100644 --- a/autonomy/wato_msgs/sample_msgs/CMakeLists.txt +++ b/autonomy/wato_msgs/sample_msgs/CMakeLists.txt @@ -17,7 +17,8 @@ set(msg_files msg/Filtered.msg msg/FilteredArray.msg msg/Unfiltered.msg - msg/Metadata.msg) + msg/Metadata.msg + msg/HandPose.msg) rosidl_generate_interfaces(sample_msgs ${msg_files} DEPENDENCIES std_msgs) From d4f625512ad626d7173ce87c2e82af01586d5fc9 Mon Sep 17 00:00:00 2001 From: YichenLiu06 <91690715+YichenLiu06@users.noreply.github.com> Date: Sat, 14 Jun 2025 17:39:27 -0400 Subject: [PATCH 3/5] Create README.md --- autonomy/teleop/README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 autonomy/teleop/README.md diff --git a/autonomy/teleop/README.md b/autonomy/teleop/README.md new file mode 100644 index 0000000..a337fc3 --- /dev/null +++ b/autonomy/teleop/README.md @@ -0,0 +1,24 @@ +# Teleop +## Samples +To run rosbridge listener: +``` +ros2 run rosbridge_listener rosbridge_listener_node +``` + +To run rosbridge publisher: + +``` +ros2 run rosbridge_publisher rosbridge_publisher_node +``` + +## Running Rosbridge Server +Rosbridge server will relay ros topics to humanoid-server. To run, use: +``` +ros2 launch rosbridge_server rosbridge_websocket_launch.xml +``` +make sure to +``` +source install/setup.bash +``` +any packages containing messages etc. that you need + From 525827f4a16fc6f3e3a7002b126d6f23c518e5f2 Mon Sep 17 00:00:00 2001 From: WATonomousAdmin Date: Wed, 23 Jul 2025 00:37:03 +0000 Subject: [PATCH 4/5] Fix code style issues with clang_format --- .../include/rosbridge_listener_node.hpp | 14 +++++------ .../src/rosbridge_listener_node.cpp | 23 ++++++++++--------- .../include/rosbridge_publisher_core.hpp | 1 - .../include/rosbridge_publisher_node.hpp | 15 +++++------- .../src/rosbridge_publisher_core.cpp | 8 +++---- .../src/rosbridge_publisher_node.cpp | 16 +++++++------ 6 files changed, 37 insertions(+), 40 deletions(-) diff --git a/autonomy/teleop/rosbridge_listener/include/rosbridge_listener_node.hpp b/autonomy/teleop/rosbridge_listener/include/rosbridge_listener_node.hpp index edf6177..5808f83 100644 --- a/autonomy/teleop/rosbridge_listener/include/rosbridge_listener_node.hpp +++ b/autonomy/teleop/rosbridge_listener/include/rosbridge_listener_node.hpp @@ -11,19 +11,17 @@ * Implementation of a ROS2 node that listens to the "unfiltered" and "filtered" * topics and echoes the operating frequency of the topic to the console. */ -class ROSbridgeListenerNode: public rclcpp::Node { +class ROSbridgeListenerNode : public rclcpp::Node { public: - - ROSbridgeListenerNode(); + ROSbridgeListenerNode(); private: + std::string + hand_pose_to_string(const sample_msgs::msg::HandPose::SharedPtr pose); - std::string hand_pose_to_string(const sample_msgs::msg::HandPose::SharedPtr pose); - - void hand_pose_callback(const sample_msgs::msg::HandPose::SharedPtr msg); - - rclcpp::Subscription::SharedPtr hand_pose_sub_; + void hand_pose_callback(const sample_msgs::msg::HandPose::SharedPtr msg); + rclcpp::Subscription::SharedPtr hand_pose_sub_; }; #endif \ No newline at end of file diff --git a/autonomy/teleop/rosbridge_listener/src/rosbridge_listener_node.cpp b/autonomy/teleop/rosbridge_listener/src/rosbridge_listener_node.cpp index 3a43178..7c2be64 100644 --- a/autonomy/teleop/rosbridge_listener/src/rosbridge_listener_node.cpp +++ b/autonomy/teleop/rosbridge_listener/src/rosbridge_listener_node.cpp @@ -1,21 +1,22 @@ #include "rosbridge_listener_node.hpp" -#include #include +#include -ROSbridgeListenerNode::ROSbridgeListenerNode() : Node("rosbridge_listener") -{ +ROSbridgeListenerNode::ROSbridgeListenerNode() : Node("rosbridge_listener") { hand_pose_sub_ = this->create_subscription( - "teleop", 10, std::bind(&ROSbridgeListenerNode::hand_pose_callback, this, std::placeholders::_1)); + "teleop", 10, + std::bind(&ROSbridgeListenerNode::hand_pose_callback, this, + std::placeholders::_1)); } -std::string ROSbridgeListenerNode::hand_pose_to_string(const sample_msgs::msg::HandPose::SharedPtr pose) -{ +std::string ROSbridgeListenerNode::hand_pose_to_string( + const sample_msgs::msg::HandPose::SharedPtr pose) { std::string s; std::vector hand_pose = pose->data; s += "["; - for(int i=0; i < hand_pose.size(); i++){ + for (int i = 0; i < hand_pose.size(); i++) { s += std::to_string(hand_pose[i]); s += ","; } @@ -23,12 +24,12 @@ std::string ROSbridgeListenerNode::hand_pose_to_string(const sample_msgs::msg::H return s; } -void ROSbridgeListenerNode::hand_pose_callback(const sample_msgs::msg::HandPose::SharedPtr msg) -{ - RCLCPP_INFO(this->get_logger(), "Received Hand Data: %s", hand_pose_to_string(msg).c_str()); +void ROSbridgeListenerNode::hand_pose_callback( + const sample_msgs::msg::HandPose::SharedPtr msg) { + RCLCPP_INFO(this->get_logger(), "Received Hand Data: %s", + hand_pose_to_string(msg).c_str()); } - int main(int argc, char **argv) { rclcpp::init(argc, argv); rclcpp::spin(std::make_shared()); diff --git a/autonomy/teleop/rosbridge_publisher/include/rosbridge_publisher_core.hpp b/autonomy/teleop/rosbridge_publisher/include/rosbridge_publisher_core.hpp index d45b6fa..bde748f 100644 --- a/autonomy/teleop/rosbridge_publisher/include/rosbridge_publisher_core.hpp +++ b/autonomy/teleop/rosbridge_publisher/include/rosbridge_publisher_core.hpp @@ -7,7 +7,6 @@ class ROSbridgePublisherCore { public: - explicit ROSbridgePublisherCore(); std::string hand_pose_to_string(const sample_msgs::msg::HandPose pose); diff --git a/autonomy/teleop/rosbridge_publisher/include/rosbridge_publisher_node.hpp b/autonomy/teleop/rosbridge_publisher/include/rosbridge_publisher_node.hpp index f827225..e2d85ab 100644 --- a/autonomy/teleop/rosbridge_publisher/include/rosbridge_publisher_node.hpp +++ b/autonomy/teleop/rosbridge_publisher/include/rosbridge_publisher_node.hpp @@ -11,21 +11,18 @@ * Implementation of a ROS2 node that listens to the "unfiltered" and "filtered" * topics and echoes the operating frequency of the topic to the console. */ -class ROSbridgePublisherNode: public rclcpp::Node { +class ROSbridgePublisherNode : public rclcpp::Node { public: - - ROSbridgePublisherNode(); + ROSbridgePublisherNode(); private: + void timer_callback(); - void timer_callback(); + rclcpp::TimerBase::SharedPtr timer_; - rclcpp::TimerBase::SharedPtr timer_; - - rclcpp::Publisher::SharedPtr hand_pose_pub_; - - ROSbridgePublisherCore rosbridge_publisher_; + rclcpp::Publisher::SharedPtr hand_pose_pub_; + ROSbridgePublisherCore rosbridge_publisher_; }; #endif \ No newline at end of file diff --git a/autonomy/teleop/rosbridge_publisher/src/rosbridge_publisher_core.cpp b/autonomy/teleop/rosbridge_publisher/src/rosbridge_publisher_core.cpp index f9a2336..649e6a6 100644 --- a/autonomy/teleop/rosbridge_publisher/src/rosbridge_publisher_core.cpp +++ b/autonomy/teleop/rosbridge_publisher/src/rosbridge_publisher_core.cpp @@ -3,14 +3,14 @@ #include "rosbridge_publisher_core.hpp" -ROSbridgePublisherCore::ROSbridgePublisherCore(){} +ROSbridgePublisherCore::ROSbridgePublisherCore() {} -std::string ROSbridgePublisherCore::hand_pose_to_string(const sample_msgs::msg::HandPose pose) -{ +std::string ROSbridgePublisherCore::hand_pose_to_string( + const sample_msgs::msg::HandPose pose) { std::string s; std::vector hand_pose = pose.data; s += "["; - for(int i=0; i < hand_pose.size(); i++){ + for (int i = 0; i < hand_pose.size(); i++) { s += std::to_string(hand_pose[i]); s += ","; } diff --git a/autonomy/teleop/rosbridge_publisher/src/rosbridge_publisher_node.cpp b/autonomy/teleop/rosbridge_publisher/src/rosbridge_publisher_node.cpp index 9ada886..0fe923a 100644 --- a/autonomy/teleop/rosbridge_publisher/src/rosbridge_publisher_node.cpp +++ b/autonomy/teleop/rosbridge_publisher/src/rosbridge_publisher_node.cpp @@ -5,19 +5,21 @@ using namespace std::chrono_literals; -ROSbridgePublisherNode::ROSbridgePublisherNode() : Node("rosbridge_publisher"), rosbridge_publisher_(ROSbridgePublisherCore()) -{ +ROSbridgePublisherNode::ROSbridgePublisherNode() + : Node("rosbridge_publisher"), + rosbridge_publisher_(ROSbridgePublisherCore()) { - hand_pose_pub_ = this->create_publisher("teleop", 10); + hand_pose_pub_ = + this->create_publisher("teleop", 10); timer_ = this->create_wall_timer( - 500ms, std::bind(&ROSbridgePublisherNode::timer_callback, this) - ); + 500ms, std::bind(&ROSbridgePublisherNode::timer_callback, this)); } -void ROSbridgePublisherNode::timer_callback(){ +void ROSbridgePublisherNode::timer_callback() { auto message = sample_msgs::msg::HandPose(); message.data = std::vector(17); - RCLCPP_INFO(this->get_logger(), "Publishing: '%s'", rosbridge_publisher_.hand_pose_to_string(message).c_str()); + RCLCPP_INFO(this->get_logger(), "Publishing: '%s'", + rosbridge_publisher_.hand_pose_to_string(message).c_str()); hand_pose_pub_->publish(message); } From e6cb8f02dc0125e2d9e547d3cfadf45c1974a40f Mon Sep 17 00:00:00 2001 From: YichenLiu06 <91690715+YichenLiu06@users.noreply.github.com> Date: Wed, 23 Jul 2025 21:16:05 -0400 Subject: [PATCH 5/5] Update README.md --- autonomy/teleop/README.md | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/autonomy/teleop/README.md b/autonomy/teleop/README.md index a337fc3..1a52eb0 100644 --- a/autonomy/teleop/README.md +++ b/autonomy/teleop/README.md @@ -16,9 +16,30 @@ Rosbridge server will relay ros topics to humanoid-server. To run, use: ``` ros2 launch rosbridge_server rosbridge_websocket_launch.xml ``` -make sure to -``` + +## Full Setup for Testing VR -> ROS +These commands were run with the autonomy/samples folder deleted, since some packages may overlap + +```bash + +# In humanoid repo: +cd autonomy +colcon build +source install/setup.bash +ros2 run rosbridge_listener rosbridge_listener_node + +# Then, in another terminal: +cd autonomy source install/setup.bash +ros2 launch rosbridge_server rosbridge_websocket_launch.xml + +# In humanoid-server repo: +npm run dev +``` + +Then, connect to ws://localhost:3000 (default websocket url) and send an example hand pose message: +``` +[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] ``` -any packages containing messages etc. that you need +The message should appear in the terminal where you ran the rosbridge listener node