RoPod/Tutorials/ConnectingToRobot

From Control Systems Technology Group
Jump to navigation Jump to search

Entering Pico from terminal via the network

Go to your .bashrc-file (cd to ~) and add the following lines at the bottom:

source /opt/ros/kinetic/setup.bash
source ~/ropod-project/catkin_workspace/devel/setup.bash

export ROS_PACKAGE_PATH=~/ropod-project/catkin_workspace/:/opt/ros/kinetic/share
export ROS_IP=`hostname -I`

alias sshpico="ssh ropod@192.168.44.81"
alias sshpico-wired="ssh ropod@10.0.0.2"
alias pico-core='export ROS_MASTER_URI=http://192.168.44.81:11311'
alias pico-core-wired='export ROS_MASTER_URI=http://10.0.0.2:11311'

export ED_PLUGIN_PATH=~/catkin_ws/devel/lib
export ED_MODEL_PATH=~/ropod-project/catkin_workspace/src/functionalities/ED/ed_object_models/models

Here, some user-defined commands are given which actually execute some more complex ones. As the .bashrc is run each time you open a new terminal, you need to open a new terminal if you added these lines from your terminal. Now, connect to the AtHome-network (ask for the password). Running sshpico gives you access to pico in the ropod-user (again, ask for the password).

Once you are running some packages on the robot and you want to use the information published and topics (for example for visualization using rviz for example), then open a terminal and run pico-core. Now, from this terminal (where you run the pico-core command) you can use these data on your own pc.

Automatic key generation

If you want to prevent using a password each time you want to log in to Pico, you need to generate a key. Therefore, you can use an automatic key generator, for example using the method copied from | this site running the next set of command from your local desktop system:

ssh-keygen

Make sure to use the default for the keyname. We suggest that you do set a passphrase on that key, otherwise it's a security problem. "-t rsa" wouldn't be a bad idea, but probably isn't needed.

ssh-copy-id ropod@192.168.44.81

That will ask you for the password you'd use to log in, and sets up the authorized_keys stuff for you. (no need to do it by hand) Then, this:

ssh-agent

or maybe this:

exec ssh-agent sh

or:

exec ssh-agent bash

That will start up an SSH agent that can hold your key. On many modern Unix variants, if you're logged in graphically, this will already have taken place. The first variant (with the backticks) puts an ssh-agent into the background and sets up the environment variables to talk to it. The second two have the agent run a shell for you, so that when you exit the shell, the agent exits. Many modern Unix variants will already have an agent running for you, especially if you logged in graphically. You might try "ps aux | grep ssh-agent" or "ps -ef | grep ssh-agent"; if something is already running, use that. Then, finally:

ssh-add

It will ask for a passphrase; give it the one you gave ssh-keygen. There's also ways to make it ask graphically. And you can put the ssh-agent and ssh-add stuff into your login scripts (setup is different depending on shell you use) to automate this, but some Unix variants (current Ubuntu Linux, for instance) do most of that automatically, so that all you really need to do is create a key and use ssh-copy-id to set it up on the remote host:

ssh-copy-id -i ~/.ssh/id_rsa.pub remote-user@remote-host

which in our case should be

ssh-copy-id -i ~/.ssh/id_rsa.pub ropod@192.168.44.81

Now, "ssh ropod@192.168.44.81" (or sshpico in our case!) should work without asking for any authentication. Behind the scenes, it's using a key that the ssh-agent is holding, and asking the agent to do the magic signing tricks for it.