Giter VIP home page Giter VIP logo

firmware's Introduction

Firmware example workflow

This is the unified firmware repository for the A-Team.

Setup

Follow the first time setup guide.

If you are not a member of the A-Team, you will not have access to the private repository that store our Wifi credentials. Please set export NO_ATEAM_WIFI_CREDENTIALS=true in your shell, so the build system will load dummy credentials. You can set them in ateam-credentials/src/public_credentials/wifi.rs.

Building Firmware

Begin by entering the Nix environment nix develop. If you use a shell other than bash, you can try nix develop -c $SHELL to stay in your preferred shell.

WSL users should launch VS Code from the nix environment in the Ubuntu shell.

A top level Makefile is provided for all targets. Targets in the form <module>--<binary>--<action>.

The primary command make control-board--control--run will build all robot firmware, flash hardware, and run the image.

List of Modules

Module Description
common common libraries shared across modules
software-communication packet defintitions used for communication with software and between hardware modules
motor-controller firmware binaries for stspin32 motor controllers (wheels, dribbler, tests)
kicker-board fimrware binaries for the kicker board
control-board firwmare binaries for the control board

List of Binaries

Binaries Description
Varied. See README.md files in subfolders or use tab complete suggestion.

List of Actions

Actions Descrption
<module>\-\-all Builds all binaries for the module
<module>\-\-<binary> Builds the binary for the module
<module>\-\-<binary>\-\-run Flashes the binary to the hardware target, runs the binary, print messages appear in the shell
<module>\-\-<binary>\-\-debug Flashes the binary to the hardware target, attaches gdb, halts the processor at reset_vector

firmware's People

Contributors

guyfleeman avatar petersonev avatar hmmurdock avatar joe-spall avatar optimalpandemic avatar ebarnette avatar fourpenny avatar collinavidano avatar

Stargazers

Luke Baird avatar David Serfozo avatar  avatar

Watchers

 avatar Joseph Neiger avatar  avatar  avatar  avatar  avatar  avatar Matthew Woodward avatar Leo Medrano avatar  avatar

firmware's Issues

Create ELF Embeddable Output Targets

We'll eventually need to be able to include the motor driver firmware into the main firmware image to be distributed. I think the easiest way to do this would be to write a small python script that can read a file (or text input), and take a label name, and generate an assembly/C stub with the byte contents, byte length, and crc32 checksum. We can then directly map the symbols in the linker file.

Check direction of encoder in torque loop more often

Because of low side current sense, we don't get direction for torque control so we rely on encoders. In the velocity loop we don't want to oversample the encoders because it will lead to instability. However, we can read the encoder without clearing more often just for direction for torque control incase there is a commanded flip before velocity is read.

Kicker Overvoltage Lockout Behavior

Kicker overvoltage lockout behavior currently has some quirks that should be addressed.

  1. Kicker errors are not reported upstream (either at the kicker or control firmware level)
  2. Kicker high voltage measurements are not filtered
  3. Kicker has no mechanism to unlatch errors

2 and 3 are interacting negatively. Occasionally it seems measurement occurs when there's a small spike (probably on kicks). The target voltage is 182, and the over voltage lock out is 190, so ~4% error. I think there are a few options to solve this, but they need careful thought. We could bump the lockout voltage, but we need to make sure it below 200V enough to stop charging before we cross 200V based on the simulated or observed charge rate. Another option might be to filter measurements (we should do this anyway at least for the value sent upstream), but again we need to make sure the filter delay doesn't mean we stop charging too slowly.

IMU Updates

The IMU code is pretty bare bones. This should address the motion improvement requirements set by @joe-spall. I suggest:

  • Move the IMU reads into their own task
  • Have the task block on device interrupts
  • Enable interrupts on the BMI085 after gyro conversion, fire SPI DMA transfer
  • Double check the BMI085 settings for data rate vs noise. It may be updating much faster than we need and would have noise
  • Add an optional filter
  • Add accelerometer data fetching at the same time we use DMA to get the gyro data (these may have different acq rate, prioritize gyro)

There's already a pubsub channel setup for IMU data that collin used for the o.g. prototype. This should be task/thread safe.

Robot Reconnection Issues

Details are murky but sometime robots require two re-connection cycles when software radio bridge is restarted out of band.

Steps to reproduce:

  1. Start radio bridge
  2. Start robot
  3. Wait for positive connection
  4. Kill and restart radio bridge
  5. Robot will connect
  6. Robot will disconnect and reboot
  7. Robot will connect and stay connected

step 7 should occur at step 5

