Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions my-website/.gitignore → .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Dependencies
/node_modules
/my-website/node_modules

# Production
/build
my-website/build

# Generated files
.docusaurus
Expand All @@ -18,3 +18,7 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# IDEs and editors
.vscode/
.idea/
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"label": "Tutorial - Extras",
"label": "Controllers",
"position": 3,
"link": {
"type": "generated-index"
}
}
}
7 changes: 7 additions & 0 deletions docs/controllers/feedback.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
sidebar_position: 1
---

# Feedback

TODO
7 changes: 7 additions & 0 deletions docs/controllers/feedforward.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
sidebar_position: 2
---

# Feedforward

TODO
6 changes: 6 additions & 0 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
sidebar_position: 1
---

# Getting Started
TODO
108 changes: 108 additions & 0 deletions docs/tutorials/1_drivetrain.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
sidebar_position: 1
---

# 1 - Drivetrain Chassis

## Initialization

```cpp
// Define SmartMotorGroups for left and right motors
SmartMotorGroup leftMotors = SmartMotorGroup("LeftMotors", {1, -2, 3, -4});
SmartMotorGroup rightMotors = SmartMotorGroup("RightMotors", {-5, 6, -7, 8});

// Create a TankChassis using the defined motor groups
TankChassis chassis = TankChassis(leftMotors, rightMotors);
```

### Usage

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

<Tabs>
<TabItem value="arcade" label="Arcade" default>
Arcade controls allow the robot to be driven using a horizontal and vertical joystick input.

```cpp
// Initialize the main controller
pros::Controller mainController = pros::Controller(pros::E_CONTROLLER_MASTER);

// Operator control function
void opcontrol() {

// Infinite loop for operator control
while (true) {

// Read joystick values from the main controller
double leftY = mainController.get_analog(ANALOG_LEFT_Y);
double rightX = mainController.get_analog(ANALOG_RIGHT_X);

// Normalize to [-1.0, 1.0]
leftY /= 127.0;
rightX /= 127.0;

// Move chassis based on joystick inputs
chassis.move(
leftY, // Forward/backward speed [-1.0 to 1.0]
rightX // Turning speed [-1.0 to 1.0]
);

// Delay to prevent the CPU from being overloaded
pros::delay(20);
}
}
```
</TabItem>
<TabItem value="tank" label="Tank" default>
Tank controls allow the robot to be driven using two separate joystick inputs for the left and right sides.

```cpp
// Initialize the main controller
pros::Controller mainController = pros::Controller(pros::E_CONTROLLER_MASTER);

// Operator control function
void opcontrol() {

// Infinite loop for operator control
while (true) {

// Read joystick values from the main controller
double leftY = mainController.get_analog(ANALOG_LEFT_Y);
double rightY = mainController.get_analog(ANALOG_RIGHT_Y);

// Normalize to [-1.0, 1.0]
leftY /= 127.0;
rightY /= 127.0;

// Move chassis based on joystick inputs
chassis.moveTank(
leftY, // Left Forward/backward speed [-1.0 to 1.0]
rightY // Right Forward/backward speed [-1.0 to 1.0]
);

// Delay to prevent the CPU from being overloaded
pros::delay(20);
}
}
```
</TabItem>
</Tabs>

## Configuration

### Brake Mode

By default, `SmartMotorGroup` motors are set to `coast` mode after they are passed into a `TankChassis`.
While this is configurable, it is **highly recommended** to keep the drivetrain motors in `coast` mode to prevent Smart Motors from overheating during matches.

```cpp
void initialize() {
// Enable brake mode on drivetrain motors
// DO NOT do this unless you know what you are doing!
leftMotors.setBrakeMode(true);
rightMotors.setBrakeMode(true);

// ...
}
```
142 changes: 142 additions & 0 deletions docs/tutorials/2_odometry.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
---
sidebar_position: 2
---

# 2 - Odometry

## Initialization

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

<Tabs groupId="odometry-type">

<TabItem value="perpendicular" label="Perpendicular" default>
```cpp
// Define rotation sensors for odometry wheels
RotationSensor verticalOdomWheel = RotationSensor("VerticalOdomWheel", 10);
RotationSensor horizontalOdomWheel = RotationSensor("HorizontalOdomWheel", 11);

// Define the radius of the dead wheels (in inches)
static constexpr double DEAD_WHEEL_RADIUS = 1.0; // in

// Create a perpendicular sensor odometry object
// (Since PerpendicularSensorOdometry is an AsyncTask, we must use a shared pointer)
PerpendicularSensorOdometry odometry = PerpendicularSensorOdometry(
verticalOdomWheel,
horizontalOdomWheel,
DEAD_WHEEL_RADIUS
);

// Run odometry in a background task
void initialize() {
odometry.start();
}
```
</TabItem>

