ROS & Ubuntu Tips
Published:
Here are some personal tips for using ROS. After I realized I kept googling the same basic information.
1. Clone existing package from GitHub
- Create and build a workspace
$ mkdir -p ~/xxx_ws/src $ cd ~/xxx_ws/ $ catkin_make
- Clone package
$ cd ~/xxx_ws/src $ git clone https://xxxxxx.git $ cd ~/xxx_ws/ $ catkin_make
Keep in mind that your workspace has a tree like this:
|/home
├── /usr
│ ├── /xxx_ws
│ │ ├── /build
│ │ ├── /devel
│ │ ├── /src
│ │ | ├── /your_cloned_package
│ │ | ├── /your_other_package
2. Create a virtual environment
Python virtual environments can create an isolated environment for different Python projects. Thus, a specific version of a module on a project basis installation won’t affect other Python projects. Here is a step by step instructions about how to create Python virtual environments on Ubuntu 18.04.
- update all packages
$ apt-get update -y
- install the
python3-venv
package$ sudo apt install python3-venv
- Create a folder (my folder name:
virenv
) for the virtual environment$ mkdir virenv $ cd virenv
- Create and activate the virtual environment (my environment name:
gpflow
)$ python3 -m venv gpflow $ source gpflow/bin/activate
- Install jupyter notebook and add the virtualenv (
gpflow
) as a jupyter kernel$ pip install jupyterlab $ pip install ipykernel $ python -m ipykernel install --name gpflow --user
In the opened notebook, navigate to
Kernel
, thenChange kernel
, pickgpflow
.
3. Image & video processing by ffmpeg
- Convert video format
$ ffmpeg -i input.mov -qscale 0 output.mp4
- Combine images to video:
$ ffmpeg -framerate 5 -i img-%02d.png video.avi $ ffmpeg -framerate 30 -i %07d.jpg video.avi $ ffmpeg -framerate 30 -s 1280x960 -pattern_type glob -i '*.png' -crf 15 test.mp4
- Cut video
$ ffmpeg -i DJI_0004.MOV -ss 00:00:00 -to 00:03:20 -c:v copy -c:a copy output.MOV
- Extract images from videos
$ ffmpeg -i input.mp4 -qscale:v 2 output_%03d.jpg
- Resize image
$ ffmpeg -i input.jpg -vf scale=2048:1024 output.png
4. Adjust Ubuntu screen resolution
$ xrandr
$ xrandr -s 1920*1200
5. Install and uninstall Visual Studio
Install
- install the repository and key
$ wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg $ sudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/ $ sudo sh -c 'echo "deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
- update the package cache and install the package
$ sudo apt-get install apt-transport-https $ sudo apt-get update $ sudo apt-get install code
Uninstall
- uninstall
$ sudo apt-get purge code
- remove settings
$ cd ~ && rm -rf .vscode && rm -rf .config/Code