JavaOne presentation - building steps :: Number42 is alive

37
Number 42 is alive instructions by Miro Kopecky Nikhil Nanivadekar special thanks to Nikos Choustoulakis for his help with Robo4j-Joystick development parts; 1. Assemble part 2. Develop and Deploy demo1 and demo2 3. Run Robo4j-Joystick and play 4. Robo4j-Brick client services

Transcript of JavaOne presentation - building steps :: Number42 is alive

Page 1: JavaOne presentation - building steps :: Number42 is alive

Number 42 is aliveinstructions

byMiro Kopecky

Nikhil Nanivadekar special thanks to Nikos Choustoulakis for his help with Robo4j-Joystick development

parts; 1. Assemble part 2. Develop and Deploy demo1 and demo23. Run Robo4j-Joystick and play4. Robo4j-Brick client services

Page 2: JavaOne presentation - building steps :: Number42 is alive

5.

Page 3: JavaOne presentation - building steps :: Number42 is alive
Page 4: JavaOne presentation - building steps :: Number42 is alive
Page 5: JavaOne presentation - building steps :: Number42 is alive
Page 6: JavaOne presentation - building steps :: Number42 is alive

LegoBrick platform details

Page 7: JavaOne presentation - building steps :: Number42 is alive
Page 8: JavaOne presentation - building steps :: Number42 is alive
Page 9: JavaOne presentation - building steps :: Number42 is alive
Page 10: JavaOne presentation - building steps :: Number42 is alive
Page 11: JavaOne presentation - building steps :: Number42 is alive
Page 12: JavaOne presentation - building steps :: Number42 is alive
Page 13: JavaOne presentation - building steps :: Number42 is alive
Page 14: JavaOne presentation - building steps :: Number42 is alive
Page 15: JavaOne presentation - building steps :: Number42 is alive
Page 16: JavaOne presentation - building steps :: Number42 is alive
Page 17: JavaOne presentation - building steps :: Number42 is alive
Page 18: JavaOne presentation - building steps :: Number42 is alive
Page 19: JavaOne presentation - building steps :: Number42 is alive
Page 20: JavaOne presentation - building steps :: Number42 is alive
Page 21: JavaOne presentation - building steps :: Number42 is alive
Page 22: JavaOne presentation - building steps :: Number42 is alive
Page 23: JavaOne presentation - building steps :: Number42 is alive
Page 24: JavaOne presentation - building steps :: Number42 is alive
Page 25: JavaOne presentation - building steps :: Number42 is alive
Page 26: JavaOne presentation - building steps :: Number42 is alive
Page 27: JavaOne presentation - building steps :: Number42 is alive
Page 28: JavaOne presentation - building steps :: Number42 is alive
Page 29: JavaOne presentation - building steps :: Number42 is alive
Page 30: JavaOne presentation - building steps :: Number42 is alive
Page 31: JavaOne presentation - building steps :: Number42 is alive
Page 32: JavaOne presentation - building steps :: Number42 is alive

Develop and Deploy demo1 and demo2: - Downloading template:Download of the zip file and unzip to the desired folder: https://goo.gl/WG7DrBThe download should begin automatically, if it does not then go to the link and download it manually: https://github.com/mirage22/robo4j-javaone-hand-one

- After downloading In the project folder i.e. the folder where you extracted the zip file from above “src/main/java/com/javaone/number42/“ open file Number42Robot.java

- link with our favourite IDE We need to link Robo4j library “robo4j-brick-alfa-0.2.jar” with opened project. Library is in the project folder “libs/”

- COMPILE and UPLOAD Number42 a) CompileOpen command line / command prompt and run Robo4j-Center: $java -jar robo4j-center-alfa-0.2.jar compileProject will compile into the same folder into the file Robo4jNumber42.jar

b) Upload Open command line / command prompt and go to Project directory and run Robo4j-Center

