Showing posts from 2015

Enumerating Range For in C++11

C++11 has introduced range-for loops that greatly simply the loop process over STL containers and other iterable entities such as arrays or initializers_lists. While this comes handy some times it is needed to have the index of the iterated entity for performing some other operations. The Python equivalent is enumerate.

Keeping Skype away for sometime in OSX

This is a small AppleScript for keeping Skype in DND mode during lecturing or giving a talk and automatically put it back. It accepts the number of minutes from command line, sends Skype in DND and then at the end put it back online.  The snippets at the beginning and end can be used to manually controlling the status via command line. The accepted options are "AWAY/OFFLINE/DND/ONLINE".

onrundurationmintellapplication"Skype"sendcommand"SET USERSTATUS DND"scriptname"My Script"endtellsetdurationsectodurationmin*60setstartTimetocurrent datedelaydurationsecsetelapsedTimeto ((current date) -startTime) tellapplication"Skype"sendcommand"SET USERSTATUS ONLINE"scriptname"My Script"endtellendrun

Swissknife tool for ONI files

The ONI file format is the mechanism provided by OpenNI for supporting the recording of videos from RGB-D cameras. This format is generally designed to support multiple compressed streams among which color and depth are the most important. Inside ROS the rosbag fulfils most the data recording and playback needs, but outside ROS the OpenNI is a valuable tools for dealing with RGB-D videos.

Starting from a simple tool for fixing truncated ONI files, I have prepared a more general Python-based tool for manipulating ONI files, motivated by the needs of our research activity and limitations in the C++ API. Some of the features are in common with video editing while others are more specific to the 3D nature of the stream: Filtering: removal of the depth or color channelCutting the file in a given rangeTime Manipulation: rescaling of the time, insertion of duplicate frames or dropping framesExtraction of the Color channel as MJPEG video or the depth as PNG images (16-bit depth)Registration of…

Compile Time C++ Tensors via Parameter Packs

The manipulation of tensors (n-dimensional arrays) emerges from several application domains in engineering, computer science and statistics (e.g. discrete CPDs). In C++ this is typically possible with dynamically allocated multidimensional arrays such as the ones from OpenCV (Mat class), but in many occasion there is the interest to rely on the optimizations provided by compile-size arrays.
Two approaches have been proposed: the first is based on the nesting of std::array (here) while the second, used by boost multidimensional library (here),  provides views over single fixed size array. In the latter case the size is fixed at compile-time but the multidim shape is not and there is partial compile-time size verification.

In this post I am addressing full compile-time multidimensional types obtained via C++11 template metaprogramming in particular parameter packs. A class will provide the storage of data as a flat array, and then different views can be generated over this array. In pa…

Robotic Vagrant for YARP

Today the YARP Framework course is starting in our lab, thanks to Lorenzo Natale. I have taken the occasion to prepare the vagrant boostrap files for supporting YARP. Quite simple except some minor changes for supporting Ubuntu 12.04 due to cmake versions.

The github repo has been updated as well.

Update: it is worth adding a note about the use USB devices within vagrant boxes. When using the virtualbox provider just use "vboxmanage list usbhost" for identifying the device and then use the following script to add it to the configuration file:

VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION)do|config| = "precise64" config.vm.box_url = ""# Add usb filter to attach SmartCard reader config.vm.provider:virtualboxdo|vb| vb.customize['modifyvm', :id, '--usb', 'on'] vb.customize['usbfilter', 'add', '0', '--target&…

Packaging your robotic VM with Vagrant

This is a short post on using Vagrant for packaging your Linux box, virtual or real, using Vagrant. The target configuration at this moment is the following:
Ubuntu 12.04 or 14.04 with 3.14.17Gcc updated 4.8.1 for 12.04 or stock 4.8.2 for 14.04Xenomai 2.6.4 (matching the kernel version)ROS Hydro Among them building the Kernel patched with Xenomai is the most interesting thing, but before that the stock gcc has to be upgraded to 4.8. Then the following steps are needed: Download Xenomai 2.6.4 and the Kernel 3.14.17Patch the Kernel using XenomaiAutomatically configure the Kernel for real-time supportBuild and Install the kernelBuild Xenomai native libraries The above is performed by means of three scripts (here) interspersed by the vagrant reload command that reboots the machine as supported by the following plugin here. Note that the automatic kernel configuration is obtained by a simple Python script that removes config entries and add others. This script differs from the kernel provide…