Xatcobeo ready!
Oh, well… in the previous post I didn’t mention this… Our small CubeSat, Xatcobeo Satellite, is done!!!!
I will speak more another day.
More info:
- ESA Site descrition: http://infeo1.eo.esa.int:8090/presentations/10000699/10003430.html
- ESA news (in Spanish): http://www.esa.int/esaCP/SEMA90WWVUG_Spain_0.html
- Xatcobeo Twitter page: https://twitter.com/#!/xatcobeo
- Xatcobeo Facebook page: https://www.facebook.com/pages/Xatcobeo/211913885505499
- Description on Gumter’s Space page: http://space.skyrocket.de/doc_sdat/xatcobeo.htm
Hi!
OMG! I was disconnected of this Web a long time!!!
I have no much time for this, because I am studying another MSc Degree: “Control and Systems Engineering (virtual campus on this link)” in the Computer Science Faculty of the great Complutense University of Madrid (but using on-line methodology). It is related to sensors and actuators, data mining, heuristics, artificial intelligence, computer vision, mobile robotics, and much more. You can select the matters you want (they say “great universities like Staford do this, we think is a great idea, then we let you do this too”).
Also, since the past August (2011) until now I am working now on a R&D (Research and Development) projects enterprise (CTAG) related do automotive industry (it is a foundation of the Galician Automotive Cluster Enterprises). My work consists in active safety projects (I am working now on two European projects: mainly on a subproject of ecoMove Project, and collaborating on Drive C2X Project). Also I am doing documentation tasks for Xatcobeo Project, of the great too University of Vigo (where I studied computer science, at ESEI, I think a great faculty; and the MSc in Project Management), but I won’t abandon this Blog!!
In fact, I will link a very interesting video, of the NASA’s Mars Science Laboratory (MSL), in which they speak about parts of the project development:
More info:
- Video on NASA’s Web Site: http://www.nasa.gov/multimedia/videogallery/index.html?collection_id=18895&media_id=122317741
- NASA’s Mars Science Lab. Site: http://www.nasa.gov/mission_pages/msl/index.html
Paused :)
Probably you realized I didn’t write any post since a pair of weeks.
This is because I have been operated in my left hand (scaphoids bone).
I won’t write much for a week (write with only a hand is not very comfortable), but I will continue in a short time.
See you soon!
MPI: Cartesian Topologies in MPI libraries
In this post I will present a keynote about MPI and cartesian topologies using this libraries.
In the future I am probably to try to write the same thing here, but now I don’t have much time for this.
Intro
MPI means “Message Passing Interface” and it is a language-independent communications protocol that allows processes to communicate with one another by sending and receiving messages. This protocol have many API implementations (I only worked with the C version, but the Fortran version is widely used).
It is typically used for parallel programs running on computer clusters and supercomputers, where the cost of accessing non-local memory is high. MPI’s goals are high performance, scalability, and portability.

