-
Notifications
You must be signed in to change notification settings - Fork 113
Added Kalman Filter + Minor Motion Control Changes #3420
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
base: master
Are you sure you want to change the base?
Conversation
src/proto/tbots_software_msgs.proto
Outdated
map<uint32, Angle> robot_orientations = 5; | ||
|
||
uint64 sequence_number = 4; | ||
} |
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.
map<uint32, Angle> robot_orientations = 5; | |
uint64 sequence_number = 4; | |
} | |
uint64 sequence_number = 4; | |
map<uint32, Angle> robot_orientations = 5; | |
} |
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.
nice work cleaning this up, left a few more comments
{ | ||
if (!initialized_) | ||
{ | ||
return std::nullopt; |
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.
maybe we should have a LOG(INFO)
here telling people that the IMU is uninitialized
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.
bump @mkhlb
int ret = ioctl(file_descriptor_, I2C_SLAVE_FORCE, 0x6b); | ||
if (ret < 0) | ||
{ | ||
return std::nullopt; |
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.
Also LOG(INFO)
that this SPI operation failed
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.
bump @mkhlb
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.
changes to this file seem accidental
reserved 5; | ||
oneof primitive | ||
{ | ||
MovePrimitive move = 1; | ||
StopPrimitive stop = 2; | ||
DirectControlPrimitive direct_control = 3; | ||
} | ||
Angle orientation = 7; | ||
|
||
// Sequence number for the primitive | ||
uint64 sequence_number = 4; | ||
|
||
reserved 5; | ||
|
||
// Epoch timestamp when primitives were assigned | ||
Timestamp time_sent = 6; |
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.
nit: can you make these in order?
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.
looks good, some minor nits and it looks like you have some failing tests in CI
auto least_significant = | ||
int16_t(i2c_smbus_read_byte_data(file_descriptor_, YAW_LEAST_SIG_REG)); | ||
auto most_significant = | ||
int16_t(i2c_smbus_read_byte_data(file_descriptor_, YAW_MOST_SIG_REG)); | ||
|
||
|
||
auto foo = (int16_t)(most_significant << 8); | ||
auto full_word = foo + least_significant; |
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.
don't use auto
. Use the types directly. Especially when using bit shift operators, it becomes very difficult to predict how the number will get interpreted.
int16_t(i2c_smbus_read_byte_data(file_descriptor_, YAW_MOST_SIG_REG)); | ||
|
||
|
||
auto foo = (int16_t)(most_significant << 8); |
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.
auto foo = (int16_t)(most_significant << 8); | |
int16_t foo = static_cast<int16_t>(most_significant << 8); |
@@ -238,6 +247,10 @@ void Thunderloop::runLoop() | |||
// Save new primitive | |||
primitive_ = new_primitive; | |||
|
|||
auto orientation_msg = primitive_.orientation(); |
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.
avoid auto
unless it's a really long type name. It makes the code harder to read for newer members (especially since we have multiple "angle"-ish types in the codebase)
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.
left some comments
Please fill out the following before requesting review on this PR
Description
Many changes were done.
Implemented a kalman filter for thunderloop that composes IMU data to track robot position more accurately.
Testing Done
Moved robot
Tested IMU variance, got about 0.0019 deg variance, expected about 0.0016 deg.
Resolved Issues
Length Justification and Key Files to Review
Review Checklist
It is the reviewers responsibility to also make sure every item here has been covered
.h
file) should have a javadoc style comment at the start of them. For examples, see the functions defined inthunderbots/software/geom
. Similarly, all classes should have an associated Javadoc comment explaining the purpose of the class.TODO
(or similar) statements should either be completed or associated with a github issue