You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/programming/driving_robot.md
+44-48Lines changed: 44 additions & 48 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -511,18 +511,6 @@ Now it’s time to make an arcadeDrive from our differentialDrive!
511
511
512
512
## Making our robot controllable
513
513
514
-
### Creating the Joystick
515
-
516
-
In order to drive our robot, it needs to know what will be controlling it. To do so, we will create a new joystick in RobotContainer.java, and an operator constant for the joystick port.
517
-
518
-
!!! summary ""
519
-
**1)** Open Constants.java
520
-
Check and make sure the `kDriverControllerPort` constant is present.
521
-
**2)** Open RobotContainer.java
522
-
- Change all `ExampleSubsystem` references to `DriveSubsystem`
523
-
524
-
<!-- TODO: add details on how to find joystick port in driverstation tips -->
525
-
526
514
### Creating the Drivearcade Command
527
515
528
516
- Remember that **methods** tell the robot what it can do but in order to make it do these things we must give it a **command**. See [Command Based Robot](../basics/wpilib.md#command-based-robot){target=_blank}
@@ -553,7 +541,7 @@ Before we begin we must create the class file for the DriveArcade command. See [
553
541
#### In the constructor
554
542
555
543
!!! summary ""
556
-
**1)** Inside the parenthesis of the the constructor `#!java DriveArcade()` add 3 variables:
544
+
**1)** Inside the parenthesis of the the constructor `driveArcade()` add 3 variables:
@@ -585,7 +573,6 @@ Before we begin we must create the class file for the DriveArcade command. See [
585
573
#### In the execute method
586
574
587
575
!!! summary ""
588
-
!!! summary ""
589
576
**1)** In the execute method we will we want to call the **arcadeDrive** method we created in **Drivetrain** and give it the variables **moveSpeed**`xspeed` and **rotateSpeed**`zrotation` we created as parameters.
590
577
591
578
In the execute() method below rotateSpeed type:
@@ -700,54 +687,58 @@ Since we will be using this command to control the robot we want it to run indef
700
687
```
701
688
</details>
702
689
703
-
### Connecting the Joystick
704
-
- In RobotContainer We will now add the code to take the joystick inputs and use them to move the robot.
690
+
### Creating the Joystick
705
691
706
-
!!! summary ""
707
-
The joystick code goes inside the `configureBindings()` method.
708
-
- We will the default command for the drive subsystem to an instance of the DriveCommand with the values provided by the joystick axes on the driver controller.
709
-
- The Y axis of the controller is inverted so that pushing the stick away from you (a negative value) drives the robot forwards (a positive value).
710
-
- Similarly for the X axis where we need to flip the value so the joystick matches the WPILib convention of counter-clockwise positive
692
+
In order to drive our robot, it needs to know what will be controlling it. To do so, we will use the joystick in `RobotContainer.java`, as `m_drivecontroller`.
711
693
712
-
694
+
!!! summary ""
695
+
**1)** Open Constants.java
696
+
Check and make sure the `kDriverControllerPort` constant is present.
697
+
**2)** Open RobotContainer.java
698
+
- Change all `ExampleSubsystem` references to `DriveSubsystem`
<!-- TODO: add details on how to find joystick port in driverstation tips -->
721
701
722
702
### Using setDefaultCommand
723
703
724
-
- Commands passed to this method will run when the robot is enabled.
725
-
- They also run if no other commands using the subsystem are running.
726
-
- This is why we write **addRequirements(Robot.m_subsystemName)** in the commands we create, it ends currently running commands using that subsystem to allow a new command is run.
727
704
728
705
!!! summary ""
729
-
**1)** Back in **RobotContainer.java** in the constructor we will call the `setDefaultCommand` of `m_drivetrain` and pass it the `DriveArcade` command
**1)** Back in **RobotContainer.java** We will need to remove everything inside the `configureBindings` method.
707
+
**2)** in the `configureBindings`we will call the `setDefaultCommand` of `m_drivetrain` and create a new `DriveArcade` command with parameters.
708
+
709
+
- Commands in this method will run when the robot is enabled.
710
+
- They also run if no other commands using the subsystem are running.
711
+
- This is why we write **addRequirements(Robot.m_subsystemName)** in the commands we create, it ends currently running commands using that subsystem to allow a new command is run.
712
+
- We will the default command for the drive subsystem to an instance of the `DriveArcade` with the values provided by the joystick axes on the driver controller.
713
+
- The Y axis of the controller is inverted so that pushing the stick away from you (a negative value) drives the robot forwards (a positive value).
714
+
- Similarly for the X axis where we need to flip the value so the joystick matches the WPILib convention of counter-clockwise positive
0 commit comments