Introduction
ER1 is a robotic toolkit available at Evolution Robotics for few hundredth dollars. The kit comprises motors, a camera, IR sensors, a gripper, and a configurable structure. The robot is controlled by a laptop through USB connection. The robot is controlled by an application shipped with the kit that can be used remotely using text commands sent through a TCP connection. ER1Lib is a managed library to control the ER1 robot.
Notes
The latency of the TCP connection is somewhat annoying, we found that setting the robot to the full speed would result in misbehaviours because of it. In certain situations it takes up to 1 second (5 meters) to react.
Why is in Robotics4.NET?
Wonder why? :) Perhaps you'd like to test our framework, some day... ;)
Example
In this code fragment it is shown a program fragment that navigates in a building like the one displayed in the R2 game. Navigation is achieved by attempting to balance the values read from sensors (displaced one in front, the remaining two 45 degrees toward left/right). The robot variable is an instance of the class exposing ER1 services.
Show
private void ReadSensors() {
double alfa = (double)numericUpDown4.Value;
central = (int)Math.Floor((alfa * robot.IrSensors(2)) + (1 - alfa) * central);
left = (int)Math.Floor((alfa * robot.IrSensors(3)) + (1 - alfa) * left);
right = (int)Math.Floor((alfa * robot.IrSensors(1)) + (1 - alfa) * right);
textBox1.Text = ""+left;
textBox2.Text = ""+central;
textBox3.Text = ""+right;
}
private void move() {
bool moving = false;
while(work) {
ReadSensors();
if(!moving) {
robot.Move(100.0,RobotSRV.Units.meters,false);
Saveposition();
moving = true;
}
if(central>threshold) {
robot.Move((left > right) ? -90.0 : 90.0,RobotSRV.Units.degrees,true);
moving = false;
}else{
int delta = left-right;
if(Math.Max(left, right) > threshold_rt && Math.Abs(delta)>threshold_fw) {
robot.Move(delta/5.0,RobotSRV.Units.degrees,true);
moving = false;
}
}
}
}