Skip to content

Commit

Permalink
Update basic programming
Browse files Browse the repository at this point in the history
  • Loading branch information
sciencewhiz committed Nov 25, 2024
1 parent 623b3d2 commit 038d81c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 26 deletions.
35 changes: 15 additions & 20 deletions source/docs/software/basic-programming/coordinate-system.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,14 @@ The code snippet below uses the ``DifferentialDrive`` and ``Joystick`` classes t
The code calls the ``DifferentialDrive.arcadeDrive(xSpeed, zRotation)`` method, with values it gets from the ``Joystick`` class:

- The first argument is ``xSpeed``

- Robot: ``xSpeed`` is the speed along the robot's X axis, which is forward/backward.
- Joystick: The driver sets forward/backward speed by rotating the joystick along its Y axis, which is pushing the joystick forward/backward.
- Code: Moving the joystick forward is negative Y rotation, whereas moving the robot forward is along the positive X axis. This means the joystick value needs to be inverted by placing a - (minus sign) in front of the value.
- Robot: ``xSpeed`` is the speed along the robot's X axis, which is forward/backward.
- Joystick: The driver sets forward/backward speed by rotating the joystick along its Y axis, which is pushing the joystick forward/backward.
- Code: Moving the joystick forward is negative Y rotation, whereas moving the robot forward is along the positive X axis. This means the joystick value needs to be inverted by placing a - (minus sign) in front of the value.

- The second argument is ``zRotation``

- Robot: ``zRotation`` is the speed of rotation along the robot's Z axis, which is rotating left/right.
- Joystick: The driver sets rotation speed by rotating the joystick along its X axis, which is pushing the joystick left/right.
- Code: Moving the joystick to the right is positive X rotation, whereas robot rotation is CCW positive. This means the joystick value needs to be inverted by placing a - (minus sign) in front of the value.
- Robot: ``zRotation`` is the speed of rotation along the robot's Z axis, which is rotating left/right.
- Joystick: The driver sets rotation speed by rotating the joystick along its X axis, which is pushing the joystick left/right.
- Code: Moving the joystick to the right is positive X rotation, whereas robot rotation is CCW positive. This means the joystick value needs to be inverted by placing a - (minus sign) in front of the value.

### Mecanum drivetrain example

Expand Down Expand Up @@ -133,23 +131,20 @@ Mecanum drivetrains are holonomic, meaning they have the ability to move side-to
The code calls the ``MecanumDrive.driveCartesian(xSpeed, ySpeed, zRotation)`` method, with values it gets from the ``Joystick`` class:

- The first argument is ``xSpeed``

- Robot: ``xSpeed`` is the speed along the robot's X axis, which is forward/backward.
- Joystick: The driver sets forward/backward speed by rotating the joystick along its Y axis, which is pushing the joystick forward/backward.
- Code: Moving the joystick forward is negative Y rotation, whereas robot forward is along the positive X axis. This means the joystick value needs to be inverted by placing a - (minus sign) in front of the value.
- Robot: ``xSpeed`` is the speed along the robot's X axis, which is forward/backward.
- Joystick: The driver sets forward/backward speed by rotating the joystick along its Y axis, which is pushing the joystick forward/backward.
- Code: Moving the joystick forward is negative Y rotation, whereas robot forward is along the positive X axis. This means the joystick value needs to be inverted by placing a - (minus sign) in front of the value.


- The second argument is ``ySpeed``

- Robot: ``ySpeed`` is the speed along the robot's Y axis, which is left/right.
- Joystick: The driver sets left/right speed by rotating the joystick along its X axis, which is pushing the joystick left/right.
- Code: Moving the joystick to the right is positive X rotation, whereas robot right is along the negative Y axis. This means the joystick value needs to be inverted by placing a - (minus sign) in front of the value.
- Robot: ``ySpeed`` is the speed along the robot's Y axis, which is left/right.
- Joystick: The driver sets left/right speed by rotating the joystick along its X axis, which is pushing the joystick left/right.
- Code: Moving the joystick to the right is positive X rotation, whereas robot right is along the negative Y axis. This means the joystick value needs to be inverted by placing a - (minus sign) in front of the value.

- The third argument is ``zRotation``

- Robot: ``zRotation`` is the speed of rotation along the robot's Z axis, which is rotating left/right.
- Joystick: The driver sets rotation speed by twisting the joystick along its Z axis, which is twisting the joystick left/right.
- Code: Twisting the joystick to the right is positive Z rotation, whereas robot rotation is CCW positive. This means the joystick value needs to be inverted by placing a - (minus sign) in front of the value.
- Robot: ``zRotation`` is the speed of rotation along the robot's Z axis, which is rotating left/right.
- Joystick: The driver sets rotation speed by twisting the joystick along its Z axis, which is twisting the joystick left/right.
- Code: Twisting the joystick to the right is positive Z rotation, whereas robot rotation is CCW positive. This means the joystick value needs to be inverted by placing a - (minus sign) in front of the value.

### Swerve drivetrain example

Expand Down
10 changes: 4 additions & 6 deletions source/docs/software/basic-programming/reading-stacktraces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ To start, search above the ``unexpected error has occurred`` for the stack trace
* The exception was a ``java.lang.NullPointerException``

* The error happened while running line ``24`` inside of ``Robot.java``

* ``robotInit`` was the name of the method executing when the error happened.

* ``robotInit`` is a function in the ``frc.robot.Robot`` package (AKA, your team's code)
Expand Down Expand Up @@ -100,7 +99,6 @@ To start, search above the ``unexpected error has occurred`` for the stack trace
* The reason it paused was one thread having an ``exception``

* The error happened while running line ``20`` inside of ``Robot.cpp``

* ``RobotInit`` was the name of the method executing when the error happened.

* ``RobotInit`` is a function in the ``Robot::`` namespace (AKA, your team's code)
Expand All @@ -123,8 +121,8 @@ Often, just looking in (or near) the problematic location in code will be fruitf

A key strategy for analyzing code is to ask the following questions:

* When was the last time the code "worked" (I.e., didn't have this particular error)?
* What has changed in the code between the last working version, and now?
* When was the last time the code "worked" (I.e., didn't have this particular error)?
* What has changed in the code between the last working version, and now?

Frequent testing and careful code changes help make this particular strategy more effective.

Expand All @@ -140,8 +138,8 @@ Sometimes, just looking at code isn't enough to spot the issue. The :ref:`single

If all else fails, you can seek out advice and help from others (both in-person and online). When working with folks who aren't familiar with your codebase, it's very important to provide the following information:

* Access to your source code, (EX: :ref:`on github.com <docs/software/basic-programming/git-getting-started:Git Version Control Introduction>`)
* The **full text** of the error, including the full stack trace.
* Access to your source code, (EX: :ref:`on github.com <docs/software/basic-programming/git-getting-started:Git Version Control Introduction>`)
* The **full text** of the error, including the full stack trace.

## Common Examples & Patterns

Expand Down

0 comments on commit 038d81c

Please sign in to comment.