robotics nxt-g: variables, file rotation sensor lab: use buttons to hit specific ball. homework:...
TRANSCRIPT
![Page 1: Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room](https://reader035.vdocument.in/reader035/viewer/2022070412/5697bf8a1a28abf838c8ac10/html5/thumbnails/1.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022070412/5697bf8a1a28abf838c8ac10/html5/thumbnails/2.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022070412/5697bf8a1a28abf838c8ac10/html5/thumbnails/3.jpg)
![Page 4: Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room](https://reader035.vdocument.in/reader035/viewer/2022070412/5697bf8a1a28abf838c8ac10/html5/thumbnails/4.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022070412/5697bf8a1a28abf838c8ac10/html5/thumbnails/5.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022070412/5697bf8a1a28abf838c8ac10/html5/thumbnails/6.jpg)
![Page 7: Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room](https://reader035.vdocument.in/reader035/viewer/2022070412/5697bf8a1a28abf838c8ac10/html5/thumbnails/7.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022070412/5697bf8a1a28abf838c8ac10/html5/thumbnails/8.jpg)
![Page 9: Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room](https://reader035.vdocument.in/reader035/viewer/2022070412/5697bf8a1a28abf838c8ac10/html5/thumbnails/9.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022070412/5697bf8a1a28abf838c8ac10/html5/thumbnails/10.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022070412/5697bf8a1a28abf838c8ac10/html5/thumbnails/11.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022070412/5697bf8a1a28abf838c8ac10/html5/thumbnails/12.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022070412/5697bf8a1a28abf838c8ac10/html5/thumbnails/13.jpg)
…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](https://reader035.vdocument.in/reader035/viewer/2022070412/5697bf8a1a28abf838c8ac10/html5/thumbnails/14.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022070412/5697bf8a1a28abf838c8ac10/html5/thumbnails/15.jpg)
![Page 16: Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room](https://reader035.vdocument.in/reader035/viewer/2022070412/5697bf8a1a28abf838c8ac10/html5/thumbnails/16.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022070412/5697bf8a1a28abf838c8ac10/html5/thumbnails/17.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022070412/5697bf8a1a28abf838c8ac10/html5/thumbnails/18.jpg)
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