Rear View Camera for an Electric Wheelchair

1,445

19

3

Introduction: Rear View Camera for an Electric Wheelchair

My brother uses an Invacare TDX electrical wheelchair, which is easy to maneuver in
all directions, but due to limited visibility to the back it is difficult to drive backwards in limited spaces. Goal of the project is to build a rear view camera using IP streaming to a mobile phone, which is mounted close to his stearing joystick.

Needed components:

  • power supply and distribution using the wheelchairs power
  • rear view camera and video streamer
  • mobile phone holder for the conrol pad.

Power is supplied by the wheelchair itself, which uses 24V lead batteries. The charging port is misused to plug in a power converter to USB, which powers the Raspberry responsible for the streaming and also powers the mobile phone if needed.

Streaming is done by a Raspberry Pi Zero W, which serves as a wireless access point and streams the video to any device connected to the wireless network.

The mobile phone to display the image is mounted with a 3d printed adapter to the wheelchair control unit.

To follow this project you will need some basic knowledge of Debian/Linux, as the configuration requires some manual work. It is however not too dificult, so give it a shot - if you are unsure there are hundreds of tutorials on Linux which can help you.

Step 1: Parts Needed

Raspberry Pi Zero W:Main component for streaming video

SainSmart Wide Angle Fish-Eye Camera Lenses for Raspberry Pi: Arduino Camera compatible wide angle camera (170° FOV)

2 × Plastic housings: One smaller housing for the raspberry and the camera, one bigger housing for the power distribution

XLR Plug: To connect to the charging port of the wheelchair

Car USB Port (eg. TurnRaise 12-24V 3.1A): A 24V to USB converter in a small housing for car and motorcycle use. Can be anything which uses 24V input and provides USB output.

Various Cables:

  • Power cable to route from XLR port to backside of wheelchair,
  • USB cable to supply Raspberry

3D printed adapter for Phone A 3d printed adapter to the wheelchair control unit which serves as base for a standard car mobile phone holder: https://www.thingiverse.com/thing:2742683

Car mobile phone holder: A mobile phone holder which can be attached to a flat surface (eg. a dashboard phone holder). I used one from Hama, a german manufacturer.

Step 2: Setting Up the Raspberry Camera

Install Raspbian from https://www.raspberrypi.org/downloads/raspbian/ following the instructions from https://www.raspberrypi.org/documentation/installation/installing-images/README.md

Install all updates by running the following two commands from a terminal:

sudo apt-get update

sudo apt-get dist-upgrade

Shut down, connect the camera. Start the raspberry again.

In the Raspberry Setup panel enable the camera and enable SSH access to the raspberry. The sainsmart camera works as the official Pi camera, you can follow the instructions found here: https://www.raspberrypi.org/learning/addons-guide... Unfortunately you are not done yet. We need a v4l driver for the raspi-cam, which is not enabled out of the box. First you should do a firmware update of your raspberry to get the latest firmware and kernel driver - run the following in a terminal:

sudo raspi-update

You need to load the v4l kernel driver now by typing into a terminal:

sudo modprobe bcm2835-v4l2

If this worked without error messages, you should now have a device /dev/video0, check with

ls - l /dev/vid*

If this worked, add bcm2835-v4l2 to /etc/modules to enable the module at each start.

You can check that the camera works with the command:

raspistill -o cam.jpg

Step 3: Install V4l2rtspserver

First, you need to install cmake, as we will compile the video streaming program ourselves:

sudo apt-get install cmake

For streaming we use v4l2rtspserver as it showed the lowest latency in our trials. You can get the code from https://github.com/mpromonet/v4l2rtspserver

Install it with:

git clone https://github.com/mpromonet/h264v4l2rtspserver.git

cd h264v4l2rtspserver

cmake .

make install

Everything should finish without errors and you can test it now by starting the streaming server from a terminal:

v4l2rtspserver -W 352 -H 288 -F 10 /dev/video0

Connect with VLC on a computer in the same network to the raspberry: rtsp://<IP_ADDRESS>:8554/unicast to check if the streaming is working.

Create a script called launcher.sh in your home directory using your favorite editor (which should be vi):

!#/bin/bash
sleep 20
v4l2rtspserver -W 352 -H 288 -F 10 /dev/video0

The sleep command is needed to allow the video driver to become ready. Probably it can be set to less than 20 seconds....

Add this script to your crontab with "crontab -e" and adding:

@reboot sh /home/pi/bbt/launcher.sh >/home/pi/logs/cronlog 2>&1

This should start the streaming at each start automatically.

Alternatives for streaming:

There are a couple of alternatives to use for streaming video, I tried motion and vlc. Motion is a webcam tool which detects motion, so it performs additional image analysis on the images and probably is a bit slower than just streaming.

VLC works out of the box without any additional compilations:

cvlc v4l2:///dev/video0 --v4l2-width 320 --v4l2-height 200 --v4l2-chroma h264 --sout '#standard{access=http,mux=ts,dst=0.0.0.0:12345}'

This command streams an h264 encoded video via http on port 12345. Latency is somewhat about 2 seconds in our test setup.

Step 4: Set Up the Raspberry As a WiFi Access Point: Part 1 - Hostapd

This step sets your Raspberry as an Access Point. After this, you are no longer connected to your network but the Raspberry opens up it's own WiFi Network. In case of mistakes, you need to have access to the Raspberry with a keyboard and a display, so do this before you bury the raspberry in a housing somewhere...

I am following the method described here: https://frillip.com/using-your-raspberry-pi-3-as-...

