How to Use Bluetooth LE Mouse with Ubuntu 16.04

Recently I’ve faced a lot of issues with some laptops interfering with the 2.4 GHz wireless mice, so I have adopted a new Bluetooth mouse to my accessories. Surprisingly, the Bluetooth did not work through the GUI interface… Fortunately, I got it to work using bluetoothctl!

Replacing the 00:00:00:00:00:00 with your Bluetooth mouse’s UUID will make it work!

Building PyQT5 with Python 2.7 on Ubuntu 16.04

So you want Qt5, but you have a lot of strict dependencies holding you back from going to Python 3. What to do? Go build everything yourself!

The following are steps based on a fresh install of Ubuntu 16.04, so adapt it per your needs.

First install the latest version of Qt. I was using the free open source edition. At the time of this post, the following was the set of commands given by Qt’s official website. I just downloaded the installation into my Downloads folder and ran it:

First download the installer:

Next, adjust the permissions and install Qt:

Now, that should have installed Qt5.x on your Ubuntu installation, it is time to install PyQt5 such that it uses Qt5 with Python 2.7. The key in this setup procedure is to build PyQt5 yourself.

First, SIP must be installed before proceeding with building PyQt5. You can download SIP from here. You can also just wget it!

Now is where things get important, as I always prefer to use virtual environments when working with Python, rather than installing everything on the global Python installation. After extracting the file, make sure to run configure.py using your virtual environment’s Python!

If the configuration was successful, the output should tell you that things related to SIP will be installed in your virtual environment’s folder, and NOT in your global Python that resides in /usr.

Now, running make and sudo make install will install SIP into your virtual environment folder, even if you are using sudo.

Now it is time to download PyQt5 and build it!

Configuration of PyQt5 is needed for building it. Again, using the right interpreter and the right parameters are key.

Now, assuming there are no errors, you should be able to run ‘import PyQt5’ in your virtual environment running Python 2.7!

Installing ZeroMQ & PyZMQ on Ubuntu

ZeroMQ is a distributed messaging system where a programmer of any level of expertise can easily connect their code across languages and platforms. Recently I had a need to connect multiple nodes on one of my projects and researched around until I found ZeroMQ. I took a quick glance on the Learn the Basics page and saw how easy it is to implement it myself and any of my team members to implement it.

In fact, the most difficult part with using ZeroMQ was the installation process and getting it to work with Python. PyZMQ is the Python binding for ZeroMQ, but I found the installation procedures a bit confusing and thought that I would give my own way of installing ZeroMQ and PyZMQ on Ubuntu.

This is assuming that you are installing on a new installation of Ubuntu. Some dependencies may already be installed if you are using a system that is already setup.

After installing some basic dependencies, we need to install libsodium. The following command lines are the way to install libsodium from source.

Now, we can finally install ZeroMQ!

Finally, on with PyZMQ, the Python binding for ZeroMQ.

Now, to test that PyZMQ was correctly installed, try:

If no errors show up, you are ready to go!

Since ZeroMQ and PyZMQ are constantly updated, I will try to keep this post updated with every major version.

Wifi Not Working with Dell M3800

I own quite a bit of laptops. Four Thinkpads (X201, X220, X230, T420) and a Dell (M3800). Recently after my Ubuntu 14.04 broke down, and as my code’s dependence on ROS lessened, I decided to upgrade my Dell M3800’s version from 14.04 to 15.10. Well, well, well… Not everything went smoothly.

Actually one thing did not go as planned. The supposedly “Ubuntu-supported’ M3800 had issues with its wireless card firmware. The specific card that my M3800 has is the Intel AC7260. Below is the fix that I had to conduct to get it working again, which is very simple. This really should be fixed right out of the box Ubuntu…

  1. Download the latest drivers
    1. https://wireless.wiki.kernel.org/en/users/drivers/iwlwifi
  2. Update the firmware
    1. Assuming you downloaded the following:
      1. https://wireless.wiki.kernel.org/_media/en/users/drivers/iwlwifi-7260-ucode-15.227938.0.tgz
    2. Unzip in the downloaded folder
    3. Run in command line:
      1. sudo cp iwlwifi-7260-15.ucode /lib/firmware/

Running the above and updating the firmware helped as now upon boot, the M3800 connects very quickly to a nearby hotspot.

Shell Ocean Discovery XPRIZE

I have always been fond of underwater robotics and thought that it might be the hardest environment for robots to perform in. We need to tackle of a multitude of challenges ranging from waterproof hardware to communication through these new mediums. It obviously will not be done in a short span of time and in the midst of drones dominating the headlines and locomotion on rough terrain even quite a distance away, I really wondered when we would start seriously considering underwater as another environment.

In the wake of SpaceX successfully landing its Falcon 9, I actually found something just as exciting that someone like me actually should have found out about much before.

So there is this new cool competition in XPRIZE called the Shell Ocean Discovery XPRIZE. The goal of this competition is to launch entries from shore or air into the competition area to produce:

  • high resolution bathymetric map
  • images of a specific object
  • identify archaeological, biological, or geological features
  • track a chemical or biological signal to its source (bonus)

Looking at these four tasks, the first thing that comes into my mind is, “Wow! DARPA-hard!”

This is going to be very interesting to continue to follow. Team registrations are due in June 2016 and regardless of what the outcome of this competition is come December 2018, advances in underwater robotics will be massive.

The massive downside is:

Operating Costs:

Teams will be responsible for funding their own technology development costs.

Anyone care to find some funding so we can have a go at this? 😉

Lua Classes

Lua and classes are a little awkward, as there really is no such thing as classes in Lua. However, it is possible to demonstrate a class like behavior using tables.

Tables are a type of object, and since an instance of a class is also an object, we can use tables as if the language itself supported classes.

You can see that an object called “Triangle” is created and useful functions for it is also created. If we were to execute these functions:

Then the outputs become:

Note that instead of the period ‘.’, I used the colon ‘:’ to create the functions. This is to pass ‘self’ as the first parameter for object-oriented programming. In the case that I used a period to create the functions, the following commands would result in an error.

In the entire reference manual, the colon syntax is mentioned very briefly, but personally, I find this to be a key syntax to effectively conduct OOP using Lua.

Python Trick of the Day (Sequence Types)

The thing that attracts me the most about programming is how you can make a certain code shorter by using clever logic or clever syntaxes. Through “Trick of the Day,” I can hopefully share a trick that I think is clever during my work (which involves quite a bit of programming).

Today’s trick is a very clever one in that if you have an instance such as the following:

There just has to be a way to shorten that repetition. Fortunately in Python, a trailing comma notation can be used to create a one-term tuple. This is called a sequence type.

So we could write the above code as:

I particularly find myself heavily using this when creating multiple objects of the same class and that requires the same inputs.

If you have any other way you perform this, feel free to share your thoughts below.