From ba784c7afb59e2e139d1a24b8aa711ef4eb75218 Mon Sep 17 00:00:00 2001 From: Vladimir Matena Date: Tue, 24 Nov 2015 15:15:38 +0100 Subject: [PATCH] Add extra demo version with ROS networking (implemented by OMNeT++) --- .../RobotLeaderFollowerDemo.java | 7 ++- .../RobotLeaderFollowerDemoFakeNetwork.java | 61 +++++++++++++++++++ 2 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 jdeeco-ros/test/cz/cuni/mff/d3s/jdeeco/ros/leaderfollowerdemo/RobotLeaderFollowerDemoFakeNetwork.java diff --git a/jdeeco-ros/test/cz/cuni/mff/d3s/jdeeco/ros/leaderfollowerdemo/RobotLeaderFollowerDemo.java b/jdeeco-ros/test/cz/cuni/mff/d3s/jdeeco/ros/leaderfollowerdemo/RobotLeaderFollowerDemo.java index 7f041e6b4..f48452097 100644 --- a/jdeeco-ros/test/cz/cuni/mff/d3s/jdeeco/ros/leaderfollowerdemo/RobotLeaderFollowerDemo.java +++ b/jdeeco-ros/test/cz/cuni/mff/d3s/jdeeco/ros/leaderfollowerdemo/RobotLeaderFollowerDemo.java @@ -7,10 +7,10 @@ import cz.cuni.mff.d3s.deeco.runtime.DEECoException; import cz.cuni.mff.d3s.deeco.runtime.DEECoNode; import cz.cuni.mff.d3s.jdeeco.network.Network; -import cz.cuni.mff.d3s.jdeeco.network.device.SimpleBroadcastDevice; import cz.cuni.mff.d3s.jdeeco.network.l2.strategy.KnowledgeInsertingStrategy; import cz.cuni.mff.d3s.jdeeco.position.PositionPlugin; import cz.cuni.mff.d3s.jdeeco.publishing.DefaultKnowledgePublisher; +import cz.cuni.mff.d3s.jdeeco.ros.BeeClick; import cz.cuni.mff.d3s.jdeeco.ros.Positioning; import cz.cuni.mff.d3s.jdeeco.ros.sim.ROSSimulation; @@ -38,7 +38,8 @@ public void testTravel() throws AnnotationProcessorException, InterruptedExcepti realm.addPlugin(Network.class); realm.addPlugin(DefaultKnowledgePublisher.class); realm.addPlugin(KnowledgeInsertingStrategy.class); - realm.addPlugin(new SimpleBroadcastDevice(0, 0, 100000, SimpleBroadcastDevice.DEFAULT_MTU)); + //realm.addPlugin(new SimpleBroadcastDevice(0, 0, 100000, SimpleBroadcastDevice.DEFAULT_MTU)); + realm.addPlugin(BeeClick.class); Positioning robot0Pos = new Positioning(); DEECoNode robot0 = realm.createNode(0, robot0Pos, rosSim.createROSServices("red"), new PositionPlugin(12, 12)); @@ -51,7 +52,7 @@ public void testTravel() throws AnnotationProcessorException, InterruptedExcepti robot1.deployEnsemble(LeaderFollowerEnsemble.class); // Simulate for specified time - realm.start(30_000); + realm.start(3000_000); System.out.println("!#!@!#!@!#@!@#!@#!@#!#!@!#!@!#@!@#!@#!@#!#!@!#!@!#@!@#!@#!@#!#!@!#!@!#@!@#!@#!@#!#!@!#!@!#@!@#!@#!@#!#!@!#!@!#@!@#"); System.out.println("!@!#!@!#@!@#!@#!@# As we cannot make ROS exit nicely we are now going to terminate the whole JVM !@#!@#!@#!@#!@#!@#"); diff --git a/jdeeco-ros/test/cz/cuni/mff/d3s/jdeeco/ros/leaderfollowerdemo/RobotLeaderFollowerDemoFakeNetwork.java b/jdeeco-ros/test/cz/cuni/mff/d3s/jdeeco/ros/leaderfollowerdemo/RobotLeaderFollowerDemoFakeNetwork.java new file mode 100644 index 000000000..7401345f5 --- /dev/null +++ b/jdeeco-ros/test/cz/cuni/mff/d3s/jdeeco/ros/leaderfollowerdemo/RobotLeaderFollowerDemoFakeNetwork.java @@ -0,0 +1,61 @@ +package cz.cuni.mff.d3s.jdeeco.ros.leaderfollowerdemo; + +import java.io.IOException; + +import cz.cuni.mff.d3s.deeco.annotations.processor.AnnotationProcessorException; +import cz.cuni.mff.d3s.deeco.runners.DEECoSimulation; +import cz.cuni.mff.d3s.deeco.runtime.DEECoException; +import cz.cuni.mff.d3s.deeco.runtime.DEECoNode; +import cz.cuni.mff.d3s.jdeeco.network.Network; +import cz.cuni.mff.d3s.jdeeco.network.device.SimpleBroadcastDevice; +import cz.cuni.mff.d3s.jdeeco.network.l2.strategy.KnowledgeInsertingStrategy; +import cz.cuni.mff.d3s.jdeeco.position.PositionPlugin; +import cz.cuni.mff.d3s.jdeeco.publishing.DefaultKnowledgePublisher; +import cz.cuni.mff.d3s.jdeeco.ros.Positioning; +import cz.cuni.mff.d3s.jdeeco.ros.sim.ROSSimulation; + +/** + * Example of vehicles traveling across the map + * + * @author Vladimir Matena + * + */ +public class RobotLeaderFollowerDemoFakeNetwork { + public static void main(String[] args) throws AnnotationProcessorException, InterruptedException, DEECoException, + InstantiationException, IllegalAccessException, IOException { + new RobotLeaderFollowerDemoFakeNetwork().testTravel(); + } + + public void testTravel() throws AnnotationProcessorException, InterruptedException, DEECoException, + InstantiationException, IllegalAccessException, IOException { + + ROSSimulation rosSim = new ROSSimulation("192.168.56.101", 11311, "192.168.56.1", "corridor", 0.02, 100); + + // Create main application container + DEECoSimulation realm = new DEECoSimulation(rosSim.getTimer()); + + // Configure loop-back networking for all nodes + realm.addPlugin(Network.class); + realm.addPlugin(DefaultKnowledgePublisher.class); + realm.addPlugin(KnowledgeInsertingStrategy.class); + realm.addPlugin(new SimpleBroadcastDevice(0, 0, 100000, SimpleBroadcastDevice.DEFAULT_MTU)); + + Positioning robot0Pos = new Positioning(); + DEECoNode robot0 = realm.createNode(0, robot0Pos, rosSim.createROSServices("red"), new PositionPlugin(12, 12)); + robot0.deployComponent(new LeaderRobot("robot_0", robot0Pos, rosSim.getTimer())); + robot0.deployEnsemble(LeaderFollowerEnsemble.class); + + Positioning robot1Pos = new Positioning(); + DEECoNode robot1 = realm.createNode(1, robot1Pos, rosSim.createROSServices("blue"), new PositionPlugin(26, 12)); + robot1.deployComponent(new FollowerRobot("robot_1", robot1Pos, rosSim.getTimer())); + robot1.deployEnsemble(LeaderFollowerEnsemble.class); + + // Simulate for specified time + realm.start(3000_000); + + System.out.println("!#!@!#!@!#@!@#!@#!@#!#!@!#!@!#@!@#!@#!@#!#!@!#!@!#@!@#!@#!@#!#!@!#!@!#@!@#!@#!@#!#!@!#!@!#@!@#!@#!@#!#!@!#!@!#@!@#"); + System.out.println("!@!#!@!#@!@#!@#!@# As we cannot make ROS exit nicely we are now going to terminate the whole JVM !@#!@#!@#!@#!@#!@#"); + System.out.println("!#!@!#!@!#@!@#!@#!@#!#!@!#!@!#@!@#!@#!@#!#!@!#!@!#@!@#!@#!@#!#!@!#!@!#@!@#!@#!@#!#!@!#!@!#@!@#!@#!@#!#!@!#!@!#@!@#"); + System.exit(0); + } +}