Install hostapd and dnsmasq:

sudo apt-get install dnsmasq hostapd

Disable dhcp on the interface wlan0 by adding the following line to /etc/dhcpd.conf (preferably at the top)

denyinterfaces wlan0

Configure a static IP for the wlan0 interface by editing /etc/network/interfaces to include the following:

allow-hotplug wlan0
iface wlan0 inet static
address 172.24.1.1
netmask 255.255.255.0
network 172.24.1.0
broadcast 172.24.1.255

Restart the dhcp daemon with sudo service dhcpcd restartand then reload the wlan0 config with

sudo ifdown wlan0; sudo ifup wlan0

Save the attached hostapd.conf under /etc/hostapd/hostapd.conf (after you have checked the contents and adapted it to your likings - you should at least change the SSID and the passphrase to something more secure).

You can now check if it works by running:

sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf

You should be able to connect to the new network, but you won't get an IP address yet. Stop hostapd by hitting CTRL-C. Enable the automatic start of hostapd by editing /etc/default/hostapd and adding the configuration file location by changing the corresponding line to

DAEMON_CONF="/etc/hostapd/hostapd.conf"

Step 5: Set Up the Raspberry As a WiFi Access Point: Part 2 - Dnsmasq

Move the provided dnsmasq config to a backup file (as it contains a lot of comments, you can still use it for reference):

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig

Then create a new /etc/dnsmasq.conf with the following content:

server=8.8.8.8 # Forward DNS requests to Google DNS
domain-needed # Don't forward short names
bogus-priv # Never forward addresses in the non-routed address spaces.
dhcp-range=172.24.1.50,172.24.1.150,12h # Assign IP addresses between 172.24.1.50 and 172.24.1.150 with a 12 hour lease time

Binding the dnsmasq service to a specific address lead to some problems in our installation, so we just let it run on all interfaces. As the raspberry Pi Zero W only has WiFi this is no problem unless you connect a USB Ethernet interface... (in this case you would also have a dhcp server on this interface, so this might mess up the network you connect to with a cable).

You do not need to do any extra steps to run dnsmasq at startup, it automatically starts. However you should test everything before you do a reboot by starting both services manually and check that you can connect to the WiFi and get an IP address (you can also tell your mobile phone that this WiFi does not have internet and that this is fine):

sudo service hostapd start
sudo service dnsmasq start

Step 6: ​Check the Software

Now that you have configured everything it is time to do a short check (before everyhting is more difficult to access). Reboot the raspberry.

Connect to the WiFi if the raspberry with your mobile phone. Connect a streaming video client (e.g. VLC which exists for all operating systems) to the stream of the raspberry by selecting "Network stream" and connecting to rtsp://<IP_ADDRESS>:8554/unicast ( <IP_ADDRESS> is the IP of your device, if you did not change it it is 172.24.1.1).

You should see some live video from the camera now... (I had some issues with VLC for android, but VLC for iOS worked smoothly - I did not further investigate the android version as my brother uses iOS).

Step 7: Making the Power Supply

The invacare control uses what seems to be a standard for powered wheelchairs. The connector is a standard XLR connector as used for microphones. Pin 1 is positive, Pin 2 negative. Invacare has two additional pins for communication, but we are not going to mess around with these...

Connect the XLR connector to the USB power adapter and fit everything in a box. To feed the cable to the box, a feedthrough is a good idea. Make sure that the cable is long enough to be routed from the wheelchair control module to the back rest where you will attach the power supply box. You can route the cables following the cables of the control module to ensure that they are not caught anywhere in a movable part.

Step 8: Building the Box for the Camera

Build a box which fits the raspberry pi and the camera. The box needs a hole on the side to route the USB power cable through and a hole for the camera which is large enough to not obstruct the view. I mounted the camera on a roughly 45° angle so that it points downwards to be able to see the back wheels of the wheelchair. I used a standard plastic box into which I cut some holes, but you can also 3D print a fancier version (maybe for Version 2)

Step 9: Make the Phone Holder

To attach the mobile phone to the wheelchair I 3d-printed an adapter plate which can be found here: https://www.thingiverse.com/thing:2742683 (the STL file is also attached). It is attached to the wheelchair control unit. On this plate you can glue any car phone holder, which you can get for cheap anyhwere.

Step 10: Assemble Everything and Try It Out

Now it is time to assemble everything:

Attach the camera-box somewhere at the back of the wheelchair where the view is not obstructed and the camera is pointing backwards. Attach the power supply box somewhere at the back where it is not in the way. Connect the USB cable from the Raspberry to the power box. Connect the power box with the XLR plug to the charging port at the wheelchair control unit. Everything should start up now.

Install VLC on your mobile phone (if you haven't done it yet...) and connect to the Raspberry via rtsp://<IP_ADDRESS>:8554/unicast

You should now see the camera image on your mobile phone :-)

Put the mobile phone holder on the wheelchair control unit and secure the phone on it. And this is it, you are done!

Raspberry Pi Contest 2017

Second Prize in the
Raspberry Pi Contest 2017

Share

    Recommendations

    • Tiny Home Contest

      Tiny Home Contest
    • Metalworking Contest

      Metalworking Contest
    • Fix It! Contest

      Fix It! Contest

    3 Discussions

    very cool! I was looking for someone who connected a SainSmart fish eye to the RasPiZeroW. I seem to not be able to detect this camera, although the pi camera module v1.2 has no problems. Was there anything special you had to get this camera to work? Thanks In advance and also great Video!

    That would be really useful :) Great idea!

    1 reply