MPI Logo
Overview
The MPI interface is meant to provide essential virtual topology, synchronization, and communication functionality between a set of processes (that have been mapped to nodes/servers/computer instances) in a language-independent way, with language-specific syntax, plus a few language-specific features. MPI programs always work with processes, but programmers commonly refer to the processes as processors. Typically, for maximum performance, each CPU (or core in a multi-core machine) will be assigned just a single process. This assignment happens at runtime through the agent that starts the MPI program, normally called mpirun or mpiexec.
I won’t write an introduction to MPI, if you don’t know anyting about MPI, you can search some guide on the Internet.
I have found one and it looks fine “An Introduction to MPI” (William Gropp and Ewing Lusk, from the Mathematics and Computer Science Division at the Argonne National Laboratory of the U.S. Department of Energy).
Keynote download
You can see or download the keynote here. It was written in Galician language (it was an article for “Parallel Computing” subject, made by a classmate, Alberto Montes, and me).
Examples/exercises (not in keynote)
In this simple example it be created a Cartesian topology according next points:
- dimension will be 2
- 2 process per column x 4 process per row
- shape: vertical toroid
It checks
- it will be checked if was constructed according previous points
- number of processes is the correct according previous points
Furthermore:
- each process will check if the net is well built
- each neighbor have to be checked and printed
//Sorry, I have to translate all comments
#include <stdio.h>
#include <stdlib.h>
#include "mpi.h"
#define ROOTP 0 // root process
#define NDIMS 2 // dimension number
#define ELS_COL 2 // number of elements in each column (no. rows)
#define ELS_FILA 4 // no. elements per row (nº columns)
#define REORD 1 // reordernación (so para arquitecturas específicas)
#define TAG 96
int main(int argc, char *argv[]) {
int rank, n_procs, topol;
int dim_vs [NDIMS] = {ELS_FILA,ELS_COL}, periodici[NDIMS]={1,0};
int sup, inf;
int esq, der;
int error_count = 0, distr_error_count = 0;
MPI_Comm novo_Comm;
MPI_Status estado;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank); /* get current process id */
MPI_Comm_size(MPI_COMM_WORLD, &n_procs); /* get # procs from env or */
if ( n_procs != ELS_FILA * ELS_COL ){
if (rank == ROOTP)
printf( "\n\tERRO: o nº de procesos é menor do precisado "
"(%d). Procédese a abortar a execución\n\n",
(ELS_FILA * ELS_COL) );
MPI_Finalize();
return EXIT_FAILURE;
}
MPI_Cart_create(MPI_COMM_WORLD, NDIMS, dim_vs, periodici, REORD ,&novo_Comm);
MPI_Topo_test(novo_Comm, &topol);
if (topol != MPI_CART){
if(rank == ROOTP)
printf( "\n\tERRO: topoloxía virtual incorrecta."
" Procédese a abortar a execución\n\n");
MPI_Finalize();
return EXIT_FAILURE;
}
MPI_Cart_shift(novo_Comm, 0, 1, &sup, &inf);
if ( ( sup < 0 ) || ( inf < 0 ) ){
printf("\tERRO, veciños na vertical de %d, Sup: %d, Inf: %d\n", rank, sup, inf);
error_count++;
}
else if (error_count == 0)
printf("Veciños na vertical de %d, Sup: %d, Inf: %d\n", rank, sup, inf);
MPI_Cart_shift(novo_Comm, 1, 1, &der, &esq);
printf("Veciños na horizontal de %d, Esq: %d, Der: %d\n", rank, der, esq);
if ( rank != ROOTP )
MPI_Send(&error_count, 1, MPI_INT, ROOTP, TAG, novo_Comm);
else {
int i;
for (i = 1; i < n_procs; i++){
MPI_Recv(&distr_error_count, 1, MPI_INT, i, TAG, novo_Comm, &estado);
error_count += distr_error_count;
}
}
if ( rank == ROOTP ) {
if (error_count > 0)
printf("Atopáronse %d erros na construcción. Revise os"
" parámetros de periocidade\n",error_count);
else
printf("Topoloxía virtual cartesiana correctamente creada\n");
}
MPI_Finalize();
return EXIT_SUCCESS;
}
More info:
- An Introduction to MPI (William Gropp and Ewing Lusk)
- MPI Specification
- Open-MPI Web Site
- Article at Wikipedia
- MPI Topologies: Graph Topology
Reactive systems programming in Java using SugarCubes: a theoretical and practical approach
In this entry I am going to speak about SugarCubes, a set of Java Classes used for concurrent programming of reactive systems.

Reactive Systems: intro
Reactive systems, unlike the purely classical transformational systems, maintain a continuous interaction with their environment, responding to external stimuli as a function of its internal state. This difference can be seen more clearly by observing the characteristics of each and comparing them:
A Transformational System:
- A data input is taken and it returns an output.
- The order of data inputs is preset.
- Its execution must end.

Transformational System Scheme
A Reactive System:
- System that continuously interacts with the environment, receiving stimuli and producing outputs in response.
- The order of events in the system is not predictable, is determined by external events.
- The execution of reactive systems does not have to end

