Skip to content

Commit b336dc1

Browse files
committed
Merge branch 'fix-digi-documents'
2 parents 6d6d6ac + 0a8337a commit b336dc1

49 files changed

Lines changed: 18406 additions & 18807 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,8 @@
1818
npm-debug.log*
1919
yarn-debug.log*
2020
yarn-error.log*
21+
22+
# IDEs
23+
.docusaurus
24+
.idea
25+
.vscode
File renamed without changes.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"label": "Tutorial - Extras",
2+
"label": "Controllers",
33
"position": 3,
44
"link": {
55
"type": "generated-index"
66
}
7-
}
7+
}

docs/controllers/feedback.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# Feedback
6+
7+
TODO

docs/controllers/feedforward.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
sidebar_position: 2
3+
---
4+
5+
# Feedforward
6+
7+
TODO

docs/getting-started.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# Getting Started
6+
TODO

docs/tutorials/1_drivetrain.mdx

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# 1 - Drivetrain Chassis
6+
7+
## Initialization
8+
9+
```cpp
10+
// Define SmartMotorGroups for left and right motors
11+
SmartMotorGroup leftMotors = SmartMotorGroup("LeftMotors", {1, -2, 3, -4});
12+
SmartMotorGroup rightMotors = SmartMotorGroup("RightMotors", {-5, 6, -7, 8});
13+
14+
// Create a TankChassis using the defined motor groups
15+
TankChassis chassis = TankChassis(leftMotors, rightMotors);
16+
```
17+
18+
### Usage
19+
20+
import Tabs from '@theme/Tabs';
21+
import TabItem from '@theme/TabItem';
22+
23+
<Tabs>
24+
<TabItem value="arcade" label="Arcade" default>
25+
Arcade controls allow the robot to be driven using a horizontal and vertical joystick input.
26+
27+
```cpp
28+
// Initialize the main controller
29+
pros::Controller mainController = pros::Controller(pros::E_CONTROLLER_MASTER);
30+
31+
// Operator control function
32+
void opcontrol() {
33+
34+
// Infinite loop for operator control
35+
while (true) {
36+
37+
// Read joystick values from the main controller
38+
double leftY = mainController.get_analog(ANALOG_LEFT_Y);
39+
double rightX = mainController.get_analog(ANALOG_RIGHT_X);
40+
41+
// Normalize to [-1.0, 1.0]
42+
leftY /= 127.0;
43+
rightX /= 127.0;
44+
45+
// Move chassis based on joystick inputs
46+
chassis.move(
47+
leftY, // Forward/backward speed [-1.0 to 1.0]
48+
rightX // Turning speed [-1.0 to 1.0]
49+
);
50+
51+
// Delay to prevent the CPU from being overloaded
52+
pros::delay(20);
53+
}
54+
}
55+
```
56+
</TabItem>
57+
<TabItem value="tank" label="Tank" default>
58+
Tank controls allow the robot to be driven using two separate joystick inputs for the left and right sides.
59+
60+
```cpp
61+
// Initialize the main controller
62+
pros::Controller mainController = pros::Controller(pros::E_CONTROLLER_MASTER);
63+
64+
// Operator control function
65+
void opcontrol() {
66+
67+
// Infinite loop for operator control
68+
while (true) {
69+
70+
// Read joystick values from the main controller
71+
double leftY = mainController.get_analog(ANALOG_LEFT_Y);
72+
double rightY = mainController.get_analog(ANALOG_RIGHT_Y);
73+
74+
// Normalize to [-1.0, 1.0]
75+
leftY /= 127.0;
76+
rightY /= 127.0;
77+
78+
// Move chassis based on joystick inputs
79+
chassis.moveTank(
80+
leftY, // Left Forward/backward speed [-1.0 to 1.0]
81+
rightY // Right Forward/backward speed [-1.0 to 1.0]
82+
);
83+
84+
// Delay to prevent the CPU from being overloaded
85+
pros::delay(20);
86+
}
87+
}
88+
```
89+
</TabItem>
90+
</Tabs>
91+
92+
## Configuration
93+
94+
### Brake Mode
95+
96+
By default, `SmartMotorGroup` motors are set to `coast` mode after they are passed into a `TankChassis`.
97+
While this is configurable, it is **highly recommended** to keep the drivetrain motors in `coast` mode to prevent Smart Motors from overheating during matches.
98+
99+
```cpp
100+
void initialize() {
101+
// Enable brake mode on drivetrain motors
102+
// DO NOT do this unless you know what you are doing!
103+
leftMotors.setBrakeMode(true);
104+
rightMotors.setBrakeMode(true);
105+
106+
// ...
107+
}
108+
```

