Subscribe RSS

Howto program AdMoVeo in Eclipse (through processing)

Install these programs

Create a new project

Start a new project in Eclipse: FILE –> NEW PROJECT and select “Java Project.” Enter Projectname e.g. AdMoVeoInEclipse and select Finish.

Import the Processing and Creapro libraries

Rightclick on the project name in the project explorer and select Properies.

Select Java Build Path And choose the Libaries tab.

Add External JAR’s… and browse to the following files

Core.jar in your <processing location>\lib\

Creapro.jar in  <sketchbook location>\libraries\CreaPro\library\

serial.jar in <processing location>\libraries\serial\library\

RXTXcomm.jar in <processing location>\libraries\serial\library\

AdMoVeoInEclipse_buildpath

Select RXTXcomm in the build path and expand it [+] and select the Native library location

Press Edit and select External folder and set this to <processing location>\libraries\serial\library\

AdMoVeoInEclipse_nativelib

Create a Class and test your code

Create a class FILE -> NEW -> CLASS called AdMoVeoInEclipse

Import the processing core and AdMoVeo library and make this Class a extension of the processing PApplet.

import processing.core.*;
import nl.tue.id.creapro.admoveo.*;
 public class AdMoVeoInEclipse extends PApplet {

Copy the rest of the example processing code (or type your own) for the AdMoVeo robot from wiki.id.tue.nl/creapro/AdMoVeoInProcessing and paste it in your AdMoVeoInProcessing Class

Make all your processing function public.

Select the correct com port and run your code

admoveo = new AdMoVeo(this, "COM5");

The complete code will look like this

import processing.core.*;
import nl.tue.id.creapro.admoveo.*;

public class AdMoVeoInEclipse extends PApplet {

	AdMoVeo admoveo;
	int bgcolor = 255;

	public void setup()
	{
	  admoveo = new AdMoVeo(this, "COM5");
	  admoveo.getLeftDistanceSensor().enable();
	}

	public void draw()
	{
	  background(0,0,bgcolor);
	}

	public void inputAvailable(Sensor sensor, int oldValue, int newValue){
	    if(sensor == admoveo.getLeftDistanceSensor()){
	        admoveo.execute("changeBlueLed", AdMoVeo.NOW);
	    }
	}

	public void changeBlueLed(SensorStatus s){
	  bgcolor = s.get(admoveo.getLeftDistanceSensor())/4;
	  admoveo.getBlueLed().setPower(bgcolor);
	}

}