LEGO NXT Robot Programming Introduction to Programming a Lego NXT robot in Java.

Slides:



Advertisements
Similar presentations
Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.
Advertisements

Introduction to Macromedia Director 8.5 – Lingo
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Getting started with LEGO NXT Mindstorms software This is intended to be a short introduction to the LEGO Mindstorms software and programming the LEGO.
Creating a Dialog-Based Comet Windows Program Brian Levantine.
GMCS Technology & Media Services Presented by: Leni Rivera
Using VB with MS Applications R. Juhl, Delta College.
EducateNXT Enter the name “Sound Graphing” for your experiment. Real-time Data Logging Click the Switch to NXT Data Logging icon in the top-left corner.
© Paradigm Publishing, Inc Excel 2013 Level 2 Unit 2Managing and Integrating Data and the Excel Environment Chapter 7Automating Repetitive Tasks.
Graphical RobotC NXT (EV3) Robot Workshop 2015 Instructor: Dr. Fred Brauchler Assistant: Chris Parker 2/7/2015Lawrence Technological University1.
Using Eclipse. Getting Started There are three ways to create a Java project: 1:Select File > New > Project, 2 Select the arrow of the button in the upper.
CS 178: Programming with Multimedia Objects Aditya P. Mathur Professor of Computer Sciences Purdue University, West Lafayette Sept 9, 2004 Last update:
Building robots Spring Mindstorms Programming Java + leJOS, NQC, and others.
Macros Tutorial Week 20. Objectives By the end of this tutorial you should understand how to: Create macros Assign macros to events Associate macros with.
CS 2511 Fall  Windows:  Start->Specialized Academic Software- >Programming Languages->NetBeans->NetBeans IDE x.y.z  where x.y.z is a version.
LEGO NXT Robot Programming
CSCI Spring '07© 2007 JW Ryder1 Week 2 Material  Install and Configure  Mindstorms NXT Software and User Guide  LeJOS NXJ Alpha  Java.
EducateNXT NXT... an introduction The Kit and the Software.
Introduction to NXT Software and Functionality Bot’oberfest October 15, 2007.
The NXT is the brain of a MINDSTORMS® robot. It’s an intelligent, computer-controlled LEGO® brick that lets a MINDSTORMS robot come alive and perform.
LEGO Mindstorms NXT Programming We will be using the Common Palette for our Robots This is how you download your program onto the brick Drag and drop a.
Access Tutorial 10 Automating Tasks with Macros
01-Intro-Object-Oriented-Prog-Alice1 Barb Ericson Georgia Institute of Technology Aug 2009 Introduction to Object-Oriented Programming in Alice.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Java for Robots How to program an NXT robot with a Java Brain Bert G. Wachsmuth Seton Hall University.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Coding for the FIRST Tech Challenge: RobotC Presented by: Audrey Yeoh Acknowledgements: Team Unlimited FTC 0001.
Coding for the FIRST Tech Challenge: RobotC
IT 211 Project Integration and Deployment Lab #11.
Arc: AddIns Dr Andy Evans. Java Direct access to ArcObjects Framework inside and outside Arc. Ability to add components to the GUI. Ability to communicate.
1 Design and Discovery Robotics Wednesday May 10th 2006 Education Centre Drumcondra Design and Discovery Robotics Wednesday May 10th 2006 Education Centre.
LiveCycle Data Services Introduction Part 2. Part 2? This is the second in our series on LiveCycle Data Services. If you missed our first presentation,
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
MS Outlook ® Version 2007 Created by: Patricia Cerio Software Training Specialist Mohawk Regional Information Center “Transitioning.
How to Run a Java Program CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Copyright © Curt Hill Turtles The beginning of media computation.
Chapter Two Creating a First Project in Visual Basic.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Negative Power or Negative Rotation makes robot go backwards. But if both are negative, the robot will go forward! Move Steering Block.
Event Driven Programming Minus the GUI Plus a Robot By Charlie Vick.
CSE 1341 Honors Professor Mark Fontenot Southern Methodist University Note Set 11.
Lego MindStorm An Introduction to Blocks. Blocks Blocks are used to give instructions to your robot. There are many types of blocks You can use the blocks.
Topics Introduction Scene Graphs
Castor Bot. Now, we will begin creating a robot Log onto your computer On your screen, click on the website labeled “castor bot” Your building instructions.
Class Builder Tutorial Presented By- Amit Singh & Sylendra Prasad.
All sections to appear here Welcome to my pptPlex Slide Show, this can be executed in either two ways: 1.As a normal PowerPoint slide show: Example hit.
JDS5 Training Guide. On Start Up you will see this screen click the OK button Click OK.
Programming - Motion Intro to Robotics. Motors and Sensors Setup The first thing we need to do is tell ROBOTC that we have motors on our robot. Choose.
Using the BlueJ IDE with Mindstorms LMICSE Workshop June , 2005 Alma College.
PowerPoint Basics Tutorial 2: A Slide Show In this tutorial you’re going to create a presentation from scratch. You will have to keep this presentation.
Creating Web Pages with Links, Images, and Embedded Style Sheets
Vex Robotics program three: using motors and sensors together.
ROBOTICS Jason Bell Brad Carlson
Chapter 7 Multiple Forms, Modules, and Menus. Section 7.2 MODULES A module contains code—declarations and procedures—that are used by other files in a.
Getting started with the Arxterra software and 3DoT Firmware
Exploring Computer Science Lesson 6-5
BEGINNER PROGRAMMING LESSON
Java on the LEGO Mindstorms EV3
Introduction To Programming with LEGO NXT 2
Using Procedures and Exception Handling
Introduction to Events
Basics for Robotics Programming
How to Run a Java Program
Exploring Computer Science Lesson 6-5
Simple Windows Applications
Constructors, GUI’s(Using Swing) and ActionListner
LEGO Mindstorms Robot and Java
The beginning of media computation Followed by a demo
LEGO MINDSTORMS NXT PROGRAMMING
Presentation transcript:

