Code Examples
A repository of 155 code examples for BeepBeep
robot.DetectSkidding Class Reference

Detects situations where a moving robot loses traction and starts skidding. More...

Static Public Member Functions

static void main (String[] args)
 
static Vector< Float > vecc (Number x, Number y)
 Utility method to create a 2D vector from Cartesian coordinates. More...
 
static Vector< Float > vecp (Number r, Number theta)
 Utility method to create a 2D vector from polar coordinates. More...
 
static float rad (float deg)
 Converts degrees to radians. More...
 

Detailed Description

Detects situations where a moving robot loses traction and starts skidding.

For the purpose of this example, skidding is is identified as a prolonged interval during which the orientation of the robot differs significantly from the orientation of its movement (i.e. the robot is pointing in one direction but moving in another one).

The example does not merely detect a skidding interval (which would be a relatively classical case of runtime verification). Rather, it summarizes a skidding situation by outputting a complex event called a "skidding incident", which is only emitted once the skidding ends. This event is a triplet containing:

  • The modulus of the robot's speed vector at the start of the skidding interval (i.e. the initial speed when the skidding started)
  • The number of consecutive events the skidding incident is spanning
  • The maximum deviation observed between the robot's orientation and its direction of motion during the skidding incident

This example makes use of the RangeCep processor, which can create "complex" events summarizing a stream of lower-level events.

To make the example more realistic, the detection of skidding allows a few "normal" events to occur interspersed with skidding events. The condition is that m out of n successive events should reveal a skidding state for the overall sequence be considered as an occurrence of skidding.

Author
Sylvain Hallé

Definition at line 74 of file DetectSkidding.java.

Member Function Documentation

◆ rad()

static float robot.DetectSkidding.rad ( float  deg)
static

Converts degrees to radians.

Parameters
degThe angle in degrees
Returns
The angle in radians

Definition at line 221 of file DetectSkidding.java.

222  {
223  return (float) (2 * Math.PI * deg / 360f);
224  }

◆ vecc()

static Vector<Float> robot.DetectSkidding.vecc ( Number  x,
Number  y 
)
static

Utility method to create a 2D vector from Cartesian coordinates.

Parameters
xThe first coordinate
yThe second coordinate
Returns
The vector

Definition at line 194 of file DetectSkidding.java.

195  {
196  Vector<Float> v = new Vector<Float>(2);
197  v.add(x.floatValue());
198  v.add(y.floatValue());
199  return v;
200  }

◆ vecp()

static Vector<Float> robot.DetectSkidding.vecp ( Number  r,
Number  theta 
)
static

Utility method to create a 2D vector from polar coordinates.

Parameters
rThe modulus
thetaThe angle (in radians)
Returns
The vector

Definition at line 208 of file DetectSkidding.java.

209  {
210  Vector<Float> v = new Vector<Float>(2);
211  v.add(r.floatValue() * (float) Math.cos(theta.floatValue()));
212  v.add(r.floatValue() * (float) Math.sin(theta.floatValue()));
213  return v;
214  }

The documentation for this class was generated from the following file: