際際滷

際際滷Share a Scribd company logo
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
5.
LegoBrick platform details
JavaOne presentation - building steps :: Number42 is alive
Develop and Deploy demo1 and demo2:
- Downloading template:
Download of the zip 鍖le and unzip to the desired folder: https://goo.gl/WG7DrB

The 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 鍖le from above src/main/
java/com/javaone/number42/ open 鍖le 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) Compile
Open command line / command prompt and run Robo4j-Center:
$java -jar robo4j-center-alfa-0.2.jar compile
Project will compile into the same folder into the 鍖le 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 Number42
Open Project 鍖le 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();
}
}
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 platform
Open Project 鍖le 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
Run Robo4j-joystick and play
instructions:
a) Go to project ROOT directory
b) Write command: $java -jar robo4j-joystick-alfa-0.2.jar
c) Robo4j-joystick will be open for you
Robo4j-Joystick control steps:
1) Connect Joystick with Robot Number42
setup robot IP address and press connect
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
Robo4j Brick Client services:
Lego Brick Client is program running on the lego brick.
Lego brick default IP address 10.0.1.1
Lego brick client default port: 8025
available services HTTP GET:
1. http://10.0.1.1:8025/setup
2. http://10.0.1.1:8025/status
3. 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.
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

More Related Content

JavaOne presentation - building steps :: Number42 is alive

  • 1. 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
  • 2. 5.
  • 3.
  • 4.
  • 5.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32. Develop and Deploy demo1 and demo2: - Downloading template: Download of the zip 鍖le and unzip to the desired folder: https://goo.gl/WG7DrB The 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 鍖le from above src/main/ java/com/javaone/number42/ open 鍖le 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) Compile Open command line / command prompt and run Robo4j-Center: $java -jar robo4j-center-alfa-0.2.jar compile Project will compile into the same folder into the 鍖le 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 Number42 Open Project 鍖le 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(); } }
  • 33. 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 platform Open Project 鍖le 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
  • 34. Run Robo4j-joystick and play instructions: a) Go to project ROOT directory b) Write command: $java -jar robo4j-joystick-alfa-0.2.jar c) Robo4j-joystick will be open for you Robo4j-Joystick control steps: 1) Connect Joystick with Robot Number42 setup robot IP address and press connect
  • 35. 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
  • 36. Robo4j Brick Client services: Lego Brick Client is program running on the lego brick. Lego brick default IP address 10.0.1.1 Lego brick client default port: 8025 available services HTTP GET: 1. http://10.0.1.1:8025/setup 2. http://10.0.1.1:8025/status 3. 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.
  • 37. 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