Using a Raspberry Pi and an Ethernet cable - tonydle/ur3_unity_sim GitHub Wiki
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
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
- 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#.
- Download an SD card image flasher. In the following steps we will be using balenaEtcher
- Insert the micro SD card into your PC with the card reader
- Select the downloaded image and the correct drive by looking at the storage size
- Click Flash and wait for it to complete
- 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
- 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)
- Right-click on Ethernet -> Properties -> Internet Protocol Version 4 (TCP/IPv4) -> Properties
- 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
- Put in 255.255.255.0 for the Subnet mask
- Leave the other fields empty. Click "OK" and close all Windows
2.3 Installing a DHCP server on the Windows PC
- Download the latest version of DHCP Server for Windows
- Unzip and run dhcpwiz.exe
- Click Next -> Choose "Ethernet" -> Next -> Next
- In "Configuring DHCP for Interface" / Configuration / IP-Pool, enter the IP Address you chose (192.168.2.1)
- Choose "1 Year" for the Lease Time. Then click Next
- Click on "Write INI file". Then click Next and Finish
- 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)
- Run dhcpsrv.exe
- Click Admin -> Configure Firewall exceptions
- Click Install, then Start to start the DHCP server
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.
- Open a Command Prompt by searching for "cmd.exe" on Windows
- Enter
ping 192.168.x.2
, replacing x with what you chose- In this tutorial we are using
ping 192.168.2.2
- In this tutorial we are using
If the Raspberry Pi responds like the image below, then go straight to the ROS Network setup steps
If that is not the case, then please do the following steps:
- Connect to the Raspberry Pi's Wifi (ubiquityrobotXXXX) with password:
robotseverywhere
- Open a Command Prompt by searching for "cmd.exe" on Windows
- Log in to the Raspberry Pi by entering
ssh [email protected]
then answeryes
and enter the passwordubuntu
- 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:
- Log in to the Raspberry Pi with its new Ethernet IP Address
- Open a Command Prompt by searching for "cmd.exe" on Windows
- Log in to the Raspberry Pi by entering
ssh [email protected]
with the passwordubuntu
- 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
- Enter
nano setup.sh
- 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
- Press Ctrl+X, enter Y and then press Enter to save the configuration file
- Enter
sudo reboot now
to restart the Raspberry Pi- You may need to re-enter the password
ubuntu
- You may need to re-enter the password
Your setup is now complete 🎉
3. Using UR3Sim
3.1 Getting the latest version of UR3Sim
- 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.
- Unzip and open UR3Sim.exe
- You can resize the window
3.2 Launching the ROS Network and ROS#
- Open a Command Prompt by searching for "cmd.exe" on Windows
- Log in to the Raspberry Pi by entering
ssh [email protected]
with the passwordubuntu
- Replace 192.168.x.y with your Raspberry Pi's IP Address - If this is your first time logging in, you will need to answeryes
before entering the password - Once you are in, launch the ROS Network and the required ROS# (file_server) package
roslaunch file_server ros_sharp_communication.launch
3.3 Connect UR3Sim to the ROS Network
- With UR3Sim.exe opened, go to the OPTIONS menu
- Enter the Raspberry Pi's IP Address
- Click BACK and then START to begin the simulation!
On the Raspberry Pi terminal, you should now see that a new client has connected.
You can also open another Command Prompt window, login to the Raspberry Pi and then use
rostopic list
to see the topics available.
🥳 Welcome to UR3Sim! 🥳