ECE4160/5160-MAE 4190/5190: Fast Robots course, offered at Cornell University in Spring 2023
This project is maintained by CEI-lab
Follow these directions to setup and use your simulation environment. You will learn how to control your virtual robot and use the live plotting tool.
The simulation environment consists of three components:
The simulator contains a wheeled robot equipped with laser range finder(s), similar to the physical robot and its ToF sensors. The simulated world is defined in a .yaml configuration file.
Odometry is the use of data from onboard sensors to estimate change in position over time. The relative changes recorded by the sensors (typically IMU and/or wheel encoders) are integrated over time to get a pose estimate of the robot. It is used in robotics by mobile robots to estimate their position relative to a starting location. This method is sensitive to errors due to the integration of velocity measurements over time to give position estimates.
The virtual robot provides simulated IMU data that mimics a typical real robot and this data is integrated over time to give you the odometry pose estimate. (In your real robot, we know that accelerometer data is too noisy to estimate forward motion, but you can consider using the gyroscope to estimate turns, and doing forward motion open loop. More on this in future labs!)
In robotics, ground truth is the most accurate measurement available. New methods, algorithms and sensors are often quantified by comparing them to a ground truth measurement. Ground truth can come either directly from a simulator, or from a much more accurate (and expensive) sensor.
For the virtual robot, ground truth is the exact position of your virtual robot within the simulator.
The virtual robot does has a (simulated) constant speed controller and odometry pose estimation built in. It essentially mimics an idealized version of the real robot.
The 2d plotting tool is a lightweight process that allows for live asynchronous plotting of multiple scatter plots using Python. The Python API to plot points is described in the Jupyter notebook. It allows you to plot the odometry and ground truth poses. It also allows you to plot the map (as line segments) and robot belief in future labs. Play around with the various GUI buttons to familiarize yourself with the tool; you want to be more familiar with the tools before you get into the future labs.
You will be programming the controller in Python to perform various functions on your virtual robot. We provide you with a Python API which, among other things, provides a minimal control interface for the robot in the simulator. It allows you to:
WSL users should continue to use WSL (for Bluetooth reliability) and should follow the Linux instructions when applicable. The provided WSL distribution comes with Python 3.9 and works without upgrading to a later Python version.
WSL users may have to install some packages in the WSL terminal.
sudo apt install libgl1 libegl1 libxkbcommon-x11-0 libxcb-xinerama0 libxcb-cursor0 libxcb-icccm4 libxcb-keysyms1 libxcb-shape0
This is a reminder to upgrade python (>= 3.9) and pip (>= 21.0).
NOTE: You may notice different versions when using
python
andpython3
commands; use the one that has the latest version and use pip in that version of python. For example, ifpython3
has the latest version of python on your computer, use pip aspython3 -m pip
. Make sure you use the right python command for all the steps detailed in this documentation.
python --version
python -m pip --version
If you just upgraded your Python version and used an older version in Lab2, then the virtual environment created in Lab 2 will no longer be compatible. Inside your project folder, delete the directory with the name of your virtual environment (FastRobots_ble). Verify it is actually deleted! Now, follow instructions in Lab2 to setup your new virtual environment and reinstall the packages from Lab 2.
python -m pip install numpy pygame pyqt6 pyqtgraph pyyaml ipywidgets colorama
Replace
python
withpython3
ifpython3
points to the latest version.
python -m tkinter
to make sure that tkinter is set up correctly. If the Tkinter module isn’t
installed, run
pip install tk
and try the
python -m tkinter
again.Download the pip wheel that matches your OS and Python version. For example, MacOS with
Python 3.9 would download the wheel with cp39-macosx
in the filename. Remember that WSL uses Linux instructions.
Replace <wheel file> with the path to the wheel that you downloaded
pip install <wheel file>
Remember that WSL can access your Windows
C:\
drive as/mnt/c
.
python
and then run the following code in the python interpreter:
import Box2D; print(Box2D.__version__)
Follow the instructions in this section IF AND ONLY IF Box2D was NOT successfully installed in the previous section.
sudo apt-get install build-essential python-dev swig python-pygame git
git clone https://github.com/pybox2d/pybox2d
python setup.py build
python setup.py install
Get-ExecutionPolicy
Set-ExecutionPolicy AllSigned
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
choco install swig
choco install git
git clone https://github.com/pybox2d/pybox2d
cd pybox2d
python setup.py build
python setup.py install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install swig
git clone https://github.com/pybox2d/pybox2d
cd pybox2d
python setup.py build
python setup.py install