Crazyflie and Networking Related Procedures

NIMBUS Lab operates the crazflie 2.0 using the work of Whoenig and his associates from USC ACT Lab. Their documentation can be found at http://crazyswarm.readthedocs.io/en/latest/index.html. However, there are some wholes in this documentation. The purpose of this document is to walk the Crazyflie operator through the setup of the Crazyflie system, from downloading a virtual machine to navigating the holes in the USC Crazyflie documentation.

If you are working in room 218 you will probably want to skip to page 7 of this document to “Actually Operating the Crazyflies.” If not, you will probably want to start with “System Reqirements”

If you want Internet on the desktop in room 218 look under “Possible Problems”

A Vicon network adapter is already present on the host machine under path “Control Panel\Network and Internet\Network Connections”

Possible Problems:

If you are working in room 218 it is likely that the USB Wi-Fi receiver on the HRI desktop will be too slow to download packages or load a website at a reasonable rate. If this is the case, you may want to bridge the Wi-Fi from your laptop to the desktop.

Setting Up Bridge Between Windows 10 Laptop to Ubuntu 16.04 VM

Setting Up Bridge on Windows 10 side:

On your Windows 10 Laptop right click on the Wi-Fi icon on the bottom right hand corner of your screen

You may need to click on the upward carrot on the bottom right hand corner of your screen to get to the Wi-Fi icon.

After right clicking select “Open Network and Internet Settings”

Select “Wi-Fi” from the menu on the right hand side of the “Settings” window

Scroll down to “Related settings” and select “Change adapter options”

Plug one end of an Ethernet cable into your laptop and the other end into the Windows 7 desktop which is hosting Ubuntu 16.04

If you do not have an Ethernet port on your computer you will probably need to use an Ethernet to USB adapter to connect to your laptop.

You probably have a choice whether you want to use another USB adapter to connect to the desktop or if you want to connect the Ethernet cable directly to the back of the desktop – the second half of these instructions only apply if you choose to use the adapter. If you choose to connect directly with the Ethernet you will have to do more work with the network adapter on the Desktop, and this documentation will not walk you through that.

You should see a new connection pop up in the “Network Connections” window when you have plugged the Ethernet cable into both computers.

Highlight your current Wi-Fi connection and the new Ethernet connection together

The Wi-Fi connection should say “unl.edu” or the name of whatever Wi-Fi you are connected to.

The Ethernet should say “Unidentified Network”

Right click on the highlighted networks and select “Bridge Connections”

In theory you should now be bridging Wi-Fi to the Windows 7 computer, but normally I find you still have one more process to go through

Unplug the Ethernet cable

The Ethernet connection and bridged connection should disappear

Right click on the Wi-Fi connection and select “Remove from Bridge”

Right click on the Wi-Fi connection again and select “Add to Bridge”

Now if you plug the Ethernet cable back into your laptop you should be bridging Wi-Fi to the desktop

You should now have access to Internet on the Windows 7 host desktop

Setting Up Bridge on Ubuntu Side:

These instructions only apply if you are using a USB adapter to connect to the Windows 7 host.

When you plug the USB adapter into the Windows 7 host you should notice a new USB icon show up on the bottom right hand side of your virtual machine. Click on this icon and make sure the USB is connected to your VM.

If the USB is connected to your computer then when you right click on the icon you will have the option “Disconnect (Connect to Host)”

If the USB is not connected to your computer you will have the option “Connect (Disconnect from Host)”. Select this option.

Now in the top right hand of your VM click on the network icon. This will either look like the Wi-Fi icon or it will be two parallel arrows side by side.

Select “Edit Connections”

Select “Add”

Make sure the drop-down menu says “Ethernet” and then select “Create”

Under “Device” in the resulting window select the device you just plugged in to your computer

The device you just plugged in should be the only one that does not share a MAC address with one of the network adapters for your VM. To determine the MAC addresses of your VMs network adapters:

In the upper right hand corner of your screen select “VM”

Select “Settings”

Select a network adapter from the menu on the left hand side of the window

On the right hand side of the window select“Advanced”

Note the MAC address at the bottom of the resulting window

Repeat this process for each network adapters

Once you have selected the correct device select “Save”

You should now be able to access the Internet from your virtual machine!

Once the file has downloaded (which may take a while) open VMware and select the “Home” tab in the upper left hand corner.