LEGO NXT Robot Programming Introduction to Programming a Lego NXT robot in Java

Objectives Software requirements Java Libraries Creating a Java forms application Running Java applications Creating objects and initialisation Robot navigation Using a timer The touch sensor Displaying a message box Pausing the program to enable the robot to respond The ultrasonic sensor

Software Required NetBeans Java development software – SE version is sufficient LeJOS Java robot API – PC installer – Download special firmware to the robot – Programs can run on the PC (controlling the robot) – Programs can be downloaded and run on the robot

NetBeans

Libraries required Copy libraries to folder within project: – C:\Program Files\leJOS NXJ\lib\pccomm.jar – C:\Program Files\leJOS NXJ\lib\pctools.jar – C:\Program Files\leJOS NXJ\3rdparty\lib\bluecove.jar Link to project within NetBeans – Right click project – Select Libraries category – Add Jar/Folder button

Forms Development Select controls from palette Set properties Rename variable (right click control) Attach an event handler – Double click control – Select “Create new action” – Choose a name for your event-handler – Code will be created for the method

Running a NetBeans App To run from within NetBeans – Make sure the required project is the currently highlighted one Right click project and select “Set as Main project” – Use the Green arrow on the toolbar – Or right click the project name and select “Run” – Interrupt if necessary using Run/Stop build/run from the menu To run from outside NetBeans – Use the hammer icon on the toolbar or right click project and select “Build” – This will create an executable JAR in the dist folder of the project – Double click the JAR file to run

Java Coding (General) Import external Java classes (similar to Using statements in C#) import lejos.nxt.*; import lejos.robotics.navigation.*; Instance variables – Placed at the bottom of form code: private TachoPilot pilot; DO NOT Modify auto-generated code

Initialisation and creating objects This will normally be done in the constructor The constructor already contains a lot of auto- generated code Add your code at the end Suggestion: – Write your own initialisation method – Call this from the bottom of the constructor – This means only one line needs to be added to the constructor and keeps your code separate

Auto-generated code Custom initialization method Call custom initialisation

Robot Navigation import lejos.robotics.navigation.*; Create pilot object (in initialisation method) private TachoPilot pilot; pilot = new TachoPilot(2.1f, 4.4f, Motor.A, Motor.C, true); Set speed of motion pilot.setMoveSpeed(3); pilot.setTurnSpeed(20); Move and rotate pilot.travel(-12); pilot.rotate(90); 11 The Tribot has the motors on backwards so needs negative number for distance

More Navigation Methods Methods exist to move the robot continuously: pilot.backward(); pilot.forward(); pilot.stop(); Remember if your robot has the motors on backwards then backwards will move forwards etc! It is also possible to obtain the maximum available speeds: float fMaxMoveSpeed = pilot.getMoveMaxSpeed(); float fMaxTurnSpeed = pilot.getTurnMaxSpeed();

Creating a Timer Create an instance variable private Timer touchTimer; Create a timer object, which includes the interval and an “action listener” method which is called for each timer tick touchTimer = new Timer(50, new ActionListener() { public void actionPerformed(ActionEvent e) { touchTimerTick(); } }); Start or stop the timer touchTimer.start(); touchTimer.stop();

The Touch Sensor Create an instance variable private TouchSensor touchSensor; Create the object and attach to the port touchSensor = new TouchSensor(SensorPort.S1); Check if the sensor is pressed if (touchSensor.isPressed()) …………

Simple Message Box Uses a class from the Java “Swing” library import javax.swing.JOptionPane; A simple message box JOptionPane.showMessageDialog(null, "Message"); A message box with a title and message type JOptionPane.showMessageDialog(null, "Message", "Title", JOptionPane.ERROR_MESSAGE); A variety of other message types are available

Adding a Pause Use the Thread.sleep command but requires exception handling to be added //include a 25ms delay to pick up values try { Thread.sleep(25); } catch(Exception e) { JOptionPane.showMessageDialog(null, "Error in pause"); return; }

The Ultrasonic Sensor Created in the same way as the touch sensor To obtain the value should first “ping” the sensor ultrasonicSensor.ping(); Then pause for at least a 25ms delay (see previous slide) Distance value can then be obtained iDist = ultrasonicSensor.getDistance();