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

Lab 3 Group 3 Report

The document is a lab report for CECS1010 focused on robot programming, where students learn to initialize and control robot components. It includes code for various tasks such as moving the robot, opening and closing a claw, and detecting objects using sensors. The report emphasizes individual submission and outlines specific learning outcomes related to robot structure and functionality.

Uploaded by

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

Lab 3 Group 3 Report

The document is a lab report for CECS1010 focused on robot programming, where students learn to initialize and control robot components. It includes code for various tasks such as moving the robot, opening and closing a claw, and detecting objects using sensors. The report emphasizes individual submission and outlines specific learning outcomes related to robot structure and functionality.

Uploaded by

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

COLLEGE OF ENGINEERING AND COMPUTER SCIENCE

Introduction to Engineering and Computer


Science
(CECS1010)

Lab 3 report: Robot programming


The student submits his/her own report; this is not a group report
Name:
Group:
Task:
Outcomes:
After this lab, the student will be able to:
 familiarize with Robot structure
 know how to initialize robot components
 know how to control parts to perform a function
Code report:
from vex import (

Brain, Motor, Ports, Colorsensor, Sonar, Bumper, ColorHue, BrakeType,


DEGREES, FORWARD, PERCENT, SECONDS, REVERSE
)
import sys
import vex
# INITIALIZATION OF ROBO PARTST
# ==========================

# brain initialization
brain = Brain()

#motors initialization

right_motor = Motor(Ports.PORT12)
left_motor = Motor(Ports.PORT11)
#sensors initialization
claw_motor = Motor(Ports.PORT7)
sonar_sensor = Sonar(Ports.PORT1)
color_sensor = Colorsensor(Ports.PORT8, False)

#task 1
# def sonar_claw():

#task 2
# def color_arm():

#task 3
def move_forward(duration):
left_motor.spin(FORWARD, 80, PERCENT)
right_motor.spin(REVERSE, 80, PERCENT)
vex.wait(duration)
left_motor.stop()
right_motor.stop()

def turn_90deg(duration):
left_motor.spin(REVERSE, 80, PERCENT)
right_motor.spin(REVERSE, 80, PERCENT)
vex.wait(duration)
left_motor.stop()
right_motor.stop()

def claw_open():
claw_motor.spin_to(-120)

def claw_close():
claw_motor.spin_to(0)

#Task 1: move in rectangle


def move_in_rectangle():
for i in range(4):
move_forward(4)
turn_90deg(0.6)
# Task 2: move forward and grasp the bottle
def open_claw():
move_forward(1)
claw_motor.spin_to(-120)
vex.wait(1)
def get_bottle():
while True:
left_motor.spin(FORWARD, 80, PERCENT)
right_motor.spin(REVERSE, 80, PERCENT)
claw_motor.spin_to(-120)
distance = sonar_sensor.distance()
if distance <= 51 :
print("Hoola")
vex.wait(0.5)
claw_close()
break

# Task 3: get the bottle and stop when detects red colors
def stop_robot():
get_bottle()
while True:
color_sensor.led(True)
left_motor.spin(FORWARD, 50, PERCENT)
right_motor.spin(REVERSE, 50, PERCENT)
color = color_sensor.colorname12()
print(color)
if color == 1 or color == 2 or color == 12 or color == 3:
left_motor.stop()
right_motor.stop()
claw_motor.spin_to(-120)
break
stop_robot()

You might also like