Now select the “Create a New Machine” option from the options in the middle of your screen.

Follow the “New Virtual Machine Wizard” that pops up.

On the second screen of the wizard select “Browse” and choose the .iso file you just downloaded.

Tip: when you choose a user name and password for this virtual machine, unless you expect to store anything confidential, make the username and password as short as possible. You will need to use your password a lot so you do not want it to be long and you do not want to forget it – make it the same thing as your username.

As you follow the wizard, when it asks you how many processor you want to give your virtual machine, select as many as is reasonable for your computer.

If you are unsure what this number is Jean Paul or AJ might be good people to talk to.

For the computer in room 218 select 8 processors.

For selecting the optimum amount for RAM or memory talking to AJ or Jean Paul may be necessary.

You will need 1.4 GB of ROM at a minimum to download everything necessary for flying the Crazyflie

The desktop VM in room 218 has 16 GB allocated to the “CrazyflieDesktop” VM

The desktop VM in room 218 also has 16 GB of RAM

Once the wizard is finished you should be good to go.

Go to “Home” again and select “Open a Virtual Machine”.

Somewhere on your computer there should be a file with the name you gave your VM. Open that file and select the document of type .vmx. This should open your new VM.

Connecting Ubuntu 16.04 VMware Workstation to Vicon Network Adapter:

In order for your virtual machine to receive Vicon data it needs to join Vicon’s network. Vicon has a network adapter on the Windows 7 host. This is where the Vicon application sends all of the telemetry data it collects from objects in the room. You need to make a network adapter on your virtual machine in order to receive this information from Vicon. Finally, these two network adapters need a way to talk to one another in order that the VM can receive Vicon data from the host computer. This final piece is called a bridge. The network adapter on the Windows 7 end should already be set up on the host computer. However, you will need to set up the bridge and the Ubuntu network adapter yourself. The following steps describe how this is done.

Setting Up Ubuntu Network Adapter for Vicon

Open your Ubuntu 16.04 workstation

In the top left corner of your screen select “VM”

At the bottom of the drop-down menu select “settings”

Toward the bottom left of this window select “Add”

At this point you will probably need the administrative password to the Windows 7 host.

The administrative password for the computer in room 218 is ‘Avery365bduncan’

You may want to copy this password to you clipboard so that you can paste it instead of typing it as it is pretty long.

Select “Network Adapter” from the list of options to the left of the window and click “next”.

Select “Custom” and then choose an unused VMnet.

You can tell whether or not a VMnet is used by looking at the “Device” menu under the “Hardware” tab of the “Virtual Machine Settings” window. If a VMnet is used it will be in parentheses after the name of one of the listed network adapters.

Select “Finish”

Setting Up Bridge Between the Vicon Network Adapter and the Ubuntu Network Adapter

At this point you will probably need the administrative password to the Windows 7 host.

Follow “a)” of step 4 of “Setting Up Ubuntu Network Adapter for Vicon”

Select “Add Network” to the bottom right of the first list in the window.

Now, using the drop-down menu in the “Add a Virtual Network” window choose the same VMnet you chose in step 6 of “Setting Up Ubuntu Network Adapter for Vicon”

Select “OK”

Under the VMnet Information heading select “Bridged”

Now you have to use the drop-down menu after “Bridged to” order to select which Ethernet connection you want to connect to. In order to do this you will need to see which Ethernet connection the Vicon Network adapter is communicating with.

Click on the Windows icon in the bottom left hand corner of your screen and type “Network and Sharing Center” in the search bar and hit ‘Enter’

In the top left hand side of the window that pops up select “Change adapter settings”

You should now see a list of all of the network adapters on the Windows 7 host machine. Hopefully one of these adapters is named “Vicon_LAN” or something similar which includes the name “Vicon”

If not talk to AJ (thank you AJ)

Underneath the network adapter you should see the network name and the name of the Ethernet connection that the adapter is using to communicate

Note the connection that Vicon is using and then return to the “Virtual Network Editor” window and select the correct connection from the “Bridged to” drop-down menu.

Click “Apply”

Click “OK”

Accessing the Vicon Network from Inside the Ubuntu Virtual Machine

In order to use the network you just set up between Vicon and your Ubuntu VM you will have make a network connection from the inside of your Ubuntu VM. First you have to add the IP address of your Vicon network adapter to the “hosts” document on your VM. Then you will make a network connection which will allow you to use access Vicon data from your VM.

