Introduction: Setting Up the Zybot Server
Now that we have our Zybot set up and the firmware installed, we can set up our server script and get our webcam working! This is part of the Zybot collaboration, so be sure to check out the other Instructables. The previous instructable is here. (Setting Up the Zybot-Software)
The plan for this Instructable is to have the webcam send a "video" to an IP address. That way a computer that's on the same server can view what the robot sees.
Note: If you have your WIFI adapter plugged in, be sure to unplug it while your are connected to the Ethernet Cable.
Open up your terminal, and enter the commands:
sudo apt-get update
sudo apt-get install linux-firmware motion
Step 1: Putting the Files Into Home
When you boot up your ZYBO and it gets to the main screen, a disk symbol should pop up, this is the ZYBO_BOOT partition in the Micro SD card. Open up your folders and drag and drop files.zip into the Home folder. Then extract into home.
Step 2: Building Your Server and Motion File
Now that the Micro SD card is plugged back into the ZYBO, we want to build server.cpp.
- Press CTRL+ALT+t on the keyboard to open up a terminal
- In the terminal, enter the command cp files/server.cpp Documents/server.cpp
- This copies server.cpp into our documents folder.
- In the terminal, enter the command cp files/usbreset.c Documents/usbreset
This copies usbreset.c into our documents folder.
Enter the command cd Documents
Run g++ server.cpp -o server
- This will generate the executable file that our script will use. Build server.cpp.
- gcc usbreset.c -o usbreset
- This code will reset the usb that is attached to the WIFI Adapter.
Step 3: Replacing the Motion.conf File
Now we are going to replace our motion file. To do this we want to run the following commands:
- This will take us back to the base directory
- sudo rsync -a files/motion.conf /etc/motion/motion.conf
rsync will change the motion.conf file, this is going to make our webcam to JPEG photos and send them to an IP address (we will go over this in a later step).
Step 4: Putting the Server_script File Into Init.d
The last thing we want to set up is the script. Just like replacing the motion file, all we have to do is run rsync again.
- sudo rsync -a files/server_script /etc/init.d/server_script
This will create a copy of the server_script file and place it into init.d.
Step 5: Building Everything
The last thing we have to do is update everything, that way all the changes we made will take effect.
Run the following commands:
- chmod +x /etc/init.d/server_script
- This will change server_script into an executable file. Before chmod, we couldn't use server_script with anything.
- sudo update-rc.d -f server_script defaults
- Here we add the server_script into the startup of our ZYBO. This runs the files we've added and will start the webcam and reset the WIFI adapter!
Now restart your Zybo, and everything should be ready to go! (If your Wifi Adapter is not working, just unplug it and plug it back in)
Step 6: Viewing Your Webcam
Now that everything is set up, our webcam should automatically start sending images to an IP address.
To find this web address enter the command ifconfig.
Look for the wlan0 line, then the inet addr: line and that will give the IP address to use. Now you can go onto any Firefox browser and enter that IP address (add :8081 at the end of the address) and see what your Zybot sees.
We can move onto the next Instructable in the collection! (Setting up the Zybot - Power Considerations)