0% found this document useful (0 votes)
68 views5 pages

Robotics Lab 1

This document contains code from multiple parts of a lab report on controlling servos and moving an activity bot robot. It includes code to: 1) Direct servos to move the robot forward, backward, and pause for calculated times. 2) Move the robot around a 40cm square using calculated wheel rotations and turns. 3) Calculate left and right wheel velocities to move the robot in a circle of a given radius while checking a proximity sensor to stop if an obstacle is detected.

Uploaded by

Jessica
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views5 pages

Robotics Lab 1

This document contains code from multiple parts of a lab report on controlling servos and moving an activity bot robot. It includes code to: 1) Direct servos to move the robot forward, backward, and pause for calculated times. 2) Move the robot around a 40cm square using calculated wheel rotations and turns. 3) Calculate left and right wheel velocities to move the robot in a circle of a given radius while checking a proximity sensor to stop if an obstacle is detected.

Uploaded by

Jessica
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Hoa Nguyen

ENGR 3100
22 September 2020
Lab 1 Report

Part 3:
/*
Part 3
William Ard and Hoa Nguyen
This is a script for Part 3 of Lab 1 to practice learning how to
direct the servos to move.
*/
#include "simpletools.h" // Include simple tools
#include "abdrive.h" // Include simple tools
int main() // Main function
{
drive_speed(20, 20);
pause(30/(0.325*20)*1000); //Go forward 30cm at a speed of 20
ticks per second
drive_speed(0,0);
pause(2000); //stop and pause for 2 seconds
drive_speed(40, 40);
pause(40/(0.325*40)*1000); //Go forward 40cm at 40 ticks per
second.
drive_speed(0,0);
pause(2000); // Stop and pause for 2 seconds
drive_speed(-10, -10);
pause(10/(0.325*10)*1000); // Go backwards 10cm at 10 ticks per
second
drive_speed(0,0);
}

In order to calculate how much time was needed to travel 30 cm, the following calculation were
made:

30 𝑐𝑚
= 6.5 𝑠
20 𝑡𝑖𝑐𝑠 . 325 𝑐𝑚

𝑠𝑒𝑐 𝑡𝑖𝑐
Part 4:
The robot moved at 1 tic/s and 1 cm/s using the drive_goto function which only required the
calculation of the amount of tics each wheel needed to move,
1 𝑡𝑖𝑐
40 𝑐𝑚 ∗ = 123.07 𝑠𝑒𝑐𝑜𝑛𝑑𝑠 𝑜𝑟 123.07 𝑡𝑖𝑐𝑠
. 325 𝑐𝑚

Once the robot moved forward 40 cm, it turned 90 degrees, this process was repeated three
additional times.

Using the drive_goto function, the left wheel was made to move 26 tics clockwise while the right
wheel was made to move 26 ticks counterclockwise in order to make a 90 degree turn. The above
process was repeated three additional times.

Upon completion of following the perimeter of the 40 cm square, it turns around to retrace its
step. It does this by using the drive_goto function to turn the left wheel 26 tics

There could be several factors that contributed to the robot not being able to end up exactly at the
original location. This could be due to not a perfect calibration of the encoders, slip between the
floor and the wheels, and an uncertainty in the encoder measurements.

/*
Part 4
William Ard and Hoa Nguyen
This is a script to practice moving the Activity Bot

*/
#include "simpletools.h" // Include simple tools
#include "abdrive.h" // Include simple tools

int main() // Main function


{
while (!input(3))
{
}
int i=1;
for (i=1; i<=4; i++)
{
drive_goto(round(40/0.325), round(40/0.325)); // Move both
wheels for 40 cm
drive_goto(26, -26); // Turn 90 degrees
clockwise
}
drive_goto(26, -26); // Turn the robot 180
degrees

for (i=1; i<=4; i++)


{
drive_goto(round(40/0.325), round(40/0.325)); // Move both
wheels for 40 cm
drive_goto(-26, 26); // Turn robot to original
position
}
high(4); // Turn on the light at pin 4
pause(5000); // Keep light on for 5
seconds
low(4); // Turn off the light at pin 4
}
Part 5:
The calculations for the left and right wheel velocities were included in the code. The distance
beterrn the wheels were set as L = 105.8mm and the desired turning radius of 609.6 mm was set
as variable R.
Then the following equation was used in the code to calculate the wheel velocities.
𝐿
𝑉(1 − )
𝑉 = 2𝑅
3.25

𝐿
𝑉(1 − )
𝑉 = 2𝑅
3.25
In order to handle the robot being able to both move in a circle while also checking the
sensor for obstacles in order to stop, a while loop to keep the proximity sensor always
on was utilized. The for loop made the robot always move in a circle as long as there
wasn’t an obstacle 20 cm in front of the robot which the while loop was checking for.

/*
Part 5
William Ard and Hoa Nguyen
This is a script to practice moving the Activity Bot

*/
#include "simpletools.h" // Include simple tools
#include "abdrive.h" // Include simple tools
#include "ping.h"

int main() // Main function


{

int dist = ping_cm(8);

float L = 105.8; // Wheel distance (mm)


float R = 609.6; // Radius of curvature (mm)
float V = 250; // Tangential velocity (mm/s)

int VL = round(V*(1-L/2/R)/3.25); // Left wheel speed (ticks/s)


int VR = round(V*(1+L/2/R)/3.25); // Right wheel speed (ticks/s)
while (1)
{
if (dist > 20)
{
freqout(3,1000,1600); //output to pin 4 for 1000 milliseconds
at 800hz

while (dist > 20)


{
drive_speed(VL, VR); // drives the robot at the
calculated wheel speed
dist = ping_cm(8); // if the distance is less than
20, the buzzer will go off
pause(50); // pause for .005 seconds
}
}

else
{
freqout(3,1000,800); //output to pin 4 for 1000 milliseconds at
800 hz

while (dist <= 20)


{
drive_speed(0,0); // stops the robot if distance
pinged is less than 20
dist = ping_cm(8);
pause(50); // pause for .005 seconds
}
}
}
}

You might also like