Repository navigation
Propagate feedback and command errors through the ROS hardware interface #9
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cfea614
serialise multipart commands so concurrent callers cannot interleave …
justagist b0e020a
validate commands and propagate send failures from the hardware inter…
justagist ed5594a
report stale feedback as an error while active
justagist 2f3edbf
join the senders before asserting in the interleave test
justagist ff1167a
check the enable and gripper zero sends during activation
justagist 4de3f32
release the CAN session on error so the component can be reconfigured
justagist 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
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
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
41 changes: 41 additions & 0 deletions
41
piper_cpp_ros/include/piper_cpp_ros/command_conversion.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,41 @@ | ||
| #pragma once | ||
|
|
||
| #include <cmath> | ||
| #include <cstdint> | ||
| #include <optional> | ||
|
|
||
| namespace piper_cpp_ros | ||
| { | ||
|
|
||
| constexpr double kRadToMd = 1000.0 * 180.0 / M_PI; | ||
| constexpr double kMdToRad = 1.0 / kRadToMd; | ||
|
|
||
| // piper_cpp's high-speed feedback reports motor_speed in 0.001 rad/s and effort in 0.001 N*m. | ||
| constexpr double kMilliToUnit = 1.0e-3; | ||
|
|
||
| // Gripper feedback / command: jaw stroke is in 0.001 mm = micrometers (1 um = 1e-6 m). | ||
| constexpr double kUmToM = 1.0e-6; | ||
| constexpr double kMToUm = 1.0e6; | ||
|
|
||
| inline double mdToRad(int32_t md) { return static_cast<double>(md) * kMdToRad; } | ||
|
|
||
| /// Joint position command in rad to the arm's 0.001 deg units, or nullopt when the value is not | ||
| /// finite or lies beyond a full turn. Real joint limits are the controller's job; this only | ||
| /// refuses values that have no sensible wire representation. | ||
| inline std::optional<int32_t> jointCommandToMillideg(double rad) | ||
| { | ||
| if (!std::isfinite(rad) || std::fabs(rad) > 2.0 * M_PI) | ||
| return std::nullopt; | ||
| return static_cast<int32_t>(std::lround(rad * kRadToMd)); | ||
| } | ||
|
|
||
| /// Gripper stroke command in metres to micrometres, with the same acceptance rule; one metre | ||
| /// is far beyond any jaw. | ||
| inline std::optional<int32_t> gripperCommandToMicrometres(double m) | ||
| { | ||
| if (!std::isfinite(m) || std::fabs(m) > 1.0) | ||
| return std::nullopt; | ||
| return static_cast<int32_t>(std::lround(m * kMToUm)); | ||
| } | ||
|
|
||
| } // namespace piper_cpp_ros |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.