My team is looking into simulating our entire robot using advantage scope, and I am the one who is in charge of the project.
I managed to get the drivetrain working almost perfectly, but I am having a really hard time moving around articulated parts using the code(they move when I change their position/rotation values in the config file), and I feel like the WPI and advantage scope docs are lacking a lot of info specifically on this topic. Is there any docs/ppts teams have created that can help me understand better? Or even working code that I can reverse engineer?
3 Likes
I’d personally first look to getting a few things going first:
- A WPILib based mechanism simulation first, so you have values to feed advantagescope for visualization. AScope is ultimately nothing more than a tool that’ll displays the values you give it, it has no inherent simulation capabilities. You can also visualize with a Mechanism2D for this.
- For our arm, we used
SingleJointedArmSim
and more or less just fed it our voltage controls and used its’ angle in our Arm class. You might want to separate out the simulation bits, but we chose not to. - For every other motor on the robot (that pretty much just spun at a certain speed until something happened), we used
FlywheelSim
. - You can more or less just give the WPILib simulation classes your feedforward constants from sysid and your gear ratio and they more or less just work.
- For our arm, we used
- Once you have that going, and you have an AdvantageScope robot model, you just need to publish an array of Transform3ds that defines the position of each of the moving (non-drivetrain) components of your robot. In our case, it was just our arm. (Positioning the note when it was inside the robot proved challenging, so maybe ignore that code, though. And the other 90% of the class is actually for visualizing a fairly complex Mechanism2D). Do note that the offset you specify in the config is ignored the second you start using the ComponentPoses array (those are meant to just be defaults so the robot looks reasonable when you don’t have ComponentPoses setup), so you need to include the offset in your code too. I’d like to also note that we never did get the arm rotating with the correct axis of rotation, so if you have something that rotates you’re going to have to play around a lot with getting that working.
Our robot model is available here.
2 Likes