RotateDegrees / DriveDistance

Please consider my projecthttp://tnt.drivehq.com/SenonTupa.zip


I am using RotateDegrees and DriveDistance commands of DifferentialDrive. The function IEnumerator<ITask> Algoritmo() is basically a copy from Robotics Tutorial 5.

I have found some issues and I need help:

  • When I order a RotateDegrees in 180°, nothing happens.
  • What is the precision of these functions? Sometimes I can see that 90o is not 90°...
  • I could see sometimes in a RotateDegrees command, the robot start turning indefinitely.
  • In my project code, You could see in Turn the "yield return" calls "StartTurn", that calls "Gira". It should wait until movement stops to go to next line. But the next movement is executed after the time defined in "TimeoutPort" in the line below. Why I need the "yield return" in "StartTurn" if the movement time is defined in "TimeoutPort"?
  • Why I need these 2 subcalls? Can I specify a function like "Rotate(double degree)" that I could call in "Algoritmo()"?


Thanks

[1346 byte] By [T.N.T.] at [2008-1-10]
# 1

Hello TNT,

Which hardware and corresponding service are you working with? The answers to your questions will depend on the implementation of that specific service..

You might find more information by looking at the console output [1]. Look for any Fault that may be displayed.

[1] http://localhost:50000/console/output

Some implementations of the Drive contract don't implement RotateDegrees, other simulate this by driving for a period of time.

Rather than linking to a zip, can you post some clips of the source code on this thread? I can answer more of your questions at that point.

Dave

DaveLee at 2007-10-3 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Simulation...
# 2

I think I wasn't too clear in my Post. I am simulating a robot in Robotics Studio, my project contains the simulation enviroiment code. I gave a link to my entire project because anyone can see it working in simulation.
Moderator moved this post to "Hardware Configuration and Troubleshooting", but I think this don't make sense, I don't have any hardware in simulation.

I am using SimulatedDifferentialDrive service in simulation.

Thanks a lot.

The code I have is this:

Code Snippet

IEnumerator<ITask> Algoritmo()
{
yield return Arbiter.Receive(false, TimeoutPort(600*TOTALROBOS), delegate(DateTime t) { });

LogInfo(LogGroups.Console, "Algoritmo DHM");

Random rnd = new Random();

// Move
yield return Arbiter.Receive(false,
StartMove(1),
delegate(bool result) { });

// wait
yield return Arbiter.Receive(false, TimeoutPort(10000), delegate(DateTime t) { });


while (true)
{
// Turn
yield return Arbiter.Receive(false,
StartTurn(-90),
delegate(bool result) { });

// wait
yield return Arbiter.Receive(false, TimeoutPort(2000), delegate(DateTime t) { });


// Move
yield return Arbiter.Receive(false,
StartMove(rnd.NextDouble() / 2 + 0.5),
delegate(bool result) { });

// wait
yield return Arbiter.Receive(false, TimeoutPort(10000), delegate(DateTime t) { });
}


yield break;

}


Port<bool> StartTurn(double angulo)
{
Port<bool> result = new Port<bool>();
// start a turn
SpawnIterator<Port<bool>, double>(result, angulo, Gira);
return result;
}

Port<bool> StartMove(double distancia)
{
Port<bool> result = new Port<bool>();
// start movement
SpawnIterator<Port<bool>, double>(result, distancia, Anda);
return result;
}

IEnumerator<ITask> Gira(Port<bool> done, double angulo)
{
LogInfo(LogGroups.Console, string.Format("Girando angulo {0}°", angulo));

drive.RotateDegreesRequest request = new drive.RotateDegreesRequest();
request.Degrees = angulo;
request.Power = 0.2;//fator de escala para velocidade linear de 10cm/s

yield return
Arbiter.Choice(
_drivePort.RotateDegrees(request),
delegate(DefaultUpdateResponseType rsp) {done.Post(true); },
delegate(W3C.Soap.Fault failure)
{
LogError("Erro ao girar rob?");
});

yield break;
}

IEnumerator<ITask> Anda(Port<bool> done, double distancia)
{
LogInfo(LogGroups.Console, string.Format("Andando distancia {0}m", distancia));

drive.DriveDistanceRequest request = new drive.DriveDistanceRequest();
request.Distance = distancia;
request.Power = 0.2;//fator de escala para velocidade linear de 10cm/s

yield return
Arbiter.Choice(
_drivePort.DriveDistance(request),
delegate(DefaultUpdateResponseType rsp) { done.Post(true); },
delegate(W3C.Soap.Fault failure)
{
LogError("Erro ao movimentar rob?");
done.Post(false);
});

yield break;
}

T.N.T. at 2007-10-3 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Simulation...
# 3

You are right, this question should be in the Simulation section not Hardware.

The implementation of RotateDegrees for the Simulated Differential Drive in V1.5 has a problem. I posted a message about this soon after 1.5 was released. It is affected by the speed of the motors, and can in fact miss the desired angle because it can overshoot in the time it takes for a single frame update if the motors are running at high speed.

If you can get my Simulated Differential Drive to work for you then it does not have this problem because of the way it operates. It actually looks for the change in angle, not a specific angle, and will stop once the difference has been exceeded.

However, the robot might NOT turn by exactly the angle you requested because the simulation does not have an infinitely small time interval between frames. Therefore it might turn a small amount too far. If you keep doing turns, eventually the robot might not be facing exactly the direction you think it is. In the real world this is a common problem. So I guess the simulator is closer to the real world than you might have expected :-)

Trevor

TrevorTaylor at 2007-10-3 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Simulation...
# 4

Thanks Trevor.

Sorry T.N.T, I have moved this post back to Simulation. It seems as though Trevor has answered your question.

Dave

DaveLee at 2007-10-3 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Simulation...

Microsoft Robotics Studio

Site Classified