Skip to content
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

Programming Advantagescope logging #14

Open
lchangGH opened this issue Jan 20, 2024 · 4 comments
Open

Programming Advantagescope logging #14

lchangGH opened this issue Jan 20, 2024 · 4 comments
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@lchangGH
Copy link
Contributor

No description provided.

@LuisFerArredondo
Copy link
Contributor

LuisFerArredondo commented Jan 25, 2024

AdvantageKit is a logging, telemetry, and replay framework developed by Team 6328. AdvantageKit enables log replay, where the full state of the robot code can be replayed in simulation based on a log file.

A variety of logging frameworks already exist in FRC, from built-in tools like the Driver Station and WPILib logging all the way to fully custom solutions. Most of these frameworks follow a similar structure, which looks this:

Image

A limited set of values are provided by the robot code and stored in the log. That could include sensor data, PID error, odometry pose, output commands, etc. While this has enormous value, it doesn't solve the eternal sentiment when something goes wrong: "If only we were logging one extra field!" Notice above that there is data flowing in and out of the robot code without being saved to the log file.

AdvantageKit takes a different approach. This is what logging looks like with AdvantageKit:

Image

Instead of logging a limited set of values from the user code, AdvantageKit records all of the data flowing into the robot code. Every sensor value, button press, and much more is logged every loop cycle. After a match, these values can be replayed to the robot code in a simulator. Since every input command is the same, all of the internal logic of the code is replayed exactly. This allows you to log extra fields after the fact, or modify pipelines to see how they would have functioned during the match. This technique means that logging is more than just a tool for checking on specific issues; it's also a safety net that can be used to verify how any part of the code functions.

In other words, we could replay the original logs, along with a new log file generated, which is based on the code that was used in that moment but with the new data generated. When replaying the logs we should not change the behavior of the robot, but we can log new values based on the ones we already have, and see how they would have behaved in that moment.

Code example: Now with advantage kit working
https://github.com/LuisFerArredondo/2706_2024.git

@LuisFerArredondo
Copy link
Contributor

Something to point out, is that we would be required to have a USB stick on the RoboRIO's USB port so the code could be logged with advantage kit.

@LuisFerArredondo
Copy link
Contributor

Also another comment on this. If we want to log the battery, Network Table Clients, current commands, etc. We have to add that code manually.

Fortunate enough, out friends from Mechanical Advantage already did that, so we just have to write a similar code(the exact same) of what they have in theirs, but in ours.

@LuisFerArredondo LuisFerArredondo added documentation Improvements or additions to documentation enhancement New feature or request labels Jan 30, 2024
@LuisFerArredondo
Copy link
Contributor

To be implement it into the code, the recommended way is:

  1. For each mechanism, there should be 3 types of files:
  • The high level programming file(Here the callout of the Logger will occur)
  • The IO Layer, which is the bridge of communication between the high level programming file and the hardware/simulator files
  • The hardware/simulator file
  1. In the "RobotContainer" is where we will define whether is simulation, real or replay, so the mechanism knows which file to use
  2. The Logger and Log writing must be set up in the "Robot" file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants