Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kicker Programming Firmware #20

Closed
wants to merge 9 commits into from
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
25 changes: 8 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ jobs:
toolchain: nightly-2024-09-04
default: true
target: thumbv7em-none-eabihf
- uses: actions-rs/cargo@v1
with:
command: check
args: --examples --bins --lib --target thumbv7em-none-eabihf
- name: Cargo Check
run: cd control && cargo check --examples --bins --lib --target thumbv7em-none-eabihf

cargo_clippy:
name: Clippy Check
Expand All @@ -29,10 +27,8 @@ jobs:
default: true
target: thumbv7em-none-eabihf
components: clippy
- uses: actions-rs/cargo@v1
with:
command: clippy
args: --target thumbv7em-none-eabihf
- name: Run Clippy
run: cd control && cargo clippy --target thumbv7em-none-eabihf

cargo_build:
name: Cargo Build
Expand All @@ -44,10 +40,8 @@ jobs:
toolchain: nightly-2024-09-04
default: true
target: thumbv7em-none-eabihf
- uses: actions-rs/cargo@v1
with:
command: build
args: --release --examples --bins --lib --target thumbv7em-none-eabihf
- name: Run Cargo Build
run: cd control && cargo build --release --examples --bins --lib --target thumbv7em-none-eabihf

cargo_rustfmt:
runs-on: ubuntu-latest
Expand All @@ -61,8 +55,5 @@ jobs:
default: true
target: thumbv7em-none-eabihf
components: rustfmt
- name: Check Formatting
uses: actions-rs/cargo@v1
with:
command: fmt
args: --check
- name: Run rustfmt
run: cd control && cargo fmt --check
12 changes: 8 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/target
**/target
**/build

# Teensy Loader CLI
teensy_loader_cli
teensy_loader_cli/**
setup/teensy_loader_cli/**
**/teensy_loader_cli
**/teensy_loader_cli/**
**/setup/teensy_loader_cli/**

# Helix Configuration
**/.helix/*
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ In 2023, we decided to switch microcontrollers from the team built A-Train micro

Therefore, this repository contains the code for the firmware for the RoboJackets RoboCup team.

## Setup

If you are running linux or macos, run:
```sh
./setup/unix.sh
```

If running windows, follow the steps in [setup/WindowsSetup.md](setup/WindowsSetup.md).

To ensure the correct version of Teensy loader is used by your system ensure the line under your operating system (i.e. "MacOS", "Windows", and "Linux") is uncommented in [control/tools/runner.rs](control/tools/runner.rs)

## Common Commands

### Running main.rs
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion .vscode/settings.json → control/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"rust-analyzer.linkedProjects": [
"./Cargo.toml",
"./drivers/motion/Cargo.toml",
"./drivers/controller/Cargo.toml"
"./drivers/controller/Cargo.toml",
"./drivers/kicker-programmer/Cargo.toml",
],
"rust-analyzer.check.extraArgs": [
"--examples",
Expand Down
9 changes: 9 additions & 0 deletions Cargo.lock → control/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml → control/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ path = "drivers/motion"
[dependencies.controller]
path = "drivers/controller"

[dependencies.kicker-programmer]
path = "drivers/kicker-programmer"

# the root package is also a workspace that holds all of the neccesary "supporting" packages
# such as driver files, utility files (e.g. tools), etc.
[workspace]
Expand All @@ -82,6 +85,7 @@ members = [
"drivers/controller",
"drivers/icm42605-driver",
"tools",
"drivers/kicker-programmer",
]

# overrides the release build optimization level
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl DutyCycle {
impl From<i16> for DutyCycle {
fn from(value: i16) -> Self {
// check that value is not outside of the allowed range
if (value > 511) || (value < -511) {
if !(-511..=511).contains(&value) {
return DutyCycle(0);
}

Expand All @@ -68,7 +68,7 @@ impl From<DutyCycle> for i16 {
fn from(dc: DutyCycle) -> Self {
let mut result: i16 = 0;
if (dc.0 >> 9) & 1 == 1 {
result = ((dc.0 & 0x1FF) as i16) * -1;
result = -((dc.0 & 0x1FF) as i16);
} else {
result = dc.0 as i16;
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Helper file that contains definitions used in the fpga
// Extracted from the FPGA.cpp driver

#[allow(dead_code, non_camel_case_types)]
#[allow(dead_code, non_camel_case_types)]

/// Instruction to Send to the Robot
Expand Down
15 changes: 7 additions & 8 deletions drivers/fpga/src/lib.rs → control/drivers/fpga/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,9 @@ where
/// 5. Returns Ok if no errors or timeout
pub fn configure(&mut self) -> Result<(), FpgaError<SPIE, GPIOE>> {
// toggle the prog_b pin
self.prog_b.set_low().map_err(|e| {
let new_error = FpgaError::<SPIE, GPIOE>::ProgPin(e);
new_error
})?;
self.prog_b
.set_low()
.map_err(FpgaError::<SPIE, GPIOE>::ProgPin)?;
self.delay.delay_ms(1); // allow for hardware to latch properly
self.prog_b.set_high().map_err(FpgaError::ProgPin)?;

Expand Down Expand Up @@ -427,8 +426,8 @@ where
let mut write_buffer = [0u8; 12];
write_buffer[0] = Instruction::R_ENC_W_VEL.opcode();

for i in 0..wheel_velocities.len() {
wheel_velocities[i] *= VELOCITY_TO_DUTY_CYCLES;
for wheel_velocity in &mut wheel_velocities {
*wheel_velocity *= VELOCITY_TO_DUTY_CYCLES;
}

duty_cycles_to_fpga(wheel_velocities, &mut write_buffer[1..9]);
Expand All @@ -454,8 +453,8 @@ where
(i16::from_be_bytes(write_buffer[5..7].try_into().unwrap()) as f32),
(i16::from_be_bytes(write_buffer[7..9].try_into().unwrap()) as f32),
];
for i in 0..4 {
delta_encoders[i] *=
for encoder_velocity in &mut delta_encoders {
*encoder_velocity *=
1e6 * 2.0 * core::f32::consts::PI * WHEEL_RADIUS / (6144.0 * delta);
}
self.status = write_buffer[0];
Expand Down
8 changes: 8 additions & 0 deletions control/drivers/kicker-programmer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "kicker-programmer"
version = "0.1.0"
edition = "2021"

[dependencies]
embedded-hal = "~0.2"
log = "0.4"
1 change: 1 addition & 0 deletions control/drivers/kicker-programmer/bin/kicker

Large diffs are not rendered by default.

Binary file added control/drivers/kicker-programmer/bin/kicker.nib
Binary file not shown.

Large diffs are not rendered by default.

Loading
Loading