Open a terminal in you Ubuntu VM (ctrl+alt+t)

type: ‘cd ../..’

type: ‘sudo gedit etc/hosts’

In the top of the document paste type: “[Vicon Network Adapter IP Address] vicon”

In order to determine the Vicon network IP address first follow steps 9 a) – c) of “Setting Up Bridge Between the Vicon Network Adapter and the Ubuntu Network Adapter”

Double click on the Vicon network adapter

Select “Details”

Use the IPv4 address in the “hosts” document

Select save and close the “hosts” document

In the top right corner of your screen click on the network icon in your Ubuntu VM

The icon will either be the Wi-Fi icon or two parallel arrows pointing in opposite directions

At the bottom of the drop-down menu select “Edit Connections”

Now select “Add”

Choose “Ethernet” from the drop-down menu and the select “Create”

In this window there should be a “Device” heading with a drop-down menu which will show you all of the available Ethernet or ens connections

To determine which connection to use click VM in the top right corner of your screen

Select “Settings” at the bottom of the resulting drop-down menu.

Click on the network adapter that is connected to Vicon

Toward the bottom right hand side of the window select “Advanced”

In the resulting window note the MAC address used by the network adapter

Return to the connection editing window and select the Ethernet or ens connection with the same MAC address as the network adapter

Make sure “MTU” is set to “automatic” and Wake on LAN to Default

Go to the “IPv4 Settings”

Change the drop-down menu under “Method” to “Manual”

Click “Add”under the Addresses heading.

Under the “Address” header make a new IP address for you computer. Check the doc entitled “Network Connections in Room 218” on the NIMBUS website to make sure you are not using an address that has already been used

The first three sections of your address must match the first three sections of the Vicon network adapter address. (probably 192.168.1.[your ID])

Under the “Netmask” header use 255.255.255.0. When you come back and look later the netmask may say 24. This is OK. Apparently 24 is the abbreviation for 255.255.255.0.

The Gateway is the same as the IP address of the Vicon network adapter.

Go to “IPv6 Settings”

Make sure that “Method” is set to “Link-Local-Only”

Select “Save”

You Should now be able to access Vicon data on your Ubuntu 16.04 VM

Downloading ROS Kinetic onto Ubuntu 16.04:

ROS Kinetic can be downloaded by following the steps at wiki.ros.org/kinetic/Installation/Ubuntu. In step 1.4 enter the command for “Desktop-Full Install” into your terminal and then move on to step 1.5.

Patching Wholes in Crazyflie Documentation:

Communicating with Crazyradio

