Tutorial (Catenary)

From Lofaro Lab Wiki
Jump to: navigation, search

Twop3dxs 1.jpg

Materials Needed

Two P3DXs, Two Raspberry PI 2 Model B V1.1, Two microSD cards (both have to be same size; 32GB and 32GB) for the Raspberry Pis, two wifi adapters (we used Trendnet TEW-648UBM wireless adapters fro MicroCenter), a 60 inch chain from HomeDepot

Setup the PI

1. Flash the microSD card using the image file from this link: image link

After you download the zip file from the provided link, extract it to get the image file.

To write the image on the microSD card, we used the software Win32Disk Disk Imager, which can be downloaded from this link: Win32 Link

Once downloaded, install Win32 and run it. Then click the folder icon to locate and select the image file that was previously downloaded. Now make sure that the microSD card is inserted at this point. Then on the device drop-down menu, select the name/directory of the microSD card. Finally click the write button to start writing the image onto the card. It will take a while to write, so take a break and grab a donut.

2. After the image has been written on the microSD card, insert the card in the Raspberry Pi 2. Also, connect the wireless adapter to the Pi. Finally, connect the Pi to a power source via the microUSB port.

If the wireless adapter does not turn on or connect to network, follow these steps:

Since we cannot ssh to pi from our computer because the wifi adapter is not working, connect the pi to an lcd monitor via HDMI and boot it up there.

2. Once booted, login with the username rpi2 and password (not shown here. Ask people at the lab).

3. Then on the terminal go to the root directory, and edit the network interface file:

   cd ~/ 
   nano /etc/network/interfaces

Install RPi.GPIO 0.6.2 module on the Pi

We need to install this module in order to read the GPIO pins on the pi so that we can get the digital potentiometer values being sent from the MCP3008 ADC.

To install the RPI.GPIO module enter this on the pi terminal:

   pip install https://pypi.python.org/packages/source/R/RPi.GPIO/RPi.GPIO-0.6.2.tar.gz

Setup MCP3008 with the Pi

Make sure you have breadboard and jumper wires, two potentiometers installed on the mount on the P3DX. Follow this PDF: MCP3008 setup link

This video is also helpful: MCP3008 and Pi setup video

Note: Connect the signal terminal of the 1st potentiometer to pin0 on the MCP3008, and Vout terminal of the 2nd potentiometer to pin1 on the MCP3008.

Download the necessary files from Github

   git clone https://github.com/adriancabal/VanguardUAVSeniorDesign.git

After downloading the directory, move the necessary bash python files to the home directory. For the first P3DX pi, move the files from the folder named rpi1. For the second P3DX copy the files from the folder named rpi2. On the first P3DX pi, the otherthing file should have rosrun keyboardRealMover.py uncommented. To edit the otherthing files, do this:

   nano otherthing

3D print the potentiometer mount

Get the 3d printed mount file from the github repository downloaded from a previous step. Copy the file to a USB flash drive and connect it to the makerbot 3d printer. Printing the file will probably take a couple of hours or more to print.

After the mount is finished printing, next we install the potentiometers on the mounts.There are two mounts, one base mount for the yaw and one mount for the pitch. Use epoxy to permanently the potentiometers on the mounts.

1. Running the P3DXs

Now you should have a raspberry pi on each P3DX and make sure they are powered. On your terminal, ssh to both Pis. For each Pi, you will actually need to open multiple tabs on the terminal.

1.1 running the first P3DX

To run the first pi, open a new terminal and ssh to the 1st pi's ip address:

   ssh rpi2@192.168.(address of the 1st pi)

Once logged in, run . master:

   . master 

Open a new tab on the same terminal window, again ssh to the 1st pi, and run the otherthing script:

   . otherthing 

Again open a new tab on the same terminal window, again ssh to the 1st pi, and run the rosa script:

   . rosa  

Now you should be able to control the 1st P3DX using the keyboard arrow keys. Make sure that you are currently on the tab which is running the otherthing script and keyboardRealMover.py in order to be able to move the P3DX.

1.2 Running the second P3DX

Open a new terminal:

   ssh rpi2@192.168.(address of the 2nd pi)

Once logged in, run . master:

   . master 

Open a new tab on the same terminal window, again ssh to the 1st pi, and run the otherthing script:

   . otherthing 

On your desktop or laptop computer open a terminal , cd to the directory that contains the gui.py file, and run the gui.py.

   python gui.py 

Open a new tab on the same terminal window, again ssh to the 1st pi, and run the spi.py python script:

   sudo python spi.py 

After running spi.py, the gui should pop up on the destp and display the distance and orientation angle. But it won't start moving until you run .rosa script.

Again open a new tab on the same terminal window, ssh to the 1st pi, and run the rosa script:

   . rosa 

After you run .rosa, the second P3DX should start moving and maintaining distance to the 1st P3DX.