Giter Club home page Giter Club logo

embedded's Introduction

Travis-CI

embedded

This is all the code for the embedded systems on the rover.

This code will run on STM32 chips, specifically the F103 or F303 series (preferably F303)

MOST OF THE FOLLOWING IS OUTDATED

Onboarding

  1. First, create a GitHub account and send the username to the Controls team lead.
  2. Install the required toolchain
  3. Follow the Onboarding Task.

Requirements

You need to have the following tools installed:

  • Oracle Virtualbox
  • Oracle Virtualbox Extension Pack
  • STlink Driver
  • Vagrant
  • VScode
  • Git
  • At least 4GB of storage space

Documentation

Windows

Install listed dependencies

It works by building a virtual machine via Vagrant that contains most of the required toolchain.

Getting started

  • First clone this repository to the machine you will work on.
git clone https://github.com/UofA-SPEAR/embedded
  • Navigate to the root directory of the embedded project via cmd terminal/bash.
  • Run vagrant up. The script will now setup the VM, this process may take a while. Ensure that you have internet access as it will download the VM.
  • Run vagrant ssh-config to retreive the ssh config for the VM.
  • Install the Remote - SSH extension for VScode. See the VSCode section below for more info.
  • In the command pallet (ctrl + shift + p) type remote-ssh: open configuration file and select the first option
  • Copy the output of vagrant ssh-config to the file that was opened.
  • In the command pallet (ctrl + shift + p) type remote-ssh: connect to host or click on the green icon in the bottom left corner of the VScode window.
  • Once connected, go find the c/c++ and cortex-debug extension in the VScode extension marketplace, and use the option 'install in spear-embedded-box' and reload the window once completed.
  • Go to terminal > run task > build and create c_cpp_properties in the reloaded window to generate VScode json.

Creating a project

Copy the example project, embedded/template_project as your own project folder.

Debugging/Flashing

UPDATE THIS

THIS MAY CHANGE SOON

To flash the firmware, simply run

make flash

with your programmer and device plugged in.

To debug, simply run:

make debug

This will launch an OpenOCD instance, with a GDB server running on port 3333. To actually debug, you will have to attach a GDB instance to it.

GDB

Once we have the OpenOCD server running, we can run GDB with these commands.

arm-none-eabi-gdb build/<project_name>.elf
(gdb) target remote localhost:3333
(gdb) monitor reset halt
(gdb) load

Now we can debug as we normally would with GDB.

Eclipse

Install Eclipse CDT, and the GNU MCU Eclipse plugin on the Eclipse marketplace. The bare minimum is fine.

Then, create a new debug configuration, with the GDB Hardware Debugging template. Select build/<project_name>.elf as your source, and change the remote target to use localhost port 3333 instead of 10000.

VSCode

You need to install the following VSCode plugins:

  • Cortex-Debug
  • C/C++

There will be a good config in the .vscode folder within the example project. Use that for reference.

If you're using a pure open-source version of vscode, then you'll need this workaround in order to access the marketplace: VSCodium/vscodium#418 (comment). Otherwise, you'll get an error like: "We cannot connect to the Extensions Marketplace at this time, please try again later". You may also need to do this workaround: https://docs.microsoft.com/en-us/visualstudio/liveshare/reference/linux#vs-code-oss-issues if you get errors like "Command ... not found".

If you are using Arch, there is a AUR package to do this patching automatically: https://aur.archlinux.org/packages/code-marketplace/

If you continue to run into issues with the open-source version, you may need to switch to the microsoft version of vscode.

UPDATE THIS

embedded's People

Contributors

davidlenfesty avatar minh7a6 avatar nic3-14159 avatar mdepp avatar kuinran avatar mayshukla avatar jacobrec avatar

Stargazers

Zhiyuan Li avatar JwongXyan Myou avatar  avatar  avatar  avatar  avatar  avatar Pavel Kirienko avatar

Watchers

James Cloos avatar  avatar Kieran avatar  avatar JwongXyan Myou avatar

embedded's Issues

Improve Motor Controller Encoder settings

Either write a script or implement something on the controller itself to make setting the positions, and feedback settings nicer to use.

