Ricardo's Place Robotics, machine learning, or simply random thoughts!

Running Ignition Gazebo Ionic on Google Colab

Last week, I saw this post on LinkedIn where Carlos Argueta was showing some interesting robotics perception experiments that were running on Google Colab.

I mentioned in the comments that I had, in the past, managed to run Gazebo on Google Colab. So, I decided to find that old notebook and here it’s:

https://colab.research.google.com/gist/ricardodeazambuja/fae4db3dcee352fee3f95966ca4f3ec6/example-virtual-screen-opengl-gazebo-ignition.ipynb

The magic is only possible thanks to open source software like X virtual framebuffer, VirtualGL, PyVirtualDisplay, among others!

Ignition Gazebo Ionic Running on Google Colab
Ignition Gazebo Ionic Running on Google Colab

Advanced QR Code Generator

I was testing some ideas at home and I needed to create a QR code. I searched online and found a few websites, but they were full of ads and I was not sure what they were doing with my data. So, I went to my “friend” Gemini and asked it for a single webpage QR code generator. After a few iterations, I got something quite interesting!

Read more...

Launching your file manager from the command line avoiding the rubbish!

After spending years using weird magic spells to launch a graphical file manager (e.g. nautilus) from the command line without it printing a lot of rubbish, I finally learned that xdg-open just works!

Use xdg-open . and you will have your graphical file manager PLUS a clean terminal!

Annotating papers and sharing your thoughts, directly from your browser

In the last weeks I’ve been reading a lot of papers. Usually I open an online document (e.g. google docs) and write down my notes there while I read a paper. However, I also like to highlight a pdf as I read it, but that forces me to download the pdf and keep the final file. Therefore I was trying to find a way to annotate a pdf directly from my web browser… and that’s the motivation that made me hack together my very own arxiv-highlighter!

Read more...

Loss function for semantic segmentation using PyTorch (CrossEntropyLoss and BCELoss)

Today I was trying to implement, using PyTorch, the Focal Loss (paperswithcode, original paper) for my semantic segmentation model. Focal Loss is “just” Cross Entropy Loss with some extra sauce that allows you to adjust (γ) how much weight you give to examples that are harder to classify otherwise your optimiser will focus on the easy examples because they have more impact on the loss. To save time, I didn’t even considered writing my own code (although the focal loss is fairly simple), and I went directly to google where I found this nice example:

Read more...

Old digital microscope was driving Ubuntu nuts!

Today I needed to check some connections in the PCB of my ST-Link V2 clone because I wanted to add the trace support following the nice explanations from here. However, my old brandless digital microscope (you know, they all look the same and come in a blue box…) refused to work. dmesg helped me find some repeated error messages (Failed to query (GET_DEF) UVC control 4 on unit 1 or Failed to query (GET_MIN) UVC control 4 on unit 1) and a little bit of google-fu did the rest. I found my system was suffering from a problem with libwebcam0 and uvcdynctrl and the log file /var/log/uvcdynctrl-udev.log was already at 68GB (?!?).

I learned this is a super old bug (first message is from 2011!) and it can slow down your system to a halt. Using apt show and the very useful apt-rdepends I noticed libwebcam0 and uvcdynctrl just depended on each other… so following the suggestion and removing libwebcam0, uvcdynctrl and uvcdynctrl-data solved my problem (sudo apt remove libwebcam0 uvcdynctrl uvcdynctrl-data).

I hope this blog post can help other people avoid spending time on google to solve the same 11-year-old problem…

UPDATE (29/01/2023):
Ubuntu Cheese sometimes is too picky and stops the stream with an error message, so I suggest using ffplay. First, connect your microscope (webcam) and check the devices available (v4l2-ctl --list-devices):

USB2.0 UVC PC Camera: USB2.0 UV (usb-0000:00:14.0-2):
	/dev/video2
	/dev/video3

Integrated_Webcam_HD: Integrate (usb-0000:00:14.0-5):
	/dev/video0
	/dev/video1

In my situation, the microscope was the USB2.0 UVC PC Camera. You can get extra info with ffmpeg -f v4l2 -list_formats all -i /dev/video2. Finally, just use ffplay /dev/video2.

Finally I found how to fully shut up apt-get!

I am always using Google Colab, but in many cases I also need to install something using apt-get. The problem was that sometimes you need to add a new repository, update, install… then your notebook becomes full of text and that eats your memory (locally too as the browser needs to render that after all). So, today I found a nice post explaining the reason why the -qq argument may still leave some bits of text behind. You should go there and read it by yourself, but I will copy some info here in case that website disappears.

To add a new repository:

sudo apt-add-repository ppa:some-repository-here -y > /dev/null

And the ultimate commands:

sudo DEBIAN_FRONTEND=noninteractive apt-get update -qq < /dev/null > /dev/null

and

sudo DEBIAN_FRONTEND=noninteractive apt-get install some_cool_free_software -qq < /dev/null > /dev/null

As I started this post mentioning Google Colab, I think it’s worth pasting here the recipe to shut up pip as well:

pip -q install --upgrade some_cool_python_package > /dev/null

Bye bye, LinkedIn

Today, I decided to close my LinkedIn account. I’d been mulling over this idea for a while, trying to weigh the PROS/CONS. The final result was that I couldn’t see much value on having that account, and I also realized I should be posting things on my own website instead :smiley:

I still have my twitter account (@ricarbotics), but I’m thinking about shutting it down as well.

UPDATE (04/07/2022): After all my efforts, I couldn’t find another place where I can easily keep my professional contacts up to date (not everybody is on Twitter or have a personal website, github profile, maybe even email). So, for the time being I will keep my Linkedin account as an old business card binder…

UPDATE (23/12/2021): I decided to re-open my account because it was too deeply available on the search engines and I became afraid someone could take it over to create a fake account. So, now I’m back to LinkedIn, but without any contacts and almost zero personal info available for the time being.

UPDATE (04/02/2022): To be honest, after the Twitter take over by Musk, I started using LinkedIn more and it has been useful to learn about new papers, technologies, etc.

Variable Power Supply, with Current Limitation, from Commercial Off-the-Shelf parts... powered by USB-C!

From time to time I have a project with some electronics that need testing. This weekend I was checking how to power my Maple Syrup Pi Camera with a solar panel. However, prototypes always have a chance of generating the magic smoke, so it’s nice to be able to limit the current to avoid that fate. In addition to that, I already have a fancy soldering iron that is power by USB-C, so why not a cordless power supply powered by USB-C too? Below you can see the result from my weekend tinkering :sweat_smile:.

variable-power-supply
Digital Variable Power Supply, with Current limitation, powered by a USB-C power bank.

Read more...

Studying Flatbuffers to play with TFLite models

I may write another post in the near future about this, but for now it will be yet another very-short-post™ :wink:. I’m working with Tiny ML (or Edge AI or simply trying to run complex stuff on not-so-great hardware) and, currently, my focus is on Google Coral EdgeTPU. In general, I like Google, TensorFlow, etc, but a lot of the things they release are badly documented (or the documentation is just plain outdated) and others simply overcomplicated (ok, it may be useful when many people work on the same codebase…). Sometimes, I even think this is some sort of business strategy because a gigantic company like Google couldn’t do these things by mistake, but who knows. So, back to TFLite models, most of the users know they are Flatbuffers, but it’s so annoyingly hard to make simple things because you can’t find proper documentation (a Google search should ALWAYS return perfect results related to Google stuff, shouldn’t it????).

Read more...