The Crazyflie documentors from USC ACT Lab mentioned in the introduction (http://crazyswarm.readthedocs.io/en/latest/index.html) seems to make the assumption that you have kept up with their previous work. Therefore they do not include the instructions for setting up your operating system to work with the Crazyradio. Before attempting to communicate with the Crazyflie via Crazyradio follow all of the instructions in section 3.1 and the first block of commands in section 3.2 of previous Crazyflie documentation act.usc.edu/publications/Hoenig_Springer_ROS2017.pdf. Note that the first block of commands in section 3.2 should say “python3-pyqt5” (not “python3-pyqt4”)

Troubles with Build

If the “./buildSumOnly.sh” command does not work do not worry. Keep following the instructions. The “python figure8_canned.py –sim will not work either. This is ok, keep moving.

Before running the “./build.sh” command you will need to use another command the documentation forgot to included. Run this command in the directory “~/crazyswarm”:

‘git submodule update –init –recursive’

USC ACT Lab made the crazyswarm workspace out of a number of different trees. The initial git clone command does not grab all of the trees. Therefore we use the command above.

Now you can run the “./build.sh” command, but this also must be done in the parent “crazyswarm” directory.

Flashing New Firmware to Crazyradio

You will need to use the full file path as described in under the next heading.

Flashing New Firmware to Crazyflies

We have only used Option 2 Under “Crazyflie Preparation” in NIMBUS Lab. So if you decide to use Option 1, best of luck. Option 2 works well, but the filename needs to have the complete file path to the file you want to flash to the Crazyflie. In room 218, the file path for the nrf51 target is “/home/cf/crazyswarm/prebuilt/cf2_nrf.bin” and the file path for the stm32 target is “/home/cf/crazyswarm/prebuilt/cf2.bin”.

Problems with Tool Scan

The instructions say that the command “rosrun crazyflie_tools scan” will report the firmware version of the crazyflie. This may have been true when they first made the tool, but now reporting the firmware has been made into an option. The correct command to use is “rosrun crazyflie_tools scan -v”. The v stands for verbose.

Also, in order to locate a Crazyflie, the scan tool needs to know what address to search. If the tool is not finding a Crazyflie even though you know it is on, go to “~/crazyswarm/ros_ws/src/crazyflie_ros/crazyflie_tools/src/scan.cpp”. On line 12 make sure the address matches that of your Crazyflie (If you’re not sure what the address is, look under the heading “Understanding Meaning of “id” Crazyflie.yaml files” two sections down).

Problems with yaml library

The first time you launch “hover_swarm.launch” it may be that you get an error complaining about yaml libraries. I am pretty sure the fix is download the correct yaml library:

‘pip install yaml3’

However I am not certain and have been unable to test to make sure that this is correct. Whether or not this is the exact right command I am certain that the problem has to do with missinig the correct yaml library. Use Google to look up problems with yaml libraries and how to download them.

Understanding Meaning of “id” Crazyflie.yaml files

“id” in the files “allCrazflies.yaml” and “crazyflieTypes.yaml” must be the same as the end of the corresponding Crazyflie’s address. For example, if my Crazyflie has the address “0xE7E7E7E701” then its id would be “01”. If its address is “0xE7E7E7E712”, then the “id” is 12.

Actually Operating the Crazyflies

Everything that follows assumes you are using “motionCapture” system (If you do not know what I am referring to, read under “Select Motion Capture System” in http://crazyswarm.readthedocs.io/en/latest/usage.html). The “libobjecttracker” works as well, but this requires that every Crazyflie shares the same marker configuration and that each Crazyflie starts from a home position each time you start the Crazyflie server (“hover_swarm.launch”)

When making a Crazyflie object in Vicon it is absolutely vital that you make the object centered in Vicon’s coordinate system and facing forward in the positive x direction.

In order to successfully kill “chooser.py”, after you hit ctrl+c you will need to pass your curser over the GUI.

Steps to getting Crazyflies in the air:

Make sure the Crazyflies you plan to fly are selected by “chooser.py”.

Make sure all of the Crazyflies are on and that they have been turned off and on since the last time they were connected to the Crazyflie server (the crazflie server is launched when you launch “hover_swarm.launch”).

Make sure the Crazyradio has been unplugged and re-plugged before launching “hover_swarm.launch” (not exactly sure why you have to do this, it may have something to do with the fact that we are using a virtual machine – either way, this step is vital).

launch “hover_swarm.launch” by typing “roslaunch crazyswarm hover_swarm.launch” in the consul.

Now you can make the Crazyflies hover with the Xbox controller by plugging the Xbox USB dongle into the computer and then pressing the start button on the Xbox controller.

Make the Crazyflies land by pressing the back button on the Xbox controller.

You can write a python script to control the Crazyflies using the library discussed on the Python API section of the USC ACT Lab crazyswarm documentation.

In order to run the python scripts make sure you have saved the script in “~/crazyswarm/ros_ws/src/crazyswarm/scripts”.

Go to the library where you have saved the script and enter “python [name of script].py”.

In order to kill a python script you may need to enter ctrl+z instead of ctrl+c.

When you kill a python script the Crazyflies will stop and hover where they are. You will need to land them with the Xbox controller by pressing back.

You can also stop anything the crazyflies are doing by pressing “X” on the Xbox controller. The Crazyflies will just fall out of the air.

Trouble Shooting

If you get a timeout error when launching “hover_swarm.launch” try check these six things

Make sure that the VM is connected to the Vicon network (click on the network icon in the top right of your screen and make sure “Vicon” is connected”.

Make sure Vicon is not paused.

Make sure as many Crazyflies are on as selected in “chooser.py”.

Make sure the all the Crazyflies have a blinking red light. If any one only has a solid blue light you will need to turn it off and turn it back on.

Make sure you have removed and replaced the Crazyradio from the USB port since the last time you killed “hover_swarm.launch”.

If you are still getting a timeout error, remove the Crazyradio, kill “hover_swarm.launch”, restart every Crazyflie, replace the radio, and relaunch “hover_swarm.launch”.