(e.g. it asks the range of the joint, then tells you to move the arm to x degrees and hold, then y degrees and hold, and it calculates all the settings for you.

Finish Indication Board Software

Really simple, just needs to PWM the RGB lines based on some state published over CAN bus.

Collaborate with software to determine the message type, and what exactly needs to be done.

Needs to conform to URC rules, however we can likely add some extra features, such as it flashes colours on state transitions. Talk with software about what they would like to see.

Standard interface for CAN frame reception.

Currently it's whatever I've decided to implement in whichever project. This should really be a seperate library that's just #included.

Ideally it should use a circular buffer (with a good implementation!) with a single interface to do CAN init. (maybe pass a function to use to enable GPIO and clocks, with asserts?)

Revamp Onboarding

As it exists, the onboarding is pretty terrible. (hrm... I wonder who wrote it)

I believe it should be re-written to actually be thorough, and not assume people will know where to look. It should function more like a tutorial than a list of tasks to finish, because this will be most people's first step into embedded.

The task itself should be similar, but updated for the state we are in now. So it should be reading some sensor value from the ADC, and then pushing it out over CAN.

This probably depends on #36 and #37 getting done.

Update ChibiOS from 19.1 to 20.3

I am creating this to request upgrading our current ChibiOS as some of the nice features from ChibiOS 20.3 that can be handy for embedded (e.g: MFS).

Third message in ArrayCommand is dropped on reciever.

When using uavcan/equipment/actuator/ArrayCommand to send actuator commands, the third command in the array is dropped. If four messages are dropped, the array looks like this:

[cmd 1] [cmd 2] [cmd 4] [blank cmd]

Reproduced on both arm controller and drive controller.

Steps to qualify:

  • Check if it is every third message
  • Check if this applies to all dynamic arrays in UAVCAN
  • Check path through the iterator that loads elements into this array

Changes to Wiki/Onboarding Task

The onboarding task on the Wiki site of this repo seems out of date, instead I think we can delete the page as the README in the front page should be good enough

ADC Assertion with ChibiOS 20.3.3

Using the motor_controller, when adcStart() is called, it triggered the assertion, when test out the ChibiOS original source with branch stable_20.3.x, this problem did not occurred

Need to assign linker scripts.

Platformio is using a default linker script, which likely won't run on any board.

I need to find the linker scripts form SW4STM32 and implement them in custom board files probably.

Refactor UAVCAN v0 CAN stuff.

Currently it's all written in coms.c of motor_controller, whenever some new firmware is started, we should factor out the common functions into their own little module (a folder in common/), to improve DRY.

Once this is done, it would be good to tackle #36

Implement Motor Controller Feedback

Right now, the feedback coming from the motor controller is pretty sparse and not that useful.

  • Add current sensing
  • Create new UAVCAN message type to encode the kind of data we want.
  • Add position feedback from the motors.

Write new DSDL definitions for UAVCAN v1

UAVCAN v1 prunes a lot of the standard data types, and instead makes it easier to define custom data types. New data types will need to be written for the various portions of the rover.

UAVCAN v1 Parameters

This needs to be implemented both on the interface side, and by adding some code infrastructure to make parameters easy.

Since it's C, lots of boilerplate for each parameter is fine, just make it reasonable to add/remove parameters, and some method of versioning so that we can detect when the list of parameters have changed.

Improve angle/position deduction scheme in motor controller.

Currently how the angles are transformed into the integer encoder positions is quite primitive, and only supports a few hardcoded use cases.

We will need to add a few more CAN parameters and redefine existing ones in order to support a more general array of use cases and redefinitions.

Some specific improvements:

  • Reverse encoder directionality. If we send an angle to an encoder, we want to be able to reference opposite of that angle.
  • Angle offset. We want to be able to reference an angle we can't reach.
  • Change to_radians to something more ergonomic.

Power Rail Monitoring

Once the computer subsystem PDU is designed, it will need to have a Speedy on it to monitor power rails status (voltage, current, faults).

Exactly what that interface will look like is unknown at the moment.

Implement CAN Bootloader.

It would be nice to have a CAN bootloader to update firmware once we have a stable system.

We can use CVRA's very nice bootloader, or make our own if we don't feel like we have enough work to do.

This also includes the tooling around the bootloader, how to actually upload to this bootloader.

Repo Cleanup

We have too many stale branches, many of them for one-off tests that have outlived their usefulness.
Either merge them in or delete them.

As well, old firmware folders can be deleted (AFTER having a known good commit tagged)

Motor Controller Code cleanup

It's kind of in a weird half-state right now.

  • Migrate fully to Kernel C style
  • Rename functions so everything has a consistent scheme
  • Move motor functions into it's own source file
  • Improve interface between main, motors, and encoders, it's kind of scattered right now. Having a single interface would be better.

Anything else you can think of.

More standard build system.

Right now we're relying on people to just create a project correctly within SW4STM32. This works but really isn't ideal.

A) it relies on people to not make any mistakes when initializing a project (humans make mistakes)
B) It copies the HAL libraries a lot
C) You have to do a bunch of build configuration to get libcanard running, which is not ideal, as it's easy to forget or mess up, and there's already a few different ways to include the libraries implemented right now.
D) It's hard to retarget. If I want to switch from an F303C8 to a CB, I need to create an entirely new project.

I think the best solution here is just a makefile. This has a few advantages over using the SW4STM32 build system:
A) You can develop/build WITHOUT installing SW4STM32.
B) If we need to add a new use case (e.g. flash storage), we add it once and it works forever
C) Things can be automated. We can do build checks!
D) We can standardize libraries without having to add them in manually to every project (we can just symlink to a single makefile)
E) We can (theoretically) retarget more easily. Different targets can just set different preprocessor defines and use different linker scripts.

Not sure exactly how this will work, and honestly this might take a while to develop an extensible makefile. (+ keep track of pre-reqs so we can give people a nice list)

There is the downside that it's not necesarily as nicely integrated into SW4STM32, but whatever.
It's not that hard to set up an eclipse environment w/ openOCD anyways. Also will be a bit wonky to deal with windows.

SWO Infrastructure

It would be quite nice to have printf-style debugging available, so someone should write a ChibiOS "module" (i.e. makefile, header, and source) that sets up ITM channel 0 for SWO print debugging, and hooks it into the C stdlib mechanisms, so that we can use printf to print to debugging.

Migrate to DroneCAN

The UAVCAN V0 frameworks are getting maintained by drone folks under the name of DroneCAN. It is a better idea to use their sources there instead of the original UAVCAN

ChibiOS App Template

Extract a template ChibiOS application out of the motor controller firmware.

Must include CAN bus, with a thread for CAN and a thread for heartbeat (w/ NodeStatus).

Migrating to UAVCAN 1.0

We will migrate to UAVCAN v1 once libcanard has official support for it.

I haven't looked in-depth at the new specification yet, but it looks like it won't be plug and play. (for one, there are no actuator commands, at least when I looked).

Retool blinky to be a good example.

Once the CAN refactor is done, blinky can be updated to use it, and serve as a useful, simple example.

Required functionality:

  • Blinkenlights ™️
  • CAN heartbeat sending
  • Heartbeat reception, updating the number of blinks to match the number of nodes it sees

CAN Bootloaders

Just trying to track progress of getting bootloaders up and running.

Note that supporting bootloaders requires full commitment - each application needs its linker script updated as well.

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.