-
Notifications
You must be signed in to change notification settings - Fork 2
Bugfix/imu angle #13
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
Bugfix/imu angle #13
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8c17a95
Fix: double time = seconds + nanoseconds -> nanoseconds
1000lai 7cad5f9
Fix: prevent repeated wheel delta integration in imu callback
1000lai 4be3368
Fix: delete unused things
1000lai b6a1d02
Merge branch 'develop' into bugfix/imu-angle
yjHuang251 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 |
|---|---|---|
|
|
@@ -15,8 +15,6 @@ WioNode::WioNode() : Node("wio_node"){ | |
| for(int i=0; i<3; i++) this->pose_cov_min[i] = 0; | ||
| this->first_odom_cb = true; | ||
| this->prev_odom_time = 0.0; | ||
| this->prev_wheel_pose.setZero(); | ||
| this->d_position.setZero(); | ||
| this->local_pose.setZero(); | ||
| this->local_twist.setZero(); | ||
| this->local_pose_cov.setIdentity(); | ||
|
|
@@ -77,11 +75,10 @@ void WioNode::wheelCallback(const geometry_msgs::msg::Twist & wheel_msg) | |
| { | ||
| rclcpp::Clock clock; | ||
| rclcpp::Time stamp = clock.now(); | ||
| double odom_time = stamp.seconds() + stamp.nanoseconds() * 1e-9; | ||
|
|
||
| double odom_time = stamp.nanoseconds() * 1e-9; | ||
| if (this->first_odom_cb) | ||
| { | ||
| this->prev_wheel_pose << wheel_msg.angular.x, wheel_msg.angular.y, 0.0; | ||
| this->prev_odom_time = odom_time; | ||
| this->first_odom_cb = false; | ||
| return; | ||
|
|
@@ -90,13 +87,6 @@ void WioNode::wheelCallback(const geometry_msgs::msg::Twist & wheel_msg) | |
| double dt = odom_time - this->prev_odom_time; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also replace all the variables from odom to wheel. the reason is that odometry is a method which calculates relative pose tracking and is not limited to wheel information. |
||
| this->prev_odom_time = odom_time; | ||
|
|
||
|
|
||
| this->d_position << wheel_msg.angular.x-this->prev_wheel_pose(0), | ||
| wheel_msg.angular.y-this->prev_wheel_pose(1), | ||
| 0.0; | ||
|
|
||
| this->prev_wheel_pose << wheel_msg.angular.x, wheel_msg.angular.y, 0.0; | ||
|
|
||
| this->local_twist(0) = wheel_msg.linear.x; | ||
| this->local_twist(1) = wheel_msg.linear.y; | ||
|
|
||
|
|
@@ -115,7 +105,7 @@ void WioNode::wheelCallback(const geometry_msgs::msg::Twist & wheel_msg) | |
| void WioNode::imuCallback(const sensor_msgs::msg::Imu & imu_msg) | ||
| { | ||
| rclcpp::Time stamp = imu_msg.header.stamp; | ||
| double time = stamp.seconds()+stamp.nanoseconds()*1e-9; | ||
| double time = stamp.nanoseconds()*1e-9; | ||
|
|
||
| if(this->first_imu_cb){ | ||
| this->prev_imu_time = time; | ||
|
|
@@ -126,18 +116,17 @@ void WioNode::imuCallback(const sensor_msgs::msg::Imu & imu_msg) | |
| double dt = time-this->prev_imu_time; | ||
| this->prev_imu_time = time; | ||
|
|
||
|
|
||
| this->local_twist(2) = imu_msg.angular_velocity.z; | ||
|
|
||
| this->local_pose(2) = | ||
| utils::angleNormalizing(this->local_pose(2)+0.5*this->local_twist(2)*dt); | ||
| utils::angleNormalizing(this->local_pose(2)+this->local_twist(2)*dt); | ||
|
|
||
| Eigen::Matrix3d R; | ||
| R << cos(this->local_pose(2)), -sin(this->local_pose(2)), 0.0, | ||
| sin(this->local_pose(2)), cos(this->local_pose(2)), 0.0, | ||
| 0.0, 0.0, 0.0; | ||
|
|
||
| this->local_pose += R*this->d_position; | ||
| this->local_pose += R*this->local_twist*dt; | ||
|
|
||
| // publish odometry | ||
| pubLocalPose(stamp); | ||
|
|
||
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's in wheel callback so actually the variable name should be
wheel_time