Skip to content

Curriculum challenge ~ Moving to a target position

Tom Blank edited this page Apr 14, 2024 · 12 revisions

Here we have an autonomous mode for the robot that requires it to drive forward to a very specific position at the start of the match (into a small scoring area). This is a very common challenge in FRC games. In order to help with this, we have a distance sensor that you can read that will tell you how far you've traveled since the start of the match.

This will be one of the first challenges that require you to write a slightly more complicated command!

  • Command: /XbotEdu/src/main/java/competition/subsystems/drive/commands/DriveToPositionCommand.java
  • Unit test: /XbotEdu/src/test/java/xbot.edubot/linear/commands/DriveToPositionCommandTest.java
In order to get the current distance that your robot has traveled you can do pose.getPosition() using the distanceSensor on the PoseSubsystem. This sensor starts at 0 at the beginning of the match and will track how far the robot has moved forwards/backwards in total.

note: It's important to understand the physical aspects of the robot being programmed.

note: The robot keeps going even after the no more power is applied to the motor (because of momentum)! To stop the robot: power must be applied in reverse. This is a feature of the electric motors used in the robot. If the robot had brakes these could be applied instead.

I suggest that you think through the problem yourself for a few minutes and try some attempts on your own. After you've experimented a bit, watch this video: https://www.youtube.com/watch?v=4Y7zG48uHRo

Graphical Tests!

Unlike the earlier challenges, we have a nice visualizer that's easier to read/understand than reading hundreds of log statements. With this tool you can visualize the position of the virtual robot as your code is running. The blue dot is where your robot is and the red dot is your target.

To run it on IntelliJ, find the run target selector at the top of the window and select LinearTestVisualizer. Click the green Run arrow next to the drop-down menu.

When the window opens, you can use the slider on the right hand side to control the simulation speed.

Leaderboards

After doing the Position challenge, write down your fastest times here!

Name Number Of Loops
Nathan Louie 299
Andy Khuu 68
Zoe 22
Vincent Liu 22
Charlotte 18
Gabriel Young 18
Kaelin 17
Issa Mathno 16
Jeremy Huang 16
John Li 15
Johnny Wu 15
Thanh Ly 15
Zilong Zeng 15
Christian Estrella 15
Judy Fu 15
Winston Bullen 15
Jian Fu Chen 14
Mohamed Abdulsemed 14

Next Steps

Continue with the next curriculum challenge: Rotating to a target orientation



              
Clone this wiki locally