-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Publish analog pins #1095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
travis-mendoza
wants to merge
38
commits into
ROBOTIS-GIT:humble
Choose a base branch
from
ez-turtlebot3:publish-analog-pins
base: humble
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Publish analog pins #1095
Changes from 2 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
c048c5d
Publish OpenCR pins A0-A5 raw values to /analog_pins
travis-mendoza d040226
assign copyright of analog pins files to ROBOTIS
travis-mendoza 79479c3
Add error messages and retry logic to check_device_status
travis-mendoza 32b9853
Fix error handling for IMU calibration failures
travis-mendoza 206c253
Update check_device_status declaration in header file
travis-mendoza 8b6cd9e
Increase time between IMU calibration retries
travis-mendoza 78ad7d0
Add moar cowbell (delay)
travis-mendoza 28a48c0
Remove error handling and logging from last few commits to declutter
travis-mendoza 050835f
Address launch file substitution error
travis-mendoza e3e7fe7
Sleep 5 seconds after IMU calibration for consistent bringup success
travis-mendoza 227e36f
Test OpenCR heartbeat before reading device status
travis-mendoza 888a3a7
Retry motor connection check if device status shows motor not connected
travis-mendoza d30d71a
Move motors warning out of for loop
travis-mendoza 7f530fb
Only show motor warning when motors do not initialize
travis-mendoza 046bffa
Create and check fw device_ready flag before checking device_status
travis-mendoza 8cb7065
Slap on a hot messy fix to address bringup segfault
travis-mendoza f0179c8
Revert "Slap on a hot messy fix to address bringup segfault"
travis-mendoza 789b9ef
Separate analog pins update rate from other sensors
travis-mendoza 344bd83
Add pointer and timer for analog pins to header file
travis-mendoza 98ff228
Write ez-turtlebot3 README
travis-mendoza b87f432
Fix rebuild instructions
travis-mendoza c299617
Invoke MPPI controller and SMAC Hybrid planner in nav2 burger params
travis-mendoza 41c9ce9
add .vscode to gitignore
travis-mendoza ac70b2d
Add AGENT.md to work with Sourcegraph Amp
travis-mendoza 807ee21
Comment out duplicate init_read_memory call for analog pins
travis-mendoza 084be22
Checkout turtlebot3.cpp from 'humble' branch for baseline
travis-mendoza 1aec572
Expand memory range in init_read_memory
travis-mendoza 402b765
Replace analog sensors with analog pins
travis-mendoza 898bb8f
Remove sensor_state from tb3_node CMakeLists
travis-mendoza 0f774ae
Specify which analog pins to read
travis-mendoza 7e6ef5c
Change variable types to make Colcon happy
travis-mendoza 7a1a861
Provide default analog_pins parameter at declaration
travis-mendoza 336094c
Add launch parameter to list analog pins to read
travis-mendoza 9147c50
Make use of custom AnalogPin ROS2 msg
travis-mendoza 3209053
Publish temperature and humidity
travis-mendoza 0e27b02
Add debug messages for temperature and humidity
travis-mendoza c0fd2e8
Remove ROS info log messages used to debug temp and RH
travis-mendoza 881f6c7
Fix copyright
travis-mendoza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
50 changes: 50 additions & 0 deletions
50
turtlebot3_node/include/turtlebot3_node/sensors/analog_pins.hpp
This file contains hidden or 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,50 @@ | ||
| // Copyright 2025 ROBOTIS CO., LTD. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #ifndef TURTLEBOT3_NODE__SENSORS__ANALOG_PINS_HPP_ | ||
| #define TURTLEBOT3_NODE__SENSORS__ANALOG_PINS_HPP_ | ||
|
|
||
| #include <memory> | ||
| #include <string> | ||
|
|
||
| #include "rclcpp/rclcpp.hpp" | ||
| #include "std_msgs/msg/u_int16_multi_array.hpp" | ||
|
|
||
| #include "turtlebot3_node/sensors/sensors.hpp" | ||
|
|
||
| namespace robotis | ||
| { | ||
| namespace turtlebot3 | ||
| { | ||
| namespace sensors | ||
| { | ||
| class AnalogPins : public Sensors | ||
| { | ||
| public: | ||
| explicit AnalogPins( | ||
| std::shared_ptr<rclcpp::Node> & nh, | ||
| const std::string & topic_name); | ||
|
|
||
| void publish( | ||
| const rclcpp::Time & now, | ||
| std::shared_ptr<DynamixelSDKWrapper> & dxl_sdk_wrapper) override; | ||
|
|
||
| private: | ||
| rclcpp::Publisher<std_msgs::msg::UInt16MultiArray>::SharedPtr analog_publisher_; | ||
| }; | ||
| } // namespace sensors | ||
| } // namespace turtlebot3 | ||
| } // namespace robotis | ||
|
|
||
| #endif // TURTLEBOT3_NODE__SENSORS__ANALOG_PINS_HPP_ |
This file contains hidden or 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 hidden or 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,85 @@ | ||
| // Copyright 2025 ROBOTIS CO., LTD. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #include "turtlebot3_node/sensors/analog_pins.hpp" | ||
|
|
||
| #include <memory> | ||
| #include <string> | ||
| #include <utility> | ||
|
|
||
| using robotis::turtlebot3::sensors::AnalogPins; | ||
|
|
||
| AnalogPins::AnalogPins( | ||
| std::shared_ptr<rclcpp::Node> & nh, | ||
| const std::string & topic_name) | ||
| : Sensors(nh, "") // Call parent constructor with node handle and empty frame_id | ||
| { | ||
| auto qos = rclcpp::QoS(rclcpp::KeepLast(10)); | ||
|
|
||
| analog_publisher_ = nh->create_publisher<std_msgs::msg::UInt16MultiArray>(topic_name, qos); | ||
|
|
||
| RCLCPP_INFO(nh->get_logger(), "Succeeded to create analog pins publisher"); | ||
| } | ||
|
|
||
| void AnalogPins::publish( | ||
| const rclcpp::Time & now, | ||
| std::shared_ptr<DynamixelSDKWrapper> & dxl_sdk_wrapper) | ||
| { | ||
| (void)now; // Mark as unused intentionally to suppress warning | ||
|
|
||
| try { | ||
| auto analog_msg = std::make_unique<std_msgs::msg::UInt16MultiArray>(); | ||
|
|
||
| // Set up dimensions for the message | ||
| analog_msg->layout.dim.push_back(std_msgs::msg::MultiArrayDimension()); | ||
| analog_msg->layout.dim[0].label = "analog_pins"; | ||
| analog_msg->layout.dim[0].size = 6; | ||
| analog_msg->layout.dim[0].stride = 6; | ||
| analog_msg->layout.data_offset = 0; | ||
|
|
||
| // Initialize data array to hold 6 pin values | ||
| analog_msg->data.resize(6); | ||
|
|
||
| // Read values from all 6 analog pins (A0-A5) | ||
| analog_msg->data[0] = dxl_sdk_wrapper->get_data_from_device<uint16_t>( | ||
| extern_control_table.analog_a0.addr, | ||
| extern_control_table.analog_a0.length); | ||
| analog_msg->data[1] = dxl_sdk_wrapper->get_data_from_device<uint16_t>( | ||
| extern_control_table.analog_a1.addr, | ||
| extern_control_table.analog_a1.length); | ||
| analog_msg->data[2] = dxl_sdk_wrapper->get_data_from_device<uint16_t>( | ||
| extern_control_table.analog_a2.addr, | ||
| extern_control_table.analog_a2.length); | ||
| analog_msg->data[3] = dxl_sdk_wrapper->get_data_from_device<uint16_t>( | ||
| extern_control_table.analog_a3.addr, | ||
| extern_control_table.analog_a3.length); | ||
| analog_msg->data[4] = dxl_sdk_wrapper->get_data_from_device<uint16_t>( | ||
| extern_control_table.analog_a4.addr, | ||
| extern_control_table.analog_a4.length); | ||
| analog_msg->data[5] = dxl_sdk_wrapper->get_data_from_device<uint16_t>( | ||
| extern_control_table.analog_a5.addr, | ||
| extern_control_table.analog_a5.length); | ||
|
|
||
| // Publish the message | ||
| analog_publisher_->publish(std::move(analog_msg)); | ||
| } catch (const std::exception & e) { | ||
| RCLCPP_ERROR( | ||
| rclcpp::get_logger("analog_pins"), | ||
| "Exception in analog_pins publish: %s", e.what()); | ||
| } catch (...) { | ||
| RCLCPP_ERROR( | ||
| rclcpp::get_logger("analog_pins"), | ||
| "Unknown exception in analog_pins publish"); | ||
| } | ||
| } |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be beneficial to add a check to ensure that the
analog_a5.addris actually greater thananalog_a0.addrto prevent potential issues if the control table is not defined as expected. This could be done with anRCLCPP_ERRORand a return if the condition is not met.