Reactive System Scheme
Comparison:
- Transformational systems are deterministic. They return the same outputs for the same input data.
- Reactive systems are inherently non-deterministic.
- Sequential languages are not suitable for programming reactive systems.
- The order of execution of instructions is predetermined by the structure of language:
- P;
- Q;
- R;
- It implies: P –> Q –> R
- The order of execution of instructions is predetermined by the structure of language:
- In reactive systems the instructions execution order can be determined by the occurrence of external events.
This causes the behavior of reactive systems is complex to analyze and error prone. Many of these errors may cause security issues, so often reactive systems are also critical systems.
There are a number of formalisms that can be used for the specification of real-time systems and reactive systems. Among the formalisms used include structured methods: operational methods used in the industry for being graphic, easy to learn, to use and to review. But this methods are not formal methods, then, generally, there is no way to analyze important properties such as the security.
What is SugarCubes?
SugarCubes provides us an structured and easy approach to concurrency and it is a set of Java classes for implementing:
- Event based systems, especially those where events are instantly broadcast throughout the system. Communicating in this framework is like in radio transmissions, where emitters send information that is instantaneously received by all receivers.
- Concurrent systems, in particular thread-less ones. Here, parallelism is a logical programming construct to implement activities which are supposed to proceed concurrently, and not one after the other.
- Reactive systems, which continuously react to activations.
In the paper you can see this and much more about SugarCubes and can see how to start a project using the 2.0 version (recently was released the 3.0 version).
![]()
Paper download/visualization
You can see or download the PDF (in Spanish) here.
More info
- SugarCubes Web Site
- SugarCubes v3 Java Docs
- SugarCubes v3 framework (Thesis of J.-F. Susini, in french. PDF)
- The SugarCubes v2 Reference Manual (PDF) (I can’t find the v3 reference manual, you have to see the Thesis)
- Lesson: Concurrency (at Oracle Java Web Site)
- A blog from a Google Employee (Jeremy Manson) speaking about Java Concurrency
- Introduction to Java concurrency / multithreading Tutorial (by Jakob Jenkov)
Mindstorms NXT: “C” and “Java” programming intro
The past year (2010, last 5-year degree course) I studied real real-time systems design and I did an (optional and) very interesting classwork with an Lego MindStorms NXT, in which I had to see how it works and how to programming it (a very small research
)

