-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
The practical assignments should be solved with C++ or Python. In this assignment you will set up your programming environment and prepare for the upcoming assignments.
Clone the repository https://github.com/JMUWRobotics/sensorcube using git, which includes documentation and example code for the Sensor Cube.
Clone the repository:
git clone https://github.com/JMUWRobotics/sensorcube.git
Alternatively, download the main branch as a ZIP-File from https://github.com/JMUWRobotics/sensorcube/archive/refs/heads/main.zip.
In the root directory is a configuration file config.json. If you use the Sensor Cube with another PC, please make sure to set serial_port (typically /dev/ttyACM[0-9] on Linux or COM[1-9] on Windows) and the correct camera_index for the stereo camera.
config.json
{
"serial_port" : "/dev/ttyACM0",
"serial_baudrate" : 921600,
"camera_index" : 0,
"camera_width" : 1600,
"camera_height": 800
}
The Python examples load this file relative to the *.py source files. For the C++ examples CMake sets the path relative to the project source dir and bakes the path in the executables.
This section is not necessary to complete if you are using the lab computers.
On GNU/Linux make sure that you have access rights for the serial device (typically /dev/ttyACM[0-9]) of the Arduino in the Sensor Cube. On GNU/Linux the device will typically have access rights for the group \textit{dialout}. Make sure your user is in the correct group to have access to the serial port.
Check the access rights to /dev/ttyACM[0-9]) by running:
ls -lah /dev/ttyACM0
For example, on Ubuntu the default owner of the device is root with access rights for the group dialout:
crw-rw-rw-+ 1 root dialout 166, 0 Apr 25 12:00 /dev/ttyACM0
You can add your user <user_name> to the group dialout by running:
sudo gpasswd -a <user_name> dialout
Alternatively, the repository includes a udev rule, which grants read and write access to the device for all users:
sudo cp udev/99-sensorcube.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
Set up your Python programming environment.
- Install Python3. On GNU/Linux you can use your favorite package manager to install Python, e.g., on Debian/Ubuntu install the package python3
- On GNU/Linux use your favorite package manager to install the Python dependencies, e.g., on Debian/Ubuntu install the packages:
python3-opencv, python3-serial, python3-matplotlib, python3-numpy.
Or, use pip to install the dependencies:
pip install opencv-python pyserial matplotlib numpy
- Inspect the Python examples in the directory examples/python.
Set up your C++ programming environment.
- Set up your C++ programming environment and compiler, e.g., GCC on GNU/Linux or Visual Studio/MSVC on Windows.
- Install the OpenCV library.
For image processing we will be using the OpenCV library which is available across platforms. It is recommended to use version 4.5.4 for this exercise. However, any version newer than 4.4.0 should be fine to complete the assignments. Please refer to:
https://docs.opencv.org/4.5.4/df/d65/tutorial_table_of_content_introduction.html
GNU/Linux:
Use your favorite package manager to install OpenCV, e.g., on Debian/Ubuntu install the package libopencv-dev.
Windows:
You can download the OpenCV binary release from https://opencv.org/releases/. You need to add the path to the unpacked directory opencv/build/x64/vc16/bin to your System Path, such that the OpenCV DLLs are found.
Of course it is also possible to compile OpenCV yourself or use other ways for the installation as listed in the OpenCV documentation. - Install the CMake build system.
GNU/Linux:
Use your favorite package manager to install CMake, e.g., on Debian/Ubuntu install the package cmake.
Windows:
You can download CMake from https://cmake.org/download/. - All other library dependencies are automatically downloaded by CMake. Inspect the CMakeLists.txt project file.
- Build the C++ examples. The recommended way of building a project with CMake is by doing an out-of-source build.
This can be done like this:
cd examples/cpp
mkdir build && cd build
cmake ..
make
- If OpenCV is not installed in the standard paths, you might need to set the OpenCV directory:
cmake -DOpenCV_DIR=<Path to directory OpenCVConfig.cmake> ..
- If you are using the OpenCV binary release on Windows, you need to specify the path to the unpacked directory opencv/build/x64/vc16/lib.
- Different CMake Generators are available, such as Unix Makefiles or Ninja. On Windows CMake can create, for example, Visual Studio project files, NMake, or Unix Makefiles:
https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html
For example, on Windows you can run from the Visual Studio developer command prompt:
cmake -G "NMake Makefiles" ..
nmake
- Inspect the C++ examples in the directory examples/cpp/src.