-
Notifications
You must be signed in to change notification settings - Fork 9
Encoder Odometry #78
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
concavegit
wants to merge
8
commits into
master
Choose a base branch
from
encodom
base: master
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.
+67
−1
Open
Encoder Odometry #78
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
33c2406
Add skeleton encoder odometry broadcaster
concavegit 589b148
Complete encoder odometry implementation
concavegit 4b910ce
Multiply by RPY instead
concavegit 090cb6e
Comment the DiffDrive message
concavegit 67c3cb5
Use enc_link as base and actually accumulate translation
concavegit 1377be7
Use tf2_ros for static transform
concavegit 1a30cb3
Depend on tf2_ros
concavegit cbe3921
merging master into this branch
nathanestill 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # This represents the distance between the two wheels | ||
| float64 wheelbase | ||
| float64 rvel | ||
| float64 lvel | ||
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,38 @@ | ||
| #include "EncOdom.h" | ||
| #include <tf2_geometry_msgs/tf2_geometry_msgs.h> | ||
|
|
||
| EncOdom::EncOdom() | ||
| : sub(nh.subscribe("diffdrive_raw", 100, &EncOdom::callback, this)) | ||
| , then(ros::Time::now()) | ||
| { | ||
| transformStamped.header.frame_id = "odom"; | ||
| transformStamped.child_frame_id = "enc_link"; | ||
| } | ||
|
|
||
| void EncOdom::callback(const gravl::DiffDrive::ConstPtr& msg) | ||
| { | ||
| const auto now = ros::Time::now(); | ||
| const auto angularVel = (msg->rvel - msg->lvel) / msg->wheelbase; | ||
| const auto tangentialVel = (msg->rvel + msg->lvel) / 2; | ||
| const auto dt = (now - then).toSec(); | ||
|
|
||
| tf2::Quaternion oldOrientation; | ||
| tf2::convert(transformStamped.transform.rotation, oldOrientation); | ||
| const auto newOrientation = oldOrientation * tf2::Vector3(0, 0, angularVel * dt); | ||
| tf2::convert(newOrientation, transformStamped.transform.rotation); | ||
|
|
||
| tf2::Vector3 oldTranslation; | ||
| tf2::convert(transformStamped.transform.translation, oldTranslation); | ||
| const auto deltaPosition = tf2::quatRotate(newOrientation, tf2::Vector3(0, 0, tangentialVel * dt)); | ||
| tf2::convert(oldTranslation + deltaPosition, transformStamped.transform.translation); | ||
|
|
||
| br.sendTransform(transformStamped); | ||
| then = now; | ||
| } | ||
|
|
||
| int main(int argc, char** argv) | ||
| { | ||
| ros::init(argc, argv, "enc_odom"); | ||
| EncOdom encOdom; | ||
| ros::spin(); | ||
| } |
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,19 @@ | ||
| #pragma once | ||
|
|
||
| #include <gravl/DiffDrive.h> | ||
| #include <tf2_ros/transform_broadcaster.h> | ||
|
|
||
| class EncOdom | ||
| { | ||
| public: | ||
| EncOdom(); | ||
|
|
||
| private: | ||
| void callback(const gravl::DiffDrive::ConstPtr& msg); | ||
|
|
||
| ros::NodeHandle nh; | ||
| tf2_ros::TransformBroadcaster br; | ||
| ros::Subscriber sub; | ||
| geometry_msgs::TransformStamped transformStamped; | ||
| ros::Time then; | ||
| }; |
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.
Tell me what this is