Skip to content

Commit

Permalink
Merge pull request #114 from PolySync/add/FP-12-joystick-commander-ad…
Browse files Browse the repository at this point in the history
…d-socketcan

Add socketCAN support into joystick commander
  • Loading branch information
LucasBuckland authored Jul 24, 2017
2 parents 4e4cb14 + bc8f36e commit 06515cb
Show file tree
Hide file tree
Showing 4 changed files with 277 additions and 241 deletions.
35 changes: 9 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,6 @@ Install the SDL2 library with the command below.
sudo apt install libsdl2-dev
```

Install the CANlib SDK via the following procedure.

[CANlib-SDK](https://www.kvaser.com/linux-drivers-and-sdk/)

## Building Joystick Commander

Navigate to the directory for the joystick commander code.
Expand All @@ -397,7 +393,7 @@ Navigate to the directory for the joystick commander code.
cd utils/joystick_commander
```

Once you are in the home directory of the joystick commander, build the code using CMake.
From this directory, run the following sequence to build joystick commander:

```
mkdir build
Expand All @@ -406,37 +402,24 @@ cmake ..
make
```

Now that the joystick commander is built it is ready to be run. However, we need to determine what
CAN interface the control CAN bus is connected to on your computer. This interface will be passed to
the joystick commander as an argument, and will be used to allow the joystick commander to communicate
with the CAN bus. To figure out what CAN interface your control CAN bus is connected to, navigate to
the examples directory in the CANlib install.

```
cd /usr/src/linuxcan/canlib/
```
Once you have initialized the CAN interface, you can use the channel number to start joystick commander and begin sending commands to the OSCC modules.

Run make to ensure all the CANlib examples are built.
For example, with a Kvaser Leaf Light attached, using a bitrate of 500000:

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

Then navigate to the examples directory of the CANlib install.

```
cd /usr/src/linuxcan/canlib/examples/
```

You can use the "listChannels" and "canmonitor" examples to determine which CAN channel your control
bus is connected to. CAN monitor will dump any data on a selected channel and list channels will tell
you what channels are available. You can use both to determine which channel you will need to use.
Once you know the correct channel number, you can run the joystick example with the command below.
You would then run:

```
./joystick-commander <channel-number>
./joystick-commander 0
```

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

## 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.
Expand Down
4 changes: 2 additions & 2 deletions utils/joystick_commander/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ target_include_directories(
target_link_libraries(
joystick-commander
PRIVATE
${SDL2_LIBRARIES}
canlib)
${SDL2_LIBRARIES})

2 changes: 1 addition & 1 deletion utils/joystick_commander/src/commander.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@



#include <canlib.h>
#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <math.h>
Expand Down
Loading

0 comments on commit 06515cb

Please sign in to comment.