Skip to content

Commit

Permalink
Feature/steering sys and load cell interface (#81)
Browse files Browse the repository at this point in the history
* integrating CASE

* adding in normalized steering

* semi-fully integrated. compiling but un-tested version that connects to the controller

* updated to newest CASE gen

* seemingly working on car, everything enabled

* added CASE

* pushing fix for brakes no stoppy

* adding more fixes to tc mux tests

* updating tc mux tests

* integrating check for VN status to check whether or not it has been active for long enough

* added beginnings of the unit test for CASE

* adding instructions for CASE updating

* removed * -1 for CASE torque request to make sure controller algos are getting negative torque request

* Update CASE library, added TCS, working brakes

* fix CASE & pedal tests

* refactor

* clean up based on PR comments

* add keepalive for steering system

* add load cell interface

* Update CASE, added new inputs

* Fixed test config

* Model change to reflect variable name better

* verified steering system works

* remove used function

* fixed implausibility typo. fixed warnings

* emergency PosSpeedLimit fix

* emergency PosSpeedLimit fix

* New CASE inputs, flashed and working 4-20-24

* Added decoupled yaw pid and discontinuous brakes, torque and regen limit now handled by CASE

* Update inputs in test_CASE

* fixed power limit jerking at low rpm (should not be possible but just in case)

* Fixed regen limit not working @ 0 rpm

* re-enabling all limits

* CASE Update, working regen 5kph limit, mech power limit, drive/brake torque bias, flashed on car 4/26/24

* update can lib to 80

* removing old way of integrating CASE_lib

---------

Co-authored-by: walkermburns <walkermburns@gmail.com>
Co-authored-by: Luke Chen <43226681+Luke-kC@users.noreply.github.com>
Co-authored-by: Dopp-IO <42275088+Dopp-IO@users.noreply.github.com>
  • Loading branch information
4 people committed Apr 29, 2024
1 parent cdd39d1 commit f36ebda
Show file tree
Hide file tree
Showing 68 changed files with 1,198 additions and 4,198 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/platformio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ jobs:
run_build_and_tests:
runs-on: ubuntu-latest
steps:
- uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.CASE_SSH_PRIVATE_KEY }}
- name: Check out the repository
uses: actions/checkout@v3

Expand Down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
## using and updating CASE

#### DO THIS ONCE
you will need to add ssh key to your github account to allow platformio to pull in CASE as a library.

[follow these instructions on how to do this.](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account)

#### UPDATING CASE

to update case, look for the latest tag at this repo: https://github.com/hytech-racing/CASE_lib/tags

and then in the `platformio.ini` file in this repository, change the number at this line:

`git+ssh://git@github.com/hytech-racing/CASE_lib.git#v(INSERT NUMBER HERE)`

for example:
```git+ssh://git@github.com/hytech-racing/CASE_lib.git#v34```

## building testing and running
This project uses [Platformio](https://docs.platformio.org/en/latest/) for building, testing, checking and packaging.

Expand Down Expand Up @@ -78,6 +96,16 @@ then you can select this configuration to be used with [this c/c++ extension](ht

to select the configuration, use the hotkey `ctrl+shift+p` to open the command prompt in vscode, and then type \`C/C++: Select a Configuration\` and then select your configuration for which you named above.

## updating CASE (manual / old way)

1. generate the .zip file in HyTech_sim by generating the code for CASE
2. while in the HyTech_sim directory, there exists `process_lib.py`. use this by running:
```
python3 process_lib.py HT08_CONTROL_SYSTEM.zip /path/to/MCU/lib/CASE_lib CASE_lib
```
while ensuring that you fill in your path to MCU.

3. profit

## Design Lore of the Code
### outline
Expand Down
3 changes: 3 additions & 0 deletions flash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
pio run --target upload --environment teensy41
pio run --target upload --environment teensy41
12 changes: 9 additions & 3 deletions include/MCU_rev15_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ const int BRAKE2_PEDAL_OOR_MIN = 90;
const int BRAKE1_PEDAL_OOR_MAX = 4000;
const int BRAKE2_PEDAL_OOR_MAX = 4000;



const float DEFAULT_PEDAL_DEADZONE = 0.05f;
const float DEFAULT_PEDAL_IMPLAUSIBILITY_MARGIN = 0.10f;

Expand All @@ -73,7 +71,7 @@ const float BRAKE_ACTIVATION_PERCENTAGE = 0.05f;
const float BRAKE_MECH_THRESH = 0.40f;

// Load Cell Defs to convert raw to lbs
// lbs = (scale)*raw + offset
// lbs = (raw + offset) * scale

const float LOADCELL_FL_SCALE = 0.0553;
const float LOADCELL_FL_OFFSET = 15.892 / LOADCELL_FL_SCALE;
Expand All @@ -86,4 +84,12 @@ const float LOADCELL_RL_OFFSET = 21.842 / LOADCELL_RL_SCALE;

const float LOADCELL_RR_SCALE = 0.0588;
const float LOADCELL_RR_OFFSET = 19.576 / LOADCELL_RR_SCALE;

// Steering parameters
const float PRIMARY_STEERING_SENSE_OFFSET = -21.18; // units are degrees
const int SECONDARY_STEERING_SENSE_LEFTMOST_BOUND = 812;
const int SECONDARY_STEERING_SENSE_RIGHTMOST_BOUND = 3179;
const int SECONDARY_STEERING_SENSE_CENTER = 1970;
const float STEERING_RANGE_DEGREES = 256.05f;

#endif /* __MCU15_H__ */
Loading

0 comments on commit f36ebda

Please sign in to comment.