I had a floor with gray tiles and a roll of white adesive tape… And with this material we build a “racing circuit”, in which the Lego had to run over the white tape.
Introducing NXC (a version of C)
NXC is very similar to C language. You can learn a lot about it in the official site, in the NXC API section. It is on the Site of Bricx Command Center (BrixCC). There you can download the IDE (problem: only windows version, but actually you have Linux or Mac OS X alternatives, the NeXT Tools).
Code in C (NXC)
Tested and working (with the gray tiles and white adesive tape parameters).
Sorry, comments are in Galician language…
int CINTA_BLANCA_MIN = 47; // white tape: minimum value
int curve_time = 50; // 0,1 seconds by default
int move_time = 100; // 0,2 seconds by default
int speed_curve = 75; // % of maximum engine capacity
int opposite_speed_curve = 25;
int speed_straight = 50; // % of engine capacity to go straight
task main()
{
SetSensorLight(IN_1); // Indicates that this port (right side) is connected to an optical sensor
SetSensorLight(IN_4); // " (but left side)
while (true)
{
/*
// RIGHT AND LEFT SENSOR CHECK THE AT SAME TIME (if it detects the tape): We assume that the NXT is perpendicular to the tape ...
if ( (Sensor(IN_1) > CINTA_BLANCA_MIN) & (Sensor(IN_4) > CINTA_BLANCA_MIN) )
{
OnFwd(OUT_C, speed_curve); // turn left
Wait(curve_time); // continue path during curve_time
}
*/
// RIGHT SENSOR CHECK (if it detects the tape)
if (Sensor(IN_1) > CINTA_BLANCA_MIN)
{
// turn left
OnFwd(OUT_A, speed_curve); // accelerate engine (side we want to turn)
OnFwd(OUT_C, opposite_speed_curve); // decelerate opposite engine
Wait(curve_time); // continue path during curve_time
}
// LEFT SENSOR CHECK (if it detects the tape)
else if (Sensor(IN_4) > CINTA_BLANCA_MIN)
{
// turn right
OnFwd(OUT_C, speed_curve);
OnFwd(OUT_A, opposite_speed_curve);
Wait(curve_time);
}
else // go straight!
{
OnFwd(OUT_AC, speed_straight); // speed up and go straight
Wait(move_time); // continue path during move_time
}
}
Off(OUT_AC); // really, this order must be never executed...
}
Explanation about leJOS: NXJ, a Java version for Lego NXT
LeJOS (according to the official website read pronounced as the Spanish word “lejos”, meaning far) is a small Java virtual machine. In 2006 it was ported to the LEGO NXT brick.
This virtual machine is a firmware for the NXT LEGO block: you have to install the new firmware NXT, overwriting the existing (it can be a risk).
The firmware installer and compiler development for the computer is available for 32-bit Windows, GNU/Linux or Apple Mac OS-X in http://lejos.sourceforge.net/nxj-downloads.php
By this way, your lego supports what is called NXJ, “Not Exactly Java”, very similar to Java but not exactly Java (remember NXC)
Code in Java… better said, in Not eXactly Java (NXJ)
Not tested (the Lego wasn’t mine and the owner, the Professor, decided it was too risk changing the firmware, and I agree with him, but if you have enough money and like the risk, you can try; when I buy a NXT, I will convert it in a NXJ)
import lejos.nxt.*;
import lejos.util.*;
public class circuito1 {
static int CINTA_BLANCA_MIN = 47; // mínimo valor en cinta blanca
int curve_time = 50; // 0,05 segundos por defecto
int move_time = 100; // 0,1 segundos por defecto
/* Velocidades para usar con Motor.setSpeed.
En Motor.setSpeed configúrase o motor en º (grados) por segundo.
Según a información atopada nos Java Docs do API, o tope (sin conectar o LEGO a 8V) parece é 900
NOTA: habería que revisar na práctica estes valores, aquí son calculados teoricamente.
*/
// NXC -> 75%. 75% of 900 = 675 degrees per second
int jspeed_curve = 675; // 75% of Max. encine capacity
// NXC era 25%. 25% de 900 = 225 degrees per second
int jopposite_speed_curve = 225; // 25% of Max. engine capacity
// NXC era 50%. 50% de 900 = 450 degrees per second
int jspeed_straight = 450; // 60% of Max. engine capacity
TimerListener tL;
Timer tmr = new Timer(move_time, tL); // Timer(int theDelay, TimerListener el)
public void circuito1()
{
}; // circuito1
public void corre(){
LightSensor light1 = new LightSensor(SensorPort.S1); // Indicates that this port (right side) is connected to an optical sensor
LightSensor light4 = new LightSensor(SensorPort.S4); // " (left side) Indicamos que a ese porto está conectado un sensor óptico. Será o do lado esquerdo
while (true)
{
// CHEQUEAMOS SENSOR DEREITO (se detecta a cinta)
if (light1.readNormalizedValue() > CINTA_BLANCA_MIN)
{
// xiramos á esquerda
Motor.A.setSpeed(jspeed_curve); // aumentamos velocidad en motor del lado que deseamos girar
Motor.C.setSpeed(jopposite_speed_curve); // reducimos velocidad en motor contrario
tmr.setDelay(curve_time); // continuamos a traxectoria durante curve_time
tmr.start();
} // if
// CHEQUEAMOS SENSOR ESQUERDO (se detecta a cinta)
else if (light4.readNormalizedValue() > CINTA_BLANCA_MIN)
{
// xiramos á dereita
Motor.C.setSpeed(jspeed_curve); // aumentamos velocidad en motor del lado que deseamos girar
Motor.A.setSpeed(jopposite_speed_curve); // reducimos velocidad en motor contrario
tmr.setDelay(curve_time); // continuamos a traxectoria durante curve_time
tmr.start();
} // else if
else // go straight!
{
// aceleramos e seguimos recto
Motor.A.setSpeed(jspeed_straight);
Motor.C.setSpeed(jspeed_straight);
tmr.setDelay(move_time); // continuamos a traxectoria durante curve_time
tmr.start();
} // else
} // while
} // corre()
public static void main (String[] args) {
circuito1 c1 = new circuito1();
c1.corre();
} // public static void main
}
I’m sorry, I didn’t recorded the Lego doing the “adesive tape circuit”
Paper download/visualization
You can see or download the PDF (in Spanish) here
More info:
- NXC Programmer’s Guide
- Interesting blog I discovered now: The NXT Step
More about Lego (and Lego & NASA
)
- Interesting site I discovered recently: Lego Space experience… At section “videos” you can find “How to build a Satellite“…
- Lego Space at Wikipedia
Machine Learning with Apache Mahout
This is an small introduction to Machine Learning with Apache Mahout

It was an article for “Automatic Reasoning and Machine Learning” subject
Paper download/visualization
You can see or download the article here (PDF in Spanish, in ACM format).