<TabItem value="parallel" label="Parallel">
```cpp
// Define rotation sensors for odometry wheels
RotationSensor leftOdomWheel = RotationSensor("LeftOdomWheel", 10);
RotationSensor rightOdomWheel = RotationSensor("RightOdomWheel", 11);

// Define the radius of the dead wheels (in inches)
static constexpr double DEAD_WHEEL_RADIUS = 1.0; // in

// Define the distance between the left and right odometry wheels (in inches)
static constexpr double DEAD_WHEEL_BASE = 12.0; // in

// Create a parallel sensor odometry object
// (Since ParallelSensorOdometry is an AsyncTask, we must use a shared pointer)
std::shared_ptr<ParallelSensorOdometry> odometry = std::make_shared<ParallelSensorOdometry>(
leftOdomWheel,
rightOdomWheel,
DEAD_WHEEL_RADIUS,
DEAD_WHEEL_BASE
);

// Run odometry in a background task
void initialize() {
odometry.start();
}
```
</TabItem>
</Tabs>

## Usage

Odometry provides the current heading and position of the robot on the field as a `Pose` object.
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.

```cpp
void opcontrol() {
while (true) {
// Get the current pose of the robot
Pose pose = odometry.getPose();
std::cout << "X: " << pose.x << " Y: " << pose.y << " Heading: " << pose.heading << std::endl;

// Example: Resetting the robot's pose when a button is pressed
bool resetPose = mainController.get_digital(DIGITAL_A);
if (resetPose)
odometry.setPose(Pose(0, 0, 0));

// ...
}
}
```

## Configuration

### Inertial Sensor

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.
While optional, it is **highly recommended** to use an IMU for the best performance.

```cpp
// Define the Inertial Sensor
InertialSensor imu = InertialSensor("IMU", 15);

void initialize() {
// Use the IMU for odometry calculations
odometry.useIMU(&imu);

// ...
}
```

### Rotational Compensation

<Tabs groupId="odometry-type">

<TabItem value="perpendicular" label="Perpendicular" default>
When the robot rotates, the perpendicular orientation of the odometry wheels can inadvertently cause lateral movement readings.
To correct for this, you can set the offsets of the odometry sensors relative to the robot's center of rotation.

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).

:::note
You may have to manually tune these values based on the position and grip of your odometry wheels.
:::

```cpp
// Offset values for the odometry sensors, relative to the robot's center of rotation (in inches)
Vector2 verticalSensorOffset = Vector2(-0.5, 0); // (Y position is disregarded)
Vector2 horizontalSensorOffset = Vector2(0, 1); // (X position is disregarded)

void initialize() {
// Apply the offsets for odometry calculations
odometry.setSensorOffsets(verticalSensorOffset, horizontalSensorOffset);

// ...
}

```
</TabItem>

<TabItem value="parallel" label="Parallel">
:::tip[You don't need this with Parallel Odom Wheels]
Rotational compensation is not required for Parallel Sensor Odometry since the odometry wheels will not produce inadvertent lateral movement readings when the robot rotates.
:::
</TabItem>
</Tabs>
7 changes: 7 additions & 0 deletions docs/tutorials/3_autosteps.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
sidebar_position: 3
---

# 3 - AutoSteps

TODO
7 changes: 7 additions & 0 deletions docs/tutorials/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"label": "Tutorials",
"position": 2,
"link": {
"type": "generated-index"
}
}
19 changes: 2 additions & 17 deletions my-website/docusaurus.config.js → docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// There are various equivalent ways to declare your Docusaurus config.
// See: https://docusaurus.io/docs/api/docusaurus-config

import {themes as prismThemes} from 'prism-react-renderer';
import { themes as prismThemes } from 'prism-react-renderer';

// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)

Expand Down Expand Up @@ -52,21 +52,6 @@ const config = {
editUrl:
'https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/',
},
blog: {
showReadingTime: true,
feedOptions: {
type: ['rss', 'atom'],
xslt: true,
},
// Please change this to your repo.
// Remove this to remove the "edit this page" links.
editUrl:
'https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/',
// Useful options to enforce blogging best practices
onInlineTags: 'warn',
onInlineAuthors: 'warn',
onUntruncatedBlogPosts: 'warn',
},
theme: {
customCss: './src/css/custom.css',
},
Expand Down Expand Up @@ -95,7 +80,7 @@ const config = {
position: 'left',
label: 'Tutorial',
},
{to: '/blog', label: 'Blog', position: 'left'},
{ to: '/blog', label: 'Blog', position: 'left' },
{
href: 'https://github.com/facebook/docusaurus',
label: 'GitHub',
Expand Down
12 changes: 0 additions & 12 deletions my-website/blog/2019-05-28-first-blog-post.md

This file was deleted.

Loading
Loading