robotics nxt-g: variables, file rotation sensor lab: use buttons to hit specific ball. homework:...

18
Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room

Upload: may-johnston

Post on 17-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room

RoboticsNXT-G: variables, file

Rotation sensorLab: Use buttons to hit specific ball.Homework: Postings. Start planning

mapping the room

Page 2: Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room

Variable

• Store value under a name and then re-use• NXT-G

– Need to set up variable: name and data type• Logic (true or false)• Number• Text

– Then can read or write– Use as input to data link– Use as input to calculation

• Demonstrate

Page 3: Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room
Page 4: Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room

Button test

• Use variable to hold which NXT button was pressed.

• Use Edit/Define Variables– Need to give name (give meaningful name)– Need to specify datatype (number, text, logic)

Page 5: Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room

Warnings

• If the task is to determine left or right button, you can’t wait for one button.

• Instead, loop checking first one then the other button. Set variable (or use data wires and an OR operation) to exit the loop.

• Probably need to insert pause(s).

Page 6: Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room
Page 7: Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room

How to check?

• Use display screen– Text– Specify text– NEED TO INSERT PAUSE SO I CAN SEE IT!

Page 8: Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room
Page 9: Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room

Lab assignment

• Do basic ball hitting exercise– Hit only red ball and only blue ball.

• Enhance hitting ball exercise – Use buttons to indicate which ball is to be hit– Use variable– NOTE: you probably can do this just with data

wires, but do it with a variable• Why?

Page 10: Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room

File

• Set of values• Can be re-used by program or uploaded to

computer• NXT-G

– Delete (might do this initially to make sure there isn’t old file by the same name)

– Write (actually append to end)– Close (need to do this before reading)– Read

• Demonstrate

Page 11: Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room

First part: records light readings

Page 12: Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room

Second part: write out file

Page 13: Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room

…and you can upload file: Other under Memory

Page 14: Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room

Rotation sensor

• Connect to particular motor.

• Reset to zero.

• Can measure in rotations or degrees.

Page 15: Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room
Page 16: Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room

Mapping

• Now have tools to record how far robot has moved– Rotation sensor: how many degrees a particular

motor has turned

– Variables and files to store data

• Need a plan/strategy to 'map room'– Determine position of walls

– Note: you know how to move until bump or move until ultrasonic indicates under a set amount.

Page 17: Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room

Challenges

• Robot to store (for later use) where it found walls (or something else) – Use rotation sensor to determine distance traveled

(will need to calibrate in terms of power)– Create file– Upload file

• LATER: Robot to send information to second robot using Bluetooth.

Page 18: Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room

Lab/Homework• Use ultrasound than light to hit the red

ball. Change to hit the blue ball

• Use display, pause, buttons to specify which ball to hit.

• Start planning room mapping task.

• Postings