$java -jar robo4j-center-alfa-0.2.jar upload <host> <user> <password> <path>example:$java -jar robo4j-center-alfa-0.2.jar upload 10.0.1.1 root password /home/root/lejos/samples

Demo 1: Activate LCD and Front-Hand active of the robot Number42Open Project file Number42Robot.java and write following code to initiate front-hand and sensor

CODE: public static void main(String[] args) { RobotNumber42 robot = new RobotNumber42(); RobotTouchSensor robotHandTouchSensor = new RobotTouchSensor("S4"); RobotMotor robotHandMotor = new RobotMotor("A");

robot.setHandMotor(robotHandMotor); robot.setHandSensor(robotHandTouchSensor); robot.setHandRelation(new RobotHandRelation(robotHandTouchSensor,robotHandMotor));

robot.setLCD(new RobotLCD(“HandONE”)); robot.setPAD(new RobotPAD()); robot.build(); if(robot.check()){ robot.activate(); } }

Page 33: JavaOne presentation - building steps :: Number42 is alive

SEE SECTION Compile and Upload Number42:CONTROL Demo: - by pressing touch sensor you can control robot hand- To exit demo press EXIT button on the BRICK

Demo 2: Make Number42 alive - activate the platformOpen Project file Number42Robot.java and write following code to initiate front-hand and sensor

CODE:public static void main(String[] args) { RobotNumber42 robot = new RobotNumber42(); RobotTouchSensor robotHandTouchSensor = new RobotTouchSensor("S4"); RobotMotor robotHandMotor = new RobotMotor("A"); RobotMotor robotLeftMotor = new RobotMotor("B"); RobotMotor robotRightMotor = new RobotMotor("C");

robot.setHandMotor(robotHandMotor); robot.setHandSensor(robotHandTouchSensor); robot.setHandRelation(new RobotHandRelation(robotHandTouchSensor,robotHandMotor)); robot.setMotorLeft(robotLeftMotor); robot.setMotorRight(robotRightMotor); robot.setPlatformRelation(new RobotPlatformRelation(robotLeftMotor, robotRightMotor));

robot.setLCD(new RobotLCD(“Number42 FULL")); robot.setPAD(new RobotPAD()); robot.build(); if(robot.check()){ robot.activate(); } }

SEE SECTION Compile and Upload Number42:CONTROL Demo: 1. Similar behaviour like Demo1 2. By using Brick PAD you can move robot forward/backward, left/right 3. To exit demo press EXIT button on the BRICK

Page 34: JavaOne presentation - building steps :: Number42 is alive

Run Robo4j-joystick and playinstructions:a) Go to project ROOT directoryb) Write command: $java -jar robo4j-joystick-alfa-0.2.jarc) Robo4j-joystick will be open for you

Robo4j-Joystick control steps:1) Connect Joystick with Robot Number42

setup robot IP address and press connect

Page 35: JavaOne presentation - building steps :: Number42 is alive

2) move BLACK point in any direction

Every segment of the joystick represents speed of the robot. The segment speed can be changed but there is a secure mechanism. This secure mechanism does not allow to set extremely high speed values. In such case the value will be change back to the default.

Exceptions:1) Trying to connect to the wrong IP

Page 36: JavaOne presentation - building steps :: Number42 is alive

Robo4j Brick Client services: Lego Brick Client is program running on the lego brick. Lego brick default IP address 10.0.1.1Lego brick client default port: 8025

available services HTTP GET: 1. http://10.0.1.1:8025/setup 2. http://10.0.1.1:8025/status3. http://10.0.1.1:8025/exit

1. service setup

provides information how sensors and engines are connected to the brick

2. service status provides information about the command that has been processed but the Robot.

Page 37: JavaOne presentation - building steps :: Number42 is alive

3. servie exit service exit turn off all running services (agents) on the Lego Brick and it ends the running program

available services HTTP POST: Robo4j Brick client also provides POST service. The POST service allows to send batch of command in JSON format