-
Notifications
You must be signed in to change notification settings - Fork 45
Curriculum challenge ~ Rotating to a target orientation
In this challenge we're going to rotate the robot to a target orientation. This is a very common thing we need to do autonomously during competition, for example to point at a goal to shoot balls into it.
Read this to understand how we define rotation: Rotation and Position ~ Robot Coordinate Conventions
You'll need to know this to complete this challenge.
Like the previous challenge, we have a nice visualizer that's easier to read/understand than reading hundreds of log statements.
You can visualize the rotation of the virtual robot as your code is running using the visualization utility. To run it on IntelliJ, find the "RotationTestVisuallizer" run configuration at the top of the window, and run it. When the window opens, select the test you are working on to start the simulation.
- The yellow line represents your robot's current orientation (initial position, and will remain yellow if the robot isn't moving. It will turn into a black line when the robot starts moving)
- The black line represents your robot's current orientation
- The pink line represents the goal
- The bar in the middle of the black line represents your robot's current rotational speed
- The bar on the outside of the black line represents your robot's current rotational power
The goal is to write a command that will rotate the robot 90 degrees to the left as quickly as possible, and then end.
- Command: \XbotEdu\src\main\java\competition\subsystems\drive\commands\TurnLeft90DegreesCommand.java
- Unit test: \XbotEdu\test\java\xbot\edubot\rotation\TurnLeft90DegreesCommand.java
- Visualizer Test: \XbotEdu\test\java\xbot\edubot\rotation\RotationTestVisualizer.java
getCurrentHeading().getDegrees()
in the PoseSubystem
to figure out where you are pointing.
Hint: The pose.getCurrentHeading().getDegrees()
is relative to the field and returns a value from -180 to 180 degrees.
Real World: A real robots absolute heading is not known with absolute certainty and the value relative to the field degrades with time.
Now that you have your basic 90 degree turn working, we're going to expand upon that with a more complicated command that will rotate the robot to an arbitrary heading, starting from any arbitrary heading - and do it as fast as possible!
This will involve handling some trickier cases with respect to angles around a circle.
- Command: /EduBot/src/xbot.edubot.subsystems.drive.commands/DriveToOrientationCommand.java
- Unit test: /EduBot/tests/xbot.edubot.rotation/GoToOrientationTest.java
Congratulations on making it this far! You now know a lot of the concepts you need to program a basic robot.
Next we'll level up your current code solutions using some powerful library features the team has built up, but first you need to learn about some of the techniques we use: Learning about Factories
- Home
- Challenges
- Setting up your environment
- Basic Robot Principles
- Tank Drive
- Altering Tank Drive
- Moving to a target position
- Rotating to a target orientation
- Factories
- The Power of Injection
- Dependency Injection with Dagger
- Upgrading Using the SeriouslyCommonLib
- Running XbotEDU on a Real Robot
- Auto Stopping Collector