docs/tutorials/2_odometry.mdx

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
---
2+
sidebar_position: 2
3+
---
4+
5+
# 2 - Odometry
6+
7+
## Initialization
8+
9+
import Tabs from '@theme/Tabs';
10+
import TabItem from '@theme/TabItem';
11+
12+
<Tabs groupId="odometry-type">
13+
14+
<TabItem value="perpendicular" label="Perpendicular" default>
15+
```cpp
16+
// Define rotation sensors for odometry wheels
17+
RotationSensor verticalOdomWheel = RotationSensor("VerticalOdomWheel", 10);
18+
RotationSensor horizontalOdomWheel = RotationSensor("HorizontalOdomWheel", 11);
19+
20+
// Define the radius of the dead wheels (in inches)
21+
static constexpr double DEAD_WHEEL_RADIUS = 1.0; // in
22+
23+
// Create a perpendicular sensor odometry object
24+
// (Since PerpendicularSensorOdometry is an AsyncTask, we must use a shared pointer)
25+
PerpendicularSensorOdometry odometry = PerpendicularSensorOdometry(
26+
verticalOdomWheel,
27+
horizontalOdomWheel,
28+
DEAD_WHEEL_RADIUS
29+
);
30+
31+
// Run odometry in a background task
32+
void initialize() {
33+
odometry.start();
34+
}
35+
```
36+
</TabItem>
37+
38+
<TabItem value="parallel" label="Parallel">
39+
```cpp
40+
// Define rotation sensors for odometry wheels
41+
RotationSensor leftOdomWheel = RotationSensor("LeftOdomWheel", 10);
42+
RotationSensor rightOdomWheel = RotationSensor("RightOdomWheel", 11);
43+
44+
// Define the radius of the dead wheels (in inches)
45+
static constexpr double DEAD_WHEEL_RADIUS = 1.0; // in
46+
47+
// Define the distance between the left and right odometry wheels (in inches)
48+
static constexpr double DEAD_WHEEL_BASE = 12.0; // in
49+
50+
// Create a parallel sensor odometry object
51+
// (Since ParallelSensorOdometry is an AsyncTask, we must use a shared pointer)
52+
std::shared_ptr<ParallelSensorOdometry> odometry = std::make_shared<ParallelSensorOdometry>(
53+
leftOdomWheel,
54+
rightOdomWheel,
55+
DEAD_WHEEL_RADIUS,
56+
DEAD_WHEEL_BASE
57+
);
58+
59+
// Run odometry in a background task
60+
void initialize() {
61+
odometry.start();
62+
}
63+
```
64+
</TabItem>
65+
</Tabs>
66+
67+
## Usage
68+
69+
Odometry provides the current heading and position of the robot on the field as a `Pose` object.
70+
The `Pose` provides `x` and `y` coordinates (in inches) representing the robot's position, as well as a `heading` (in degrees) representing the robot's orientation.
71+
72+
```cpp
73+
void opcontrol() {
74+
while (true) {
75+
// Get the current pose of the robot
76+
Pose pose = odometry.getPose();
77+
std::cout << "X: " << pose.x << " Y: " << pose.y << " Heading: " << pose.heading << std::endl;
78+
79+
// Example: Resetting the robot's pose when a button is pressed
80+
bool resetPose = mainController.get_digital(DIGITAL_A);
81+
if (resetPose)
82+
odometry.setPose(Pose(0, 0, 0));
83+
84+
// ...
85+
}
86+
}
87+
```
88+
89+
## Configuration
90+
91+
### Inertial Sensor
92+
93+
An Inertial Sensor (IMU) can be used to improve the accuracy of odometry calculations by providing accurate orientation data that drifts significantly less over time.
94+
While optional, it is **highly recommended** to use an IMU for the best performance.
95+
96+
```cpp
97+
// Define the Inertial Sensor
98+
InertialSensor imu = InertialSensor("IMU", 15);
99+
100+
void initialize() {
101+
// Use the IMU for odometry calculations
102+
odometry.useIMU(&imu);
103+
104+
// ...
105+
}
106+
```
107+
108+
### Rotational Compensation
109+
110+
<Tabs groupId="odometry-type">
111+
112+
<TabItem value="perpendicular" label="Perpendicular" default>
113+
When the robot rotates, the perpendicular orientation of the odometry wheels can inadvertently cause lateral movement readings.
114+
To correct for this, you can set the offsets of the odometry sensors relative to the robot's center of rotation.
115+
116+
These are defined as `Vector2` objects, where the x-coordinate represents the horizontal offset (left/right) and the y-coordinate represents the vertical offset (forward/backward).
117+
118+
:::note
119+
You may have to manually tune these values based on the position and grip of your odometry wheels.
120+
:::
121+
122+
```cpp
123+
// Offset values for the odometry sensors, relative to the robot's center of rotation (in inches)
124+
Vector2 verticalSensorOffset = Vector2(-0.5, 0); // (Y position is disregarded)
125+
Vector2 horizontalSensorOffset = Vector2(0, 1); // (X position is disregarded)
126+
127+
void initialize() {
128+
// Apply the offsets for odometry calculations
129+
odometry.setSensorOffsets(verticalSensorOffset, horizontalSensorOffset);
130+
131+
// ...
132+
}
133+
134+
```
135+
</TabItem>
136+
137+
<TabItem value="parallel" label="Parallel">
138+
:::tip[You don't need this with Parallel Odom Wheels]
139+
Rotational compensation is not required for Parallel Sensor Odometry since the odometry wheels will not produce inadvertent lateral movement readings when the robot rotates.
140+
:::
141+
</TabItem>
142+
</Tabs>

docs/tutorials/3_autosteps.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
sidebar_position: 3
3+
---
4+
5+
# 3 - AutoSteps
6+
7+
TODO

docs/tutorials/_category_.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"label": "Tutorials",
3+
"position": 2,
4+
"link": {
5+
"type": "generated-index"
6+
}
7+
}

0 commit comments

Comments
 (0)