Skip to content

Commit 5996c32

Browse files
joseajosea
josea
authored and
josea
committed
Fixing bug in object detector
Adding Clawbot Electromechanical model and accompanying lessons
1 parent 6fb2af4 commit 5996c32

File tree

61 files changed

+2667
-2653
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2667
-2653
lines changed

Robotics Playground.mltbx

1.61 MB
Binary file not shown.
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
function c = calcHypot(a,b)
2-
%calcHypoth Solution
3-
4-
% This function calculates the hypothenuse given the length
5-
% of two for the sides of a right triangle
6-
c=sqrt(a^2+b^2);
7-
8-
end
9-
1+
function c = calcHypot(a,b)
2+
%calcHypoth Solution
3+
4+
% This function calculates the hypothenuse given the length
5+
% of two for the sides of a right triangle
6+
c=sqrt(a^2+b^2);
7+
8+
end
9+
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
clear
2-
clc
3-
4-
a=12;
5-
b=17;
1+
clear
2+
clc
3+
4+
a=12;
5+
b=17;
66
c=sqrt(a^2 + b^2)
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
clear
2-
clc
3-
4-
result1=2+3;
5-
result2=4+5;
1+
clear
2+
clc
3+
4+
result1=2+3;
5+
result2=4+5;
66
result3=result1 + result2
Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
% Create virtual robot
2-
myRobot=mlrobot;
3-
4-
% Start running the virtual environment simulation
5-
mlrobotstart(myRobot);
6-
7-
% Set both motors to a value that will make the robot move forward
8-
% NOTE: The direction of one motor is inverted use a negative value if
9-
% necessary
10-
% HINT: use "mlrobotsetmotorvoltage"
11-
12-
mlrobotsetmotorvoltage(myRobot,'left',-3);
13-
mlrobotsetmotorvoltage(myRobot,'right',3);
14-
15-
% delay for 5 seconds so the robot moves forward
16-
pause(5);
17-
18-
% Set motors to same values to make the robot turn
19-
20-
mlrobotsetmotorvoltage(myRobot,'left',-3);
21-
mlrobotsetmotorvoltage(myRobot,'right',-3);
22-
23-
% Wait for a period of time until the robot is facing in the opporite
24-
% direction
25-
26-
pause(6);
27-
28-
% Set motor values again to make robot move forward
29-
30-
mlrobotsetmotorvoltage(myRobot,'left',-3);
31-
mlrobotsetmotorvoltage(myRobot,'right',3);
32-
33-
% Wait until the robot reaches its original position
34-
35-
pause(5);
36-
37-
% Set both motors to zero voltage
38-
% HINT: use "mlrobotsetmotorvoltage"
39-
40-
mlrobotsetmotorvoltage(myRobot,'left',0);
41-
mlrobotsetmotorvoltage(myRobot,'right',0);
42-
43-
% Stop simulation
44-
mlrobotstop(myRobot);
1+
% Create virtual robot
2+
myRobot=mlrobot;
3+
4+
% Start running the virtual environment simulation
5+
mlrobotstart(myRobot);
6+
7+
% Set both motors to a value that will make the robot move forward
8+
% NOTE: The direction of one motor is inverted use a negative value if
9+
% necessary
10+
% HINT: use "mlrobotsetmotorvoltage"
11+
12+
mlrobotsetmotorvoltage(myRobot,'left',-3);
13+
mlrobotsetmotorvoltage(myRobot,'right',3);
14+
15+
% delay for 5 seconds so the robot moves forward
16+
pause(5);
17+
18+
% Set motors to same values to make the robot turn
19+
20+
mlrobotsetmotorvoltage(myRobot,'left',-3);
21+
mlrobotsetmotorvoltage(myRobot,'right',-3);
22+
23+
% Wait for a period of time until the robot is facing in the opporite
24+
% direction
25+
26+
pause(6);
27+
28+
% Set motor values again to make robot move forward
29+
30+
mlrobotsetmotorvoltage(myRobot,'left',-3);
31+
mlrobotsetmotorvoltage(myRobot,'right',3);
32+
33+
% Wait until the robot reaches its original position
34+
35+
pause(5);
36+
37+
% Set both motors to zero voltage
38+
% HINT: use "mlrobotsetmotorvoltage"
39+
40+
mlrobotsetmotorvoltage(myRobot,'left',0);
41+
mlrobotsetmotorvoltage(myRobot,'right',0);
42+
43+
% Stop simulation
44+
mlrobotstop(myRobot);
Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
% Create virtual robot
2-
myRobot=mlrobot;
3-
4-
% Start running the virtual environment simulation
5-
mlrobotstart(myRobot);
6-
7-
% Set both motors to a value that will make the robot move forward
8-
% NOTE: The direction of one motor is inverted use a negative value if
9-
% necessary
10-
% HINT: use "mlrobotsetmotorvoltage"
11-
12-
mlrobotsetmotorvoltage(myRobot,'left',-3);
13-
mlrobotsetmotorvoltage(myRobot,'right',3);
14-
15-
% delay for 5 seconds so the robot moves forward
16-
pause(5);
17-
18-
% Set motors to opposing values to make the robot turn
19-
20-
% mlrobotsetmotorvoltage(myRobot,'left',);
21-
% mlrobotsetmotorvoltage(myRobot,'right',);
22-
23-
% Wait for a period of time until the robot is facing in the opporite
24-
% direction
25-
26-
% pause();
27-
28-
% Set motor values again to make robot move forward
29-
30-
% mlrobotsetmotorvoltage(myRobot,'left',);
31-
% mlrobotsetmotorvoltage(myRobot,'right',);
32-
33-
% Wait until the robot reaches its original position
34-
35-
% pause();
36-
37-
% Set both motors to zero voltage
38-
% HINT: use "mlrobotsetmotorvoltage"
39-
40-
mlrobotsetmotorvoltage(myRobot,'left',0);
41-
mlrobotsetmotorvoltage(myRobot,'right',0);
42-
43-
% Stop simulation
44-
mlrobotstop(myRobot);
1+
% Create virtual robot
2+
myRobot=mlrobot;
3+
4+
% Start running the virtual environment simulation
5+
mlrobotstart(myRobot);
6+
7+
% Set both motors to a value that will make the robot move forward
8+
% NOTE: The direction of one motor is inverted use a negative value if
9+
% necessary
10+
% HINT: use "mlrobotsetmotorvoltage"
11+
12+
mlrobotsetmotorvoltage(myRobot,'left',-3);
13+
mlrobotsetmotorvoltage(myRobot,'right',3);
14+
15+
% delay for 5 seconds so the robot moves forward
16+
pause(5);
17+
18+
% Set motors to opposing values to make the robot turn
19+
20+
% mlrobotsetmotorvoltage(myRobot,'left',);
21+
% mlrobotsetmotorvoltage(myRobot,'right',);
22+
23+
% Wait for a period of time until the robot is facing in the opporite
24+
% direction
25+
26+
% pause();
27+
28+
% Set motor values again to make robot move forward
29+
30+
% mlrobotsetmotorvoltage(myRobot,'left',);
31+
% mlrobotsetmotorvoltage(myRobot,'right',);
32+
33+
% Wait until the robot reaches its original position
34+
35+
% pause();
36+
37+
% Set both motors to zero voltage
38+
% HINT: use "mlrobotsetmotorvoltage"
39+
40+
mlrobotsetmotorvoltage(myRobot,'left',0);
41+
mlrobotsetmotorvoltage(myRobot,'right',0);
42+
43+
% Stop simulation
44+
mlrobotstop(myRobot);
Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
% Create virtual robot
2-
myRobot=mlrobot;
3-
4-
% Start running the virtual environment simulation
5-
mlrobotstart(myRobot);
6-
7-
% Set both motors to a value that will make the robot move forward
8-
% NOTE: The direction of one motor is inverted use a negative value if
9-
% necessary
10-
% HINT: use "mlrobotsetmotorvoltage"
11-
12-
mlrobotsetmotorvoltage(myRobot,'left',-3);
13-
mlrobotsetmotorvoltage(myRobot,'right',3);
14-
15-
% delay for 5 seconds so the robot moves forward
16-
pause(5);
17-
18-
% Set motors to opposing values to make the robot turn
19-
20-
% Wait for a period of time until the robot is facing in the opporite
21-
% direction
22-
23-
% Set both motors to zero voltage
24-
% HINT: use "mlrobotsetmotorvoltage"
25-
26-
mlrobotsetmotorvoltage(myRobot,'left',0);
27-
mlrobotsetmotorvoltage(myRobot,'right',0);
28-
29-
% Stop simulation
30-
mlrobotstop(myRobot);
1+
% Create virtual robot
2+
myRobot=mlrobot;
3+
4+
% Start running the virtual environment simulation
5+
mlrobotstart(myRobot);
6+
7+
% Set both motors to a value that will make the robot move forward
8+
% NOTE: The direction of one motor is inverted use a negative value if
9+
% necessary
10+
% HINT: use "mlrobotsetmotorvoltage"
11+
12+
mlrobotsetmotorvoltage(myRobot,'left',-3);
13+
mlrobotsetmotorvoltage(myRobot,'right',3);
14+
15+
% delay for 5 seconds so the robot moves forward
16+
pause(5);
17+
18+
% Set motors to opposing values to make the robot turn
19+
20+
% Wait for a period of time until the robot is facing in the opporite
21+
% direction
22+
23+
% Set both motors to zero voltage
24+
% HINT: use "mlrobotsetmotorvoltage"
25+
26+
mlrobotsetmotorvoltage(myRobot,'left',0);
27+
mlrobotsetmotorvoltage(myRobot,'right',0);
28+
29+
% Stop simulation
30+
mlrobotstop(myRobot);
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
% Create virtual robot
2-
myRobot=mlrobot;
3-
4-
% Start running the virtual environment simulation
5-
mlrobotstart(myRobot);
6-
7-
% Set both motors to a value that will make the robot move forward
8-
% NOTE: The direction of one motor is inverted use a negative value if
9-
% necessary
10-
% HINT: use "mlrobotsetmotorvoltage"
11-
12-
13-
14-
% delay for 5 seconds so the robot moves forward
15-
pause(5);
16-
17-
% Set both motors to zero voltage
18-
% HINT: use "mlrobotsetmotorvoltage"
19-
20-
21-
22-
% Stop simulation
23-
mlrobotstop(myRobot);
1+
% Create virtual robot
2+
myRobot=mlrobot;
3+
4+
% Start running the virtual environment simulation
5+
mlrobotstart(myRobot);
6+
7+
% Set both motors to a value that will make the robot move forward
8+
% NOTE: The direction of one motor is inverted use a negative value if
9+
% necessary
10+
% HINT: use "mlrobotsetmotorvoltage"
11+
12+
13+
14+
% delay for 5 seconds so the robot moves forward
15+
pause(5);
16+
17+
% Set both motors to zero voltage
18+
% HINT: use "mlrobotsetmotorvoltage"
19+
20+
21+
22+
% Stop simulation
23+
mlrobotstop(myRobot);
Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
% Create virtual robot
2-
myRobot=mlrobot;
3-
4-
% Start running the virtual environment simulation
5-
mlrobotstart(myRobot);
6-
7-
% Fill in the for loop in order to read the robot's angle
8-
9-
for i=1:30
10-
mlrobotsetmotorvoltage(myRobot,'left',5);
11-
mlrobotsetmotorvoltage(myRobot,'right',5);
12-
13-
% Assign the output of a "mlrobotreadcompassangle" to a variable
14-
% named "angle"
15-
16-
angle(i)=mlrobotreadcompassangle(myRobot);
17-
18-
% Wait for 0.1 seconds before reading the next robot angle
19-
pause(0.1);
20-
end
21-
22-
% Stop simulation
23-
mlrobotstop(myRobot);
24-
25-
% Create a time array to plot against
26-
time=0.1:0.1:3;
27-
28-
% Use the "plot" command to plot the robot angle vs time
29-
plot(time,angle)
30-
31-
title('Robot Orientation vs Time');
32-
xlabel('Time (s)')
1+
% Create virtual robot
2+
myRobot=mlrobot;
3+
4+
% Start running the virtual environment simulation
5+
mlrobotstart(myRobot);
6+
7+
% Fill in the for loop in order to read the robot's angle
8+
9+
for i=1:30
10+
mlrobotsetmotorvoltage(myRobot,'left',5);
11+
mlrobotsetmotorvoltage(myRobot,'right',5);
12+
13+
% Assign the output of a "mlrobotreadcompassangle" to a variable
14+
% named "angle"
15+
16+
angle(i)=mlrobotreadcompassangle(myRobot);
17+
18+
% Wait for 0.1 seconds before reading the next robot angle
19+
pause(0.1);
20+
end
21+
22+
% Stop simulation
23+
mlrobotstop(myRobot);
24+
25+
% Create a time array to plot against
26+
time=0.1:0.1:3;
27+
28+
% Use the "plot" command to plot the robot angle vs time
29+
plot(time,angle)
30+
31+
title('Robot Orientation vs Time');
32+
xlabel('Time (s)')
3333
ylabel('Robot Orientation (Degrees)')

0 commit comments

Comments
 (0)