Skip to content

Commit

Permalink
Release 4.2 (#849)
Browse files Browse the repository at this point in the history
* Copied release_4_2 which itself is a copy of dev and removed 2 accidental merges 61f4742, cb50317
* Fixed small bug in UI
* Merged from master
  • Loading branch information
DocGarbanzo committed Apr 28, 2021
1 parent f8463e1 commit c8c8dd1
Show file tree
Hide file tree
Showing 83 changed files with 4,003 additions and 493 deletions.
1 change: 0 additions & 1 deletion .github/workflows/python-package-conda.yml
Expand Up @@ -15,7 +15,6 @@ jobs:
include:
- os: macos-latest
ENV_FILE: install/envs/mac.yml

- os: ubuntu-latest
ENV_FILE: install/envs/ubuntu.yml
fail-fast: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/superlinter.yml
@@ -1,7 +1,7 @@
name: Super-Linter

# Run this workflow every time a new commit pushed to your repository
on: push
on: [push, pull_request]

jobs:
# Set the job key. The key is displayed as the job name
Expand Down
Binary file added docs/assets/RC_receiver.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/cuthere.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/driveshaft.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/encoder1.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/encoder2.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/encoder_inplace.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/encoder_wiring.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/lidar.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/lidar_angle.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/rc.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/rc_wiring.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/ui-car-connector-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/ui-pilot-arena.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/ui-trainer.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/ui-tub-manager-2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/ui-tub-manager.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions docs/guide/install_software.md
Expand Up @@ -41,6 +41,10 @@ This guide will help you to setup the software to run Donkeycar on your Raspberr
* Setup [Jetson Nano](robot_sbc/setup_jetson_nano.md)
![donkey](/assets/logos/nvidia_logo.png)

## [Optional] Use the Intel Realsense T265 localization sensor instead of a RPi camera

Read [this](/guide/robot_sbc/intelt265) for more information.

## [Optional] Use TensorRT on the Jetson Nano

Read [this](/guide/robot_sbc/tensorrt_jetson_nano) for more information.
Expand Down
45 changes: 45 additions & 0 deletions docs/guide/robot_sbc/intelt265.md
@@ -0,0 +1,45 @@
# A Guide to using the Intel Realsense T265 sensor with Donkeycar

----

* **Note** Although the Realsense T265 can be used with a Nvidia Jetson Nano, it's a bit easier to set up with a Raspberry Pi (we recommend the RPi 4, with at least 4GB memory). Also, the Intel Realsense D4XX series can also be used with Donkeycar as a regular camera (with the use of its depth sensing data coming soon), and we'll add instructions for that when it's ready.

Original T265 path follower code by [Tawn Kramer](https://github.com/tawnkramer/donkey)
----

## Step 1: Setup Donkeycar

## Step 2: Setup Librealsense on Ubuntu Machine

Using the latest version of Raspian (tested with Raspian Buster) on the RPi, follow [these instructions](https://github.com/IntelRealSense/librealsense/blob/master/doc/installation_raspbian.md) to set up Intel's Realsense libraries (Librealsense) and dependencies.

## Step 3: Setup TensorRT on your Jetson Nano

After you’ve done that, set up the directory with this:

```donkey createcar --path ~/follow --template path_follower
Running
``` cd ~/follow
python3 manage.py drive```

Once it’s running, open a browser on your laptop and enter this in the URL bar: http://<your nano’s IP address>:8887

The rest of the instructions from Tawn’s repo:

When you drive, this will draw a red line for the path, a green circle for the robot location.
Mark a nice starting spot for your robot. Be sure to put it right back there each time you start.
Drive the car in some kind of loop. You see the red line show the path.
Hit X on the PS3/4 controller to save the path.
Put the bot back at the start spot.
Then hit the “select” button (on a PS3 controller) or “share” (on a PS4 controller) twice to go to pilot mode. This will start driving on the path. If you want it go faster or slower, change this line in the myconfig.py file: THROTTLE_FORWARD_PWM = 530
Check the bottom of myconfig.py for some settings to tweak. PID values, map offsets and scale. things like that. You might want to start by downloading and using the myconfig.py file from my repo, which has some known-good settings and is otherwise a good place to start.
Some tips:

When you start, the green dot will be in the top left corner of the box. You may prefer to have it in the center. If so, change PATH_OFFSET = (0, 0) in the myconfig.py file to PATH_OFFSET = (250, 250)

For a small course, you may find that the path is too small to see well. In that case, change PATH_SCALE = 5.0 to PATH_SCALE = 10.0 (or more, if necessary)

If you’re not seeing the red line, that means that a path file has already been written. Delete “donkey_path.pkl” (rm donkey_path.pkl) and the red line should show up

It defaults to recording a path point every 0.3 meters. If you want it to be smoother, you can change to a smaller number in myconfig.py with this line: PATH_MIN_DIST = 0.3
9 changes: 5 additions & 4 deletions docs/guide/robot_sbc/setup_raspberry_pi.md
Expand Up @@ -220,10 +220,11 @@ cd donkeycar
git checkout master
pip install -e .[pi]
pip install numpy --upgrade
wget "https://raw.githubusercontent.com/PINTO0309/Tensorflow-bin/master/tensorflow-2.3.1-cp37-none-linux_armv7l_download.sh"
chmod u+x tensorflow-2.3.1-cp37-none-linux_armv7l_download.sh
./tensorflow-2.3.1-cp37-none-linux_armv7l_download.sh
pip install tensorflow-2.3.1-cp37-none-linux_armv7l.whl

curl -sc /tmp/cookie "https://drive.google.com/uc?export=download&id=1DCfoSwlsdX9X4E3pLClE1z0fvw8tFESP" > /dev/null
CODE="$(awk '/_warning_/ {print $NF}' /tmp/cookie)"
curl -Lb /tmp/cookie "https://drive.google.com/uc?export=download&confirm=${CODE}&id=1DCfoSwlsdX9X4E3pLClE1z0fvw8tFESP" -o tensorflow-2.2.0-cp37-cp37m-linux_armv7l.whl
pip install tensorflow-2.2.0-cp37-cp37m-linux_armv7l.whl
```

You can validate your tensorflow install with
Expand Down
30 changes: 30 additions & 0 deletions docs/parts/controllers.md
Expand Up @@ -11,6 +11,36 @@ The default controller to drive the car with your phone or browser. This has a w

> Note: Recently iOS has [disabled default Safari](https://www.macrumors.com/2019/02/04/ios-12-2-safari-motion-orientation-access-toggle/) access to motion control.
## RC Controller
If you bought an RC car then it might have come with a standard 2.4GHz car radio and receiver as shown in picture below. This can be used to drive the car.
![wiring diagram](../assets/rc.jpg)

* Hardware setup

Using female-to-female jumper cables connect the following pins from your RC receiver to your RPi GPIO row as shown the diagram below
![wiring diagram](../assets/rc_wiring.jpg)

Any of the RC receiver's + pin should go to any of the RPi's 3v pins. Any of the receiver's - pins can go to any RPi ground pin.

For the three RC channels, CH-1 is for steering, CH-2 for throttle and CH-3 is linked to a press button on the remote control. The default connections are steering: GPIO 26, throttle: GPIO 20, channel 3 (for record deletion): GPIO 19.

* Software setup

You must have `pigpio` installed. Do so with these commands: `sudo apt update && sudo apt install python3-pigpio && sudo systemctl enable pigpiod & sudo systemctl start pigpiod`

The `basic` template which you install with `donkey createcar --path ~/mycar --template basic` has an additional function `manage.py calibrate` which you should use to zero your angle and throttle PWM signal.

> Note: The PWM signal drifts over time. Hence check your calibration regularly before starting recording.
To use RC control, change 'USE_RC' to 'True' in your myconfig.py file in your mycar directory. If you used different GPIO pins than the above, you can set them here, too.

```#RC CONTROL
USE_RC = True
STEERING_RC_GPIO = 26
THROTTLE_RC_GPIO = 20
DATA_WIPER_RC_GPIO = 19
```

## Joystick Controller

Many people find it easier to control the car using a game controller. There are several parts that provide this option.
Expand Down
1 change: 1 addition & 0 deletions docs/parts/keras.md
@@ -1,3 +1,4 @@

# Keras Parts

These parts encapsulate models defined using the [Keras](https://keras.io/) high level api. They are intended to be used with the Tensorflow backend. The parts are designed to use the trained artificial neural network to reproduce the steering and throttle given the image the camera sees. They are created by using the [train command](/guide/train_autopilot/).
Expand Down
38 changes: 38 additions & 0 deletions docs/parts/lidar.md
@@ -0,0 +1,38 @@
# Lidar

A Lidar sensor can be used with Donkeycar to provide obstacle avoidance or to help navigate on tracks with walls. It records data along with the camera during training and this can be used for training

![Donkey lidar](../assets/lidar.jpg)
## Supported Lidars

We currently only support the RPLidar series of sensors, but will be adding support for the similar YDLidar series soon.

We recommend the [$99 A1M8](https://amzn.to/3vCabyN) (12m range)


## Hardware Setup

Mount the Lidar underneath the camera canopy as shown above (the RPLidar A2M8 is used there, but the A1M8 mounting is the same). You can velcro the USB adapter under the Donkey plate and use a short USB cable to connect to one of your RPi or Nano USB ports. It can be powered by the USB port so there's no need for an additional power supply.

## Software Setup

Lidar requires the glob library to be installed. If you don't already have that, install it with `pip3 install glob2`

Also install the Lidar driver: `pip3 install rplidar`

Right now Lidar is only supported with the basic template. Install it as follows:

`donkey createcar --path ~/lidarcar --template basic`

Then go to the lidarcar directory and edit the myconfig.py file to ensure that the Lidar is turned on. The upper and lower limits should be set to reflect the areas you want your Lidar to "look at", omitting the areas that are blocked by parts of the car body. An example is shown below. For the RPLidar series, 0 degrees is in the direction of the motor (in the case of the A1M8) or cable (in the case of the A2M8)

```
# LIDAR
USE_LIDAR = True
LIDAR_TYPE = 'RP' #(RP|YD)
LIDAR_LOWER_LIMIT = 44 # angles that will be recorded. Use this to block out obstructed areas on your car and/or to avoid looking backwards. Note that for the RP A1M8 Lidar, "0" is in the direction of the motor
LIDAR_UPPER_LIMIT = 136
```
![Lidar limits](../assets/lidar_angle.png)


62 changes: 62 additions & 0 deletions docs/parts/odometry.md
@@ -0,0 +1,62 @@
## Odometry

Odometry is a way to calculate the speed and distance travelled of the car by measuring the rotation of its wheels using a sensor called an rotary encoder. This encoder can be on the motor, on the main drive shaft or on individual wheels. The advantage of using an encoder is that it "closes the loop" with your throttle, so your car can reliably command an actual velocity rather than just issuing a motor control which will produce a faster or slower velocity depending on the slope of the track, the surface or mechanical friction in your drive train while turning. In short, an encoder gives you much better control over your speed.

Encoders come in various forms:
* Quadrature encoders use hall-effect sensors to measure magnetic pulses as the shaft turns, and have the advantage of being very precise as well as being able to tell the difference between forward and reverse rotation
* Single-output encoders are like quadrature encoders but they can not determine the direction of motion
* Optical encoders are typicall a LED/Light sensor combo with a disk that has slots cut in in-between them. As the disk rotates, the light is interruprted and those pulses are counted. These sensors are cheap and easy to install but cannot determine the direction of rotation

There are several ways to read encoders with Donkey:
* Directly with the RaspberryPi's GPIO pins. This is best for optical encoders, since they don't generate as many pulses as a quadrature encoder and the RPi will miss fewer of them as it task-swaps between the various Donkeycar parts
* With an Arduino or Teensy. This is best for quadrature encoders, since the Arduino/Teensy is 100% devoted to counting pulses. It transmits the count to the RPi via the USB serial port when requested by Donkeycar, which lightens the processing load for the Rpi
* With an Astar board. This is just a fancy Arduino, but if you have one, it makes for a neat installation


## Supported Encoders

Examples of rotary encoders that are supported:

* Optical encoder sensors and discs [Available from many sources on Amazon](https://amzn.to/3s05QmG)
* Quadrature encoders. [Larger, cheaper](https://amzn.to/3liBUjj), [Smaller, more expensive](https://www.sparkfun.com/products/10932)

## Hardware Setup

How you attach your encoder is up to you and which kind of encoder you're using. For example, [here's](https://diyrobocars.com/2020/01/31/how-to-add-an-encoder-to-the-donkeycar-chassis/) one way to put a quadrature encoder on the main drive shaft. [Here](https://guitar.ucsd.edu/maeece148/index.php/Project_encoders) is a more complex setup with dual encoders.

But this is the easiest way to do it, with a cheap and simple optical encoder on the main drive shaft of a standard Donkeycar chassis (if your chassis is different, the same overall approach should work, although you may have to find a different place to mount the sensor):

First, unscrew the plate over the main drive shaft. Tilt the rear wheels back a bit and you should be able to remove the shaft.

![drive shaft](../assets/driveshaft.jpg)

Now enlarge the hole in the optical encoder disc that came with your sensor (use a drill or Dremel grinding stone) so you can slip it onto the shaft. Stretch a rubber grommet (you can use the sort typically included with servos to mount them, but any one of the right size will do) over the shaft and push it into the encoder disc hole. If you don't have a grommet, you can wrap tape around the shaft until it's large enough to hold the disc firmly. Once you've ensured it's in the right place, use a few drops of superglue or hot glue to hold it in place)

![drive shaft](../assets/encoder1.jpg)

![drive shaft](../assets/encoder2.jpg)

Cut out a small notch (marked in pencil here) in the plate covering the drive shaft, so you can mount the encoder sensor there, ensuring that the disc can turn freely in the gap in front of the steering servo

![drive plate](../assets/cuthere.jpg)

Now replace the plate and drill two holes so you can screw in the encoder sensor. Slide the disc along the shaft so that it doesn't bind on the sensor.

![drive plate](../assets/encoder_inplace.jpg)

Use three female-to-female jumper cables and connect the sensor to your RPi GPIO pins as follows. Connect the GND, V+ (which might say 5V or 3.3V) and data pin (which will say "Out or "D0") to the RPi 5V, Ground and GPIO 13 as shown here (if your sensor encoder has four pins, ignore the one that says "A0"):
![wiring diagram](../assets/encoder_wiring.jpg)


## Software Setup

Enable odometry in `myconfig.py`.

```HAVE_ODOM = True # Do you have an odometer/encoder
ENCODER_TYPE = 'GPIO' # What kind of encoder? GPIO|Arduino|Astar
MM_PER_TICK = 12.7625 # How much travel with a single tick, in mm. Roll you car a meter and divide total ticks measured by 1,000
ODOM_PIN = 13 # if using GPIO, which GPIO board mode pin to use as input
ODOM_DEBUG = False # Write out values on vel and distance as it runs
```

If you are using an Arduino or Teensy to read your encoder, select 'Arduino' in the myconfig.py file libe above. The microcontroller should be flashed using the Arduino IDE with [this sketch](https://github.com/zlite/donkeycar/tree/master/donkeycar/parts/encoder/encoder). Make sure you check the sketch using the "test_encoder.py code in the Donkeycar tests folder to make sure you've got your encoder plugged into the right pins, or edit it to reflect the pins you are using.

0 comments on commit c8c8dd1

Please sign in to comment.