Straight Movement Alignment
In our model, the gyroscope sensor is also used to calibrate the robot to move in a straight direction.
It was found that while moving straight, the robot was slightly turning its face by 5-10 degrees, an error due to the motors and tyres.
To move the robot in straight direction, we are using the below algorithm:
temp = gyro();
if(temp ==arr_angle[i]){
move_straight(moving_direction, sp);
}
else if(temp > arr_angle[i]){
move_straight_syn2(moving_direction);
}
else {
move_straight_syn(moving_direction);
}
[move_straight_syn2(moving_direction) – Moves right motor with constant speed and slows down left motor.
move_straight_syn(moving_direction) – Moves left motor with constant speed and slows down right motor. ]
If the above algorithm , The robot is moving in a straight line. As soon as there is a difference in the values of current gyro reading(temp) and the previously set gyro value, it detects the difference and makes call to respect move_straight_syn or move_straight_syn2 functions. Thus, keeping the robot in most possible straight direction.
Below are the code for move_straight_syn function:
We reduce the speed of right motor by multiplying the maximum speed by 13/20. This results in robo to move right.
set_tacho_speed_sp(sn1,dir*max_speedA*13/20); //right motor
set_tacho_speed_sp(sn2,dir*max_speedB); //left motor
Similarly, for move_straight_syn2 function:
We reduce the speed of left motor by multiplying the maximum speed by 13/20. This results in robo to move left.
set_tacho_speed_sp(sn2,dirmax_speedB13/20); //left motor
set_tacho_speed_sp(sn1,dir*max_speedA); //right motor