Hi team
Following code snap for rotate the robot at Left Right and Around
In this case delay is used to decide the value of angle robot to be rotated
Once we set the delay value for example 90 degree it is working fine
But due to decay of battery voltage the motor speed can be reduced So previously set angle can be changed
as a solution we can use
for example turn Left
we can rotate robot until sensor one reached the black line and then stop the rotation
Hope above solution is worked
But I don’t understand how it write properly using coding
Hi expert…Can you please help me to write it
Thanks in advanced
void turn(unsigned char dir)
{
switch(dir)
{
case 'L':
// Turn left.
OrangutanMotors::setSpeeds(-80, 80);
delay(200);
break;
case 'R':
// Turn right.
OrangutanMotors::setSpeeds(80, -80);
delay(200);
break;
case 'B':
// Turn around.
OrangutanMotors::setSpeeds(80, -80);
delay(400);
break;
case 'S':
// Don't do anything!
break;
}
}
It is generally beyond the scope of our direct technical support to write custom user code like that, but what you’re describing sounds similar to how our maze solving example for the Zumo shield robot handles turns. So, you might be able to use the turn() function that starts on line 173 as an example.
The Zumo shield line sensor array consists of 6 sensors, so the turn() function continues to turn until one of the sensors (the second sensor in toward the turning direction) passes over the line.
The followSegment() function that on line 258 uses simple proportional control (which is basically a PID controller with the I and D coefficients set to 0). The offset_from_center variable is the error, which then gets multiplied by P (1/3 in this case) to calculate a power difference that’s proportional to the error.
Most maze courses I’ve seen only have straight line segments to follow between turns, so typically a full PID algorithm isn’t necessary, but it should generally be fine to use one like you’re suggesting.