CPE313 Week2
CPE313 Week2
Robotics Technology
Dr. Mohannad Farag
2021-2022, Semester I
Lesson overview
You will learn how to use VR code to make the VR Robot utilize the Drivetrain commands in order to move around the
Castle Crasher Playground.
Learning objectives
1. Identify how to use the [Drive for] command to drive the VR Robot a specific distance.
2. Identify how to use the [Set drive velocity] command to set the speed of the
drivetrain.
3. Identify how to use the [Turn for] command to turn the VR Robot right or left.
4. Identify how to use the [Turn to heading] and [Drive to rotation] command to turn the
VR Robot to a given heading/ rotation.
5. Identify the relation between the code Planning and robot Behavior.
Keywords
_______________________________________________________________________
https://betterprogramming.pub/python-3-10-is-released-know-whats-new-and-if-it-s-worth-the-switch-19c7a5738f7c
Drivetrain Move Forward/ Reverse
How can the brain sense the wheel’s rotation?
https://www.youtube.com/watch?v=v4BbSzJ-hz4&list=RDCMUCmkP178NasnhR3TWQyyP4Gw&start_radio=1&rv=v4BbSzJ-hz4&t=36
Rotary Encoder
How Rotary Encoder Works
Encoder Circuit connection
Encoder Example code
The direct proportional relationship between the motor and wheels rotations
and the robot linear movement.
For example…
If the motor spins 2 times…
• Then the wheels spin 2 times…
• And the robot travels the circumference of the wheel, 2 times!
These proportional relationships are affected by any slipping or sticking of the
wheels and the surface the robot is driving on.
Slower movements allow the wheels to grip and Faster speeds may cause wheels to slip and come
move forward the entirety of the distance up short of the intended distance
Task 1: Motors Forward/ Reverse Instructions
1. Create a New Text Project
2. Rename it: week2.task1
3. Open Castle Crasher playground
4. Try it!
5. Change the distance to 500 mm
6. Monitor the distance sensor value
7. Try to crash the center castle.
8. Let the robot move back to its
start position.
9. Set the robot speed to 100%.
10. Submit your code to MS teams
Drivetrain Turning
Robot turning approximately 90 degrees to the right
Does velocity affect the margin of error?
Rotational Movement
• Rotational movement occurs when an object follows along a curved path.
• When your robot makes a turn, it is using rotational movement, and torque to make that
turn. Torque is known as a twisting force that causes rotations.
Inertial Sensor
c = π * d.
Video Link