I’ve attached some code for a simulated gyroscope for a SwerveDrive. I’m looking for feedback .
I’ve been using the new fromDiscrete method for ChassisSpeeds and was expecting to use an elapsed time of 0.020s for drift reduction. I found that using 0.058s was benefitting us more. Being that this is all in the simulator I was wondering where the issue could be and I’m sure it’s probably in the simulated gyroscope.
The issue being that I’m using roughly 3 times the frame rate for drift reduction. This could be another issue, but I think all of my modules are in good shape. SwerveGyrocopeSim.java (2.4 KB)
JSON is a weird format to use for that. CSV is more straightforward.
#!/usr/bin/env python3
import csv
import matplotlib.pyplot as plt
x = []
y = []
with open("xy.csv") as f:
for row in csv.reader(f, delimiter=","):
x.append(row[0])
y.append(row[1])
plt.plot(x, y)
plt.xlabel("x position (m)")
plt.ylabel("y position (m)")
plt.show()
AdvantageScope might also support the plots you need, but I haven’t used the tool.
AdvantageScope 3D Field tab shows a robot pose through Network Tables and similarly the Odometry tab shows a top-down 2D Field. I use the 3D a lot but haven’t used the 2D yet.
I tried AdvantageScope Odometry tab now and it shows a robot pose in 2-D (or 3-D). It isn’t a true X-Y plot as it is intended to show just one point - the current pose of the robot. For the trajectory option it does show a few seconds of a “comet tail” following the robot but that isn’t much of a history if that’s what you need. The 3D Field tab shows the current pose of the robot in 3-D, of course.
AdvantageScope is a standalone program that you install on a PC. It easily connects to your robot’s Network Tables where it gets the robot pose data that you have to publish from your robot.
I hacked up some code to try this out. If you are still interested (since it lacks the historical aspect of a true X-Y plot) I can repost my changes back into Github.
Maybe! If you mean the left side of AdvantageScope doesn’t show all the names that are supposedly in your network table then verify those names show in a WPILib tool such as OutlineViewer. My AdvantageScope list of fields matches my Outline Viewer. I have no special troubleshooting skills if the lists of fields don’t match.
If you see the SmartDashboard table and your fields but they don’t drag or don’t show on a line graph that’s also a problem I don’t have and don’t know how to troubleshoot.
For the Odometry tab and the 3D Field tab the poses have to been in particular formats as documented in AdvantageScope.
The Odometry must be a 3 element array for X, Y, Theta.
The 3D Field must be a 7 element array for X, Y, Z, quaternion W,X,Y,Z (I think, didn’t check my memory and I’m called to eat a few minutes ago).
Make sure to click “File” > “Connect to Robot/Simulator”. Unlike the WPILib tools, AdvantageScope does not connect to NT automatically since it supports viewing both live data and log files. If you’re having other issues I can try to help diagnose.
Thanks for all of the information. I will try and put it to good use.
I just realized something. Though. I’m really stupid apparently. I was just expecting the number to show in a drop down like the sims dashboard. I wasn’t dragging into the right place