I am working on a small robot that is driven using a joystick. As of now the joystick is connected to the Pi via USB and is driving the servos as intended. What I would like to do is get rid of the joystick attached to the Pi so that the robot can drive wireless around within range of a WiFi signal. I would like to attach the joystick to a laptop running Mac OS or Linux and drive the robot from there. What are my options? I have never spent much time learning about advanced network technology so this is new to me. If someone could tell me what my options are and maybe some resources explaining it I would very much appreciate the help. Thanks
4 Answers
I have a potential solution for you. We have written a script for doing this with a PicoBorg as the control board called RemoteJoyBorg.py, found here.
It should be easy enough to change the code to control a different drive board, or the network messages to send different data if required.
The code is all free to use for any purpose, we just ask that you mention us if you publish it as part of anything :)
This sounds like an awesome project.
First of all, you are going to need a way to control the robot via wifi. You need to buy a robotic wifi controller.
You will need to make a program which can communicate with the Robot / Pi. Since you only need to deal with low-level stuff, I recommend checking out the socket module. If you would prefer to use c, you can use their sockets.
To get a video feed, have the Pi start a VNC server, connect to it, and then open up a basic webcam viewer (easy to make yourself with OpenCV, if your up for it).
For tutorials, parts and more, you can use PiBorg.
I wish you luck on this awesome project.
http://raspberrytank.ianrenton.com/
I found this on a site with a bunch of RPi projects. I think it's pretty cool, and it seems to be along the lines of what you want to do, with the WiFi aspect anyway. Not sure if you were planning on making a fully autonomous tank though... ;) He can control the tank via WiFi on his iPhone, so it could be another way to do your project.
I am doing a very similar project, however i decided to start off at a more basic level of control using arrow keys. I assume that you already have a small wifi dongle for your robot? and intend on using your home wifi network?
The next stage is to decide on the type of interaction you wish to achieve. if you are not after providing GUI or dont mind a slow response you can use an SSH program (command line) or a VNC server(Pi GUI) being run on your stationary computer alos connected to the same wifi network. Or do you wish to run the program to recieve your controls on your local computer and then simply send the comands to a smaller recieving program that implements them?
I personally chose the second option and proceeded to create 2 seperate programs.
- PiBotController (deals with user input and is a client to the server running from my pi)
- PiBotReciever (This is the server which waits for the commands to be sent to it)
I chose to use a Socket server for simplicity. The server runs constantly whent the robot is active and waits for commands to be sent to predetermined 'sockets'.
The code for the server and client side of this and some of my controller is here;
I have yet to implement the control side within the server as i have been trying to optimise the client such that is doesnt send excessive data when no variables are changing.
-
I have actually gotten this project working I just need to build the frame for the bot first. I created two
C
programs a client and a server that open sockets and send a constant data stream over wifi. I used the linux joystick API to get the commands from the joystick which sends them as integers into the Pi. It works excellent! Commented Aug 22, 2013 at 18:02 -
ahh very impressed! unfortunately i don't know any C, i have the socket client working and sending data over wifi and the server receiving however i am now having issues using the variables inside my socket server class in any of my other functions!! must be an obvious solution but its escaping me XD– D MasonCommented Aug 22, 2013 at 21:46