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

update oscc to v1.2.4, add validation modifications #31

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
654e9ef
Update README with vehicle compatibility list
vertexmachina Nov 9, 2017
047933b
Add deadzone for steering joystick
vertexmachina Nov 29, 2017
f7d062c
Clear out exponential filter averages on disable
vertexmachina Nov 29, 2017
7ae3fd2
Update torque range to 20% of max range
Dec 8, 2017
75fd4fe
Fix typoo in documentation
Dec 8, 2017
da0fe09
Fix another typo
Dec 8, 2017
92b6dce
Merge remote-tracking branch 'origin/maint/update-torque-feel' into d…
vertexmachina Dec 13, 2017
ffeda9a
Merge 'origin/maint/update-readme' into devel
Dec 13, 2017
d8806e9
Merge 'origin/maint/zero-filters-on-disable' into devel
Dec 13, 2017
cd5bbf5
Add Jenkinsfile
Dec 14, 2017
21b5f03
Fix typo
Dec 14, 2017
90ecfbc
More carefully fix typoo because testing Jenkins locally is hard
Dec 14, 2017
83edf6a
Pull in OSCC repo for building
Dec 14, 2017
2f1377c
Remove unnecessary catch block
Jan 2, 2018
3b61d81
Merge 'origin/maint/add-jenkinsfile' into devel
Jan 2, 2018
f7cca5b
Make initialization of `joystick_data` explicit
Jan 16, 2018
752b391
Merge remote-tracking branch 'snewt/bug/explicit-joystick-data-init' …
Jan 24, 2018
9410337
Add OSCC configuration file
rebpdx Jun 7, 2018
0b2269a
Add OSCC submodule
rebpdx Jun 7, 2018
e1f0c70
Merge pull request #27 from PolySync/maint/update-cmake-config
Jun 7, 2018
9cae150
Merge pull request #30 from PolySync/master
cotos Oct 25, 2018
3454aa3
update oscc to v1.2.4, add validation modifictions
cotos Jul 9, 2019
45bc4c6
Updated README and LICENSE files
cotos Jul 10, 2019
2a60f8f
Update README.md
cotos Jul 10, 2019
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
Prev Previous commit
Next Next commit
Updated README and LICENSE files
I updated the README to follow the the DriveKit README on the
`feature/dfu-bootloader` branch.

I updated the MIT copyright to 2019 in the license and readme files.
  • Loading branch information
cotos committed Jul 10, 2019
commit 45bc4c6b7371d7e2832d2197897951a9da668143
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 PolySync Technologies
Copyright (c) 2019 PolySync Technologies

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
96 changes: 50 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
<img src="https://raw.githubusercontent.com/wiki/PolySync/OSCC/images/oscc_logo_title.png">

# Joystick Commander

## Overview

Joystick commander is an example application designed to show how the Open Source Car Control API can be used to recieve reports from and send commands to a drive by-wire enabled vehicle.

Using an SDL2 supported game controller, inputs are normalized and converted to relative torque, throttle, and brake commands. This application also demonstrates registering callback functions to recieve and parse OSCC reports as well as vehicle state reports from the car's OBD-II CAN network.

