We have seen how to control the Pi Rover over HTTP. However, you may find it a bit of an overkill to install a webserver bundled with PHP just to control the motors. A leaner alternative would be to remotely execute commands over SSH. We assume a Unix-like OS on which you can run the SSH client from the command line (e.g. Linux, OS X, Windows with CygWin).
Set up a password-less login
Of course, SSH needs to be enabled on the Raspberry Pi. You can do this using raspi-config:
Navigate to SSH and enable the server.
Once you have logged in successfully from the client system generate the public and private RSA keys:
You can use the default values and leave the passphrase empty for a completely password-less login.
Copy the new key to the Raspberry Pi. In this example the Pi is at IP 192.168.1.12 and the remote user is ‘pi’.
On the Raspberry Pi a simple Python script sends commands and data (taken from the command line) to the motor controller:
A shell script that we will call over SSH translates movement commands into the arguments taken by the Python script:
In our client script, instead of posting a payload over HTTP, we simply call the shell script with the appropriate arguments:
def send(): Popen(['ssh', 'firstname.lastname@example.org', '/home/pi/move.sh %s %s' % (command_data.command, command_data.data)])