User Guide of RobDev - RoboboUPMC2016/RobDoc GitHub Wiki

RobDev, Robot Behavior Framework

1. Introduction

RodDev is a Java framework allowing anyone to create basic robot behaviors. The framework has been created as part of the student project "Rob".

For downloading the latest version of the framework click here!

2. Creating a Behavior

Since RobDev is a Java framework, we recommend usage of an IDE as Eclipse although a simple text editor can be sufficient. A behavior is actually a basic Java class contained in a single file. This file must follow conventions below:

  • File name follows the pattern *.java
  • The main class implements interface robdev.Behavior

Basically a behavior follows this template:

import robdev.*;

public class MyBehavior implements Behavior {
	

	public void run(Actions actions) {
		...
	}

}

where method run contains the behavior definition.
This method can be seen as the main method of a standard Java program. Note that a behavior has to be read like a sequence of instructions.

3. Basics Actions

4. Handling Events Using "When" Instruction

You can create responsive behaviors using the instruction Actions.when(Event event, Runnable fun)

public class UnstoppableBehavior implements Behavior{

	public void run(final Actions action) {

		action.when(Event.SHOCK_DETECTED, () -> { avoidObstacle(action); });

		while(true)
			action.moveForward(1);

	}

	private void avoidObstacle(Actions action){
		action.turnLeft();
	}

}

5. Testing a Behavior

If you are a ROBOBO owner, you can test your behavior on your smartphone, via the application RobApp.

6. Using Java Features in Behaviors

For creating complex behaviors you can use Java features (variable declaration, loop, method definition, ...)

public class CounterBehavior implements Behavior {
	

	public void run(Actions actions) {
		count(actions);
	}
	
	private void count(Actions actions){
		for(int i=0; i<10; i++){
			actions.speak(i);
		}
	}


}```