For more information about OSCC, check out our [github](https://github.com/PolySync/oscc).


# Pre-requisites:
## Getting Started

These instructions have been tested with a new Ubuntu 18.04 installation.

- OSCC's API and firmware modules are both required, and the modules must be installed on the vehicle
- The socketcan driver for USB and PCIe CAN interfaces is required, and is pre-installed on most Linux systems
Expand All @@ -20,112 +26,110 @@ This application has been tested with a Logitech F310 gamepad and a wired Xbox 3

[Logitech Gamepad F310](http://a.co/3GoUlkN)

Install the SDL2 library with the command below.

```
sudo apt install libsdl2-dev
### 1. Install Dependencies

You will need several packages installed on your machine in order to build the oscc-joystick-commander application. Use the following command to install them using `apt`:

```sh
sudo apt install git cmake libsdl2-dev
```

### 2. Set up this repository locally

# Getting OSCC & Joystick Commander
Clone this repository to your machine, if you have not already done so:

If you haven't already, install the OSCC hardware modules onto the target vehicle.
```sh
# clone the repository
$ git clone [email protected]:PolySync/oscc-joystick-commander.git

Once the hardware is installed and the firmware is flashed, clone and enter the joystick commander repo:

```
git clone [email protected]:PolySync/oscc-joystick-commander.git
cd oscc-joystick-commander
# change the current directory to the repository
$ cd oscc-joystick-commander
```

From within the joystick commander directory, clone the OSCC repo:
Note: If you do not have a github account you will need to clone the repository using HTTPS.

```
git submodule update --init
```
Then, from within that directory, sync and initialize Git submodules:

This will clone into a directory called `oscc` where CMake will look for the OSCC API when it builds joystick commander.
```sh
$ git submodule sync
$ git submodule update --init --recursive
```

## Building Joystick Commander

# Building Joystick Commander
### 1. CMake Configuration

From the root directory, create a build directory inside of it:
Before you can build the oscc-joystick-commander application, you must use cmake to configure the project. From within the oscc-joystick-commander repository on your machine:

```sh
# create a build directory that will act as our workspace, and cd to it
$ mkdir build/
$ cd build/
```
mkdir build
cd build
```

To generate Makefiles, tell `cmake` which vehicle to build for by supplying the
appropriate build flag:

| Vehicle | Flag |
| --------------- | ---------------- |
| Kia Soul Petrol | -DKIA_SOUL=ON |
| Kia Soul EV | -DKIA_SOUL_EV=ON |
From there, you will run `cmake` to build a platform-specific Makefile. `cmake` will require some arguments, including the vehicle that the firmware is being built for. You can get a list of supported vehicles using the following command:

```sh
$ cmake -LA .. 2>/dev/null | grep 'VEHICLE_VALUES'
```

For example, if you want to build joystick commander for the petrol Kia Soul:
For example, to configure `cmake` to build a platform-specific Makefile for the Kia Niro, you would use the following command (from within the `build/` directory you created):

```sh
$ cmake -DVEHICLE=kia_niro ..
```
cmake .. -DKIA_SOUL=ON
make
```

The vehicle build flag enables the API to swap between different vehicle specifications, allowing the firmware and API to remain car agnostic.

### CAN interface

After initializing the CAN interface, use the channel number to start joystick commander and begin sending commands to the OSCC modules.

For example with a Kvaser Leaf Light attached, using a bitrate of 500000 and a CAN channel of 0:

```
```sh
sudo ip link set can0 type can bitrate 500000
sudo ip link set up can0
```

You would then run:

```
```sh
./oscc-joystick-commander 0
```

For more information on setting up a socketcan interface, check out [this guide](http://elinux.org/Bringing_CAN_interface_up).

# Application Details

# Controlling the Vehicle with the Joystick Gamepad
## Controlling the Vehicle with the Joystick Gamepad

Once the joystick commander is up and running you can use it to send commands to the Arduino modules.
Once the joystick commander is up and running you can use it to send commands to DriveKit.
Use the left trigger to brake, the right trigger for throttle, and the left gamepad axis to control steering.

The vehicle will only respond to commands if control is enabled with the start button. The back button disables control.


# Application Details


### main

Entry point of joystick commander. Initializes OSCC interface, checks for controller updates in 50 ms intervals, and closes the interface when the program terminates. This contains the applications main loop.

`main.c` is the entry point of joystick commander. Initializes OSCC interface, checks for controller updates in 5 ms intervals, and closes the interface when the program terminates. This contains the applications main loop.

### joystick

`joystick.c` contains the functionality necessary to initialize and interact with the game controller.


### commander

The commander files contain the joystick commander's interactivity with the OSCC API. It demonstrates opening and closing the CAN channel communications with OSCC's control CAN network, sending enable/disable commands to the modules through the API, retrieving OSCC reports through callback functions, and sending commands through the OSCC `publish` functions.


# Using OSCC API

To use the OSCC API in your applications, you need to include any relevant header files.

* The can message protocols are located in `oscc/api/include/can_protocols/`
* These specify the structs we use for steering, throttle, brake, and fault reports
* Vehicle specific macros and values are located in `oscc/api/include/vehicles/`
* You only need to include `vehicles.h`, which will include the relevant vehicle-specific header depending on the option provided to CMake (e.g., `-DKIA_SOUL=ON` will include `kia_soul.h`)
* You only need to include `vehicles.h`, which will include the relevant vehicle-specific header depending on the option provided to CMake (e.g., `-DVEHICLE=kia_niro` will include `kia_niro.h`)
* `oscc/api/include/oscc.h` includes the functionality to interface with the OSCC API


Expand All @@ -144,4 +148,4 @@ Please direct questions regarding OSCC and/or licensing to [email protected].

*Distributed as-is; no warranty is given.*

Copyright (c) 2017 PolySync Technologies, Inc. All Rights Reserved.
Copyright (c) 2019 PolySync Technologies, Inc. All Rights Reserved.