update-alternatives fails in udev_setup.bash when alternative is already set?

On WSL2 if running udev_setup.bash after update-alternatives has been set for usbip, the line
update-alternatives --install /usr/local/bin/usbip usbip /usr/lib/linux-tools/*-generic/usbip 20 fails with
update-alternatives: priority must be an integer

This causes the rest of the setup script to not be run. This error also occurs if the line is ran from the command line. I am speculating its because the priority is already set? 20 is clearly an integer.

Commenting out the line lets the rest of the script run.

Improve Global E-Stop

We've got much better error detection and handling at the stspin layer and can detect missing PCBs, but the way we handle this info is missing or blunt. Notable examples are a system power reset when comms time out, and no detection/correction for faulted motors. We should have a global estop manager that aggregates failures and contains some of access control list type of thing where major functions are enabled or disabled based on the aggregate of current errors (e.g. dribbler fault should not stop motion, a single motor failure should arguable not stop motion but restrict it, two motor failures should certainly stop motion, specific failures should automatically trigger kicker auto discharge).

We should consider at least the following list or errors:

  • dribbler failures
  • single motor failure
  • multiple motor failure
  • unplugged radio
  • comms timeout
  • unplugged IMU
  • IMU failed self test
  • unplugged kicker
  • low battery voltage
  • critical battery voltage

We should consider the following classes of actions:

  • forcing reduced motor velocity
  • forcing 0 motor velocity
  • forcing power off / lower power state
  • forcing kicker discharge procedure

Measure charge rate of kicker voltage

Might be interesting to measure charge rates of kicker over time to detect faults/ measure performance. Would send up to control. Reset count after kick/chip

Differences with Software

This isn't a firmware or software issue per se, but a list of things that should be standardized between the sides and aren't. This is a living list.

  • we have no standard terminology for "body velocity", the Vec3 in robot motion command. Software simply calls this twist because that's the msg type, but we may conceivably use multiple twists for position, vel, accl, torque at various points
  • we have no agreed upon terminology for clamped, limited, whatever versions of raw commands
  • we have no agreed upon structure for wheel based data, e.g. float32[4] arrays for each data point, Struct[4] containing all data points per wheel
  • software and firmware use different wheel state spaces (e.g. indices for ordering in arr[4] types)
  • broadly, some control packet data names are misleading or bad, some feature mismatches
  • software and firmware use different names for firmware: "control debug telemetry", software: "RobotMotionFeedback"

Kicker v3.0 Hardware Fixes

  • HPF across outboard inductors (1nF, 1k)
  • BOOT0 pull down
  • Fix PGOOD LED
  • Vbatt sense
  • 3v3 sense
  • uC_KILL pull up
  • Kick Chip silkscreen
  • local 8MHz clock?
  • layout

Create CMake Macro for Targets

Looks like the template to collect sources and build a firmware image is gonna be extremely cookie cutter. This can probably be made into a macro. Then the top level CMakeLists.txt file will be fairly clean and we won't have to get crazy with sub dir files.

Motors Occasionally Jerk When Commanded DC Is Negative

We seem to observe this behavior only with a negative DC setpoint. We might have a sign based logic bug somewhere when setting DC on the stspin firmware.

Steps to repro: set DC -0.2 (observe behavior after a few minutes), set DC 0.2 (do not observe behavior after a few min)

UART communications seem to drop out

something causes stspin uart to freeze without locking up the whole device (doesn't trigger watchdog). We've temporarily added a watchdog trigger to clear the condition with a reboot.

Comp mode switch

Adds timeout recovery, don't flash everything in paralélelo, etc

Kicker auto-discharge should not run if breakbeam

Auto-discharge runs without considering the breakbeam. However, if someone goes to pick up the robot, a finger could be in the mouth of robot. Invert the logic and stop the auto-discharge if breakbeam

Refactor Communication

  • change ambiguous verb/noun names/functions
  • battery voltage is sent back to ROS
  • torques are sent back to ROS
  • wheel vels are sent to ROS
  • IMU theta, xz accel

Motion Model Refactor

The motion code has some rough edges, especially as we've added features like parameter updates. Things that should be cleaned up:

  • matrices should have names not mathematical letters/syms
  • there should be a clear delineation between hardware and control models
  • PID module needs to be refactored into a single state module, not a parametric type. This has implications for matrix slicing when parameters are updated, and currently makes the code pretty ugly
  • parameter updates should be dispatched hierarchically using some form of trait for updates. This will make pieces interchangeable.
  • Modules should have prints at correct logging granularity and crate level logging should be error or off by default

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.