Using a Raspberry Pi and an Ethernet cable - tonydle/ur3_unity_sim GitHub Wiki

raspberry_pi_with_ethernet

Using a Raspberry Pi and an Ethernet cable is currently our recommended way of setting up a ROS Network for the UR3 Unity Simulation. It provides a low latency network condition (< 1ms), which helps with performance and also does not take up space on your machine.

Contents
  1. Requirements
  2. Installation
  3. Using UR3Sim

1. Requirements

You will need:

  • 1x Raspberry Pi 4 or Raspberry Pi 3B+
  • 1x USB-C or micro-USB charging cable for the Pi 4 / 3B+ respectively
  • 1x Ethernet cable (CAT6)
  • 1x Micro SD Card with at least 16GB of memory
  • (Optional) 1x SD Card reader - if your computer does not have a micro SD card slot
  • (Optional) 1x Ethernet-to-USB adapter - if your computer does not have an Ethernet port

2. Installation

2.1 Installing a custom Ubuntu image onto the Raspberry Pi

  1. Download our Ubuntu image for the Raspberry Pi. It comes with pre-installed ROS Kinetic, as well as the required package (file_server from ROS#)
    • Our image is based on Ubiquity Robotics' Raspberry Pi image. You can also download that image here and manually install ROS#.
  2. Download an SD card image flasher. In the following steps we will be using balenaEtcher
  3. Insert the micro SD card into your PC with the card reader
  4. Select the downloaded image and the correct drive by looking at the storage size
  5. Click Flash and wait for it to complete balenaEtcher
  6. Remove the micro SD card from your PC and insert it into the Raspberry Pi

⚠️ DO NOT TURN ON THE RASPBERRY PI YET ⚠️

2.2 Configuring the Windows PC's Ethernet IP Address

  1. Go to Control Panel's "Network Connections" by searching for "View network connections"
    • Alternatively, you can go to Control Panel -> Network and Internet -> Network and Sharing Centre -> Change adapter settings (left menu) ethernet_properties
  2. Right-click on Ethernet -> Properties -> Internet Protocol Version 4 (TCP/IPv4) -> Properties ethernet_ipv4
  3. Tick "Use the following IP address" and choose an IP address that is 192.168.x.1, where x is 0-255
    • For this example we are using 192.168.2.1
  4. Put in 255.255.255.0 for the Subnet mask
  5. Leave the other fields empty. Click "OK" and close all Windows ethernet_windows_ip

2.3 Installing a DHCP server on the Windows PC

  1. Download the latest version of DHCP Server for Windows
  2. Unzip and run dhcpwiz.exe
  3. Click Next -> Choose "Ethernet" -> Next -> Next

dhcpwiz_ethernet

  1. In "Configuring DHCP for Interface" / Configuration / IP-Pool, enter the IP Address you chose (192.168.2.1)
  2. Choose "1 Year" for the Lease Time. Then click Next

dhcpwiz_ip

  1. Click on "Write INI file". Then click Next and Finish
  2. A dhcpsrv.ini file should now have appeared, open it. Then edit the IPBIND_1 value into the address you chose (192.168.2.1)

dhcpsrv_ini

  1. Run dhcpsrv.exe
  2. Click Admin -> Configure Firewall exceptions
  3. Click Install, then Start to start the DHCP server dhcpsrv

CONNECT THE ETHERNET CABLE BETWEEN THE RASPBERRY PI AND THE WINDOWS PC 🔌

POWER ON THE RASPBERRY PI 🔋

Allow up to 2 minutes for the Pi to completely boot up, especially it will take longer on the first boot.

After the above setup, the Raspberry Pi will be dynamically allocated an IP Address on the Windows PC's DHCP Network. Our next step is to find out what this IP Address is and configure the ROS Network accordingly.

2.4 Configuring the Raspberry Pi IP Address and ROS Network

2.4.1 Finding the Pi's IP Address

Most of the time, the Raspberry Pi will have an IP Address that is one above the Windows PC's IP Address. So if the Windows PC is 192.168.x.1 then the Pi will be 192.168.x.2.

We will perform a quick check to see if this is true.

  1. Open a Command Prompt by searching for "cmd.exe" on Windows
  2. Enter ping 192.168.x.2, replacing x with what you chose
    • In this tutorial we are using ping 192.168.2.2

If the Raspberry Pi responds like the image below, then go straight to the ROS Network setup steps

ping_pi

If that is not the case, then please do the following steps:

  1. Connect to the Raspberry Pi's Wifi (ubiquityrobotXXXX) with password: robotseverywhere
  2. Open a Command Prompt by searching for "cmd.exe" on Windows
  3. Log in to the Raspberry Pi by entering ssh [email protected] then answer yes and enter the password ubuntu
  4. Once you are in, enter hostname -I

The first address is what the Raspberry Pi was allocated to, and should be under the format 192.168.x.y. You can perform the ping check above with another Command Prompt from the Windows PC to double check.

2.4.2 Configuring the ROS Network

If your Raspberry Pi's IP Address is 192.168.2.2, you don't have to do this part. Your setup is now complete 🎉

If your Pi's IP Address is anything other than 192.168.2.2, please follow the next steps:

  1. Log in to the Raspberry Pi with its new Ethernet IP Address
    1. Open a Command Prompt by searching for "cmd.exe" on Windows
    2. Log in to the Raspberry Pi by entering ssh [email protected] with the password ubuntu
      • The IP Address is what you found in the steps above
      • If this is your first time logging in, you will need to answer yes before entering the password
  2. Enter nano setup.sh
  3. Use arrow keys to navigate the cursor, and modify the second line to match the Raspberry Pi's IP Address
export ROS_HOSTNAME=192.168.x.y
  1. Press Ctrl+X, enter Y and then press Enter to save the configuration file
  2. Enter sudo reboot now to restart the Raspberry Pi
    • You may need to re-enter the password ubuntu

Your setup is now complete 🎉

3. Using UR3Sim

3.1 Getting the latest version of UR3Sim

  1. Make sure you grab the latest UR3Sim zip from our Releases page
    • Sometimes Google Chrome will say that the file is not "commonly downloaded and is potentially dangerous". Please ignore that and select to Keep the file, it is not dangerous (trust me)
    • The release was built for Windows 10 and should work on all Windows PC. You can also try to build it from source from the Unity editor.
  2. Unzip and open UR3Sim.exe
    • You can resize the window ur3sim_menu

3.2 Launching the ROS Network and ROS#

  1. Open a Command Prompt by searching for "cmd.exe" on Windows
  2. Log in to the Raspberry Pi by entering ssh [email protected] with the password ubuntu - Replace 192.168.x.y with your Raspberry Pi's IP Address - If this is your first time logging in, you will need to answer yes before entering the password
  3. Once you are in, launch the ROS Network and the required ROS# (file_server) package
roslaunch file_server ros_sharp_communication.launch

rossharp_launch

3.3 Connect UR3Sim to the ROS Network

  1. With UR3Sim.exe opened, go to the OPTIONS menu
  2. Enter the Raspberry Pi's IP Address

ur3sim_option

  1. Click BACK and then START to begin the simulation!

On the Raspberry Pi terminal, you should now see that a new client has connected.

rossharp_client

You can also open another Command Prompt window, login to the Raspberry Pi and then use

rostopic list

to see the topics available.

rossharp_topics

🥳 Welcome to UR3Sim! 🥳

ur3sim_running