public void execute() { NodeConfiguration nodeConfiguration = RosTools.createNodeConfiguration(masterURI); nodeMainExecutor = DefaultNodeMainExecutor.newDefault(); nodeMainExecutor.execute(this, nodeConfiguration); }
public void execute() { NodeConfiguration nodeConfiguration = RosTools.createNodeConfiguration(masterURI); nodeMainExecutor = DefaultNodeMainExecutor.newDefault(); nodeMainExecutor.execute(this, nodeConfiguration); }
public static void main(String[] args) throws URISyntaxException { String MASTER = "http://localhost:11311"; String TOPIC_NAME = "/camera/image_raw/compressed"; URI master = new URI(MASTER); try { RosCameraBenchmarker externalCamera = new RosCameraBenchmarker(TOPIC_NAME); NodeConfiguration nodeConfiguration = RosTools.createNodeConfiguration(master); NodeMainExecutor nodeMainExecutor = DefaultNodeMainExecutor.newDefault(); nodeMainExecutor.execute(externalCamera, nodeConfiguration); } catch (Exception e) { e.printStackTrace(); } } }
public static void main(String[] args) throws URISyntaxException { String MASTER = "http://localhost:11311"; String TOPIC_NAME = "/camera/image_raw/compressed"; URI master = new URI(MASTER); try { RosCameraBenchmarker externalCamera = new RosCameraBenchmarker(TOPIC_NAME); NodeConfiguration nodeConfiguration = RosTools.createNodeConfiguration(master); NodeMainExecutor nodeMainExecutor = DefaultNodeMainExecutor.newDefault(); nodeMainExecutor.execute(externalCamera, nodeConfiguration); } catch (Exception e) { e.printStackTrace(); } } }
public static void main(String[] args) throws URISyntaxException { String MASTER = "http://localhost:11311"; String TOPIC_NAME = "/camera/image_raw/compressed"; URI master = new URI(MASTER); try { RosCameraBenchmarker externalCamera = new RosCameraBenchmarker(TOPIC_NAME); NodeConfiguration nodeConfiguration = RosTools.createNodeConfiguration(master); NodeMainExecutor nodeMainExecutor = DefaultNodeMainExecutor.newDefault(); nodeMainExecutor.execute(externalCamera, nodeConfiguration); } catch (Exception e) { e.printStackTrace(); } } }
public static void main(String[] args) throws URISyntaxException { try { if (args.length < 3) throw new IllegalArgumentException("Insufficient arguments provided. Please provide IP of MASTER, camera name, and topic name."); else { URI master = new URI(args[0]); ExternalCameraFeed externalCamera; if (args.length == 3) externalCamera = new ExternalCameraFeed(args[1], args[2]); else externalCamera = new ExternalCameraFeed(args[1], args[2], args[3].equals("true")); NodeConfiguration nodeConfiguration = RosTools.createNodeConfiguration(master); NodeMainExecutor nodeMainExecutor = DefaultNodeMainExecutor.newDefault(); nodeMainExecutor.execute(externalCamera, nodeConfiguration); } } catch (Exception e) { e.printStackTrace(); } } }
public ROSiRobotCommandDispatcher(PacketCommunicator ihmcMessageCommunicator, String rosHostIP) { ihmcMessageCommunicator.attachListener(HandDesiredConfigurationMessage.class, handDesiredConfigurationMessageSubscriber); String rosURI = "http://" + rosHostIP + ":11311"; rosHandCommunicator = new ROSiRobotCommunicator(rosURI); try { NodeConfiguration nodeConfiguration = RosTools.createNodeConfiguration(new URI(rosURI)); NodeMainExecutor nodeMainExecutor = DefaultNodeMainExecutor.newDefault(); nodeMainExecutor.execute(rosHandCommunicator, nodeConfiguration); } catch (URISyntaxException e) { e.printStackTrace(); } }
public ROSiRobotCommandDispatcher(PacketCommunicator ihmcMessageCommunicator, String rosHostIP) { ihmcMessageCommunicator.attachListener(HandDesiredConfigurationMessage.class, handDesiredConfigurationMessageSubscriber); String rosURI = "http://" + rosHostIP + ":11311"; rosHandCommunicator = new ROSiRobotCommunicator(rosURI); try { NodeConfiguration nodeConfiguration = RosTools.createNodeConfiguration(new URI(rosURI)); NodeMainExecutor nodeMainExecutor = DefaultNodeMainExecutor.newDefault(); nodeMainExecutor.execute(rosHandCommunicator, nodeConfiguration); } catch (URISyntaxException e) { e.printStackTrace(); } }
public ROSiRobotCommandDispatcher(String robotName, RealtimeRos2Node realtimeRos2Node, String rosHostIP) { ROS2Tools.createCallbackSubscription(realtimeRos2Node, HandDesiredConfigurationMessage.class, ControllerAPIDefinition.getSubscriberTopicNameGenerator(robotName), handDesiredConfigurationMessageSubscriber); String rosURI = "http://" + rosHostIP + ":11311"; rosHandCommunicator = new ROSiRobotCommunicator(rosURI); try { NodeConfiguration nodeConfiguration = RosTools.createNodeConfiguration(new URI(rosURI)); NodeMainExecutor nodeMainExecutor = DefaultNodeMainExecutor.newDefault(); nodeMainExecutor.execute(rosHandCommunicator, nodeConfiguration); } catch (URISyntaxException e) { e.printStackTrace(); } }
@Test public void testAddDisconnectedPublisher() { nodeMainExecutor.execute(new AbstractNodeMain() { @Override public GraphName getDefaultNodeName() { return GraphName.of("subscriber"); } @Override public void onStart(ConnectedNode connectedNode) { DefaultSubscriber<std_msgs.String> subscriber = (DefaultSubscriber<std_msgs.String>) connectedNode.<std_msgs.String>newSubscriber( "foo", std_msgs.String._TYPE); try { subscriber.addPublisher(PublisherIdentifier.newFromStrings("foo", "http://foo", "foo"), new InetSocketAddress(1234)); fail(); } catch (RuntimeException e) { // Connecting to a disconnected publisher should fail. } } }, nodeConfiguration); }
@Before public void setup() throws InterruptedException { final CountDownLatch latch = new CountDownLatch(1); nodeMainExecutor.execute(new AbstractNodeMain() { @Override public GraphName getDefaultNodeName() { return GraphName.of("node_name"); } @Override public void onStart(ConnectedNode connectedNode) { parameters = connectedNode.getParameterTree(); log = connectedNode.getLog(); latch.countDown(); } }, nodeConfiguration); assertTrue(latch.await(1, TimeUnit.SECONDS)); }
@Before public void setup() throws InterruptedException { final CountDownLatch latch = new CountDownLatch(1); nodeMainExecutor.execute(new AbstractNodeMain() { @Override public GraphName getDefaultNodeName() { return GraphName.of("node_name"); } @Override public void onStart(ConnectedNode connectedNode) { parameters = connectedNode.getParameterTree(); latch.countDown(); } }, nodeConfiguration); assertTrue(latch.await(1, TimeUnit.SECONDS)); }
public static void main(String[] argv) throws Exception { if (argv.length == 0) { printUsage(); System.exit(1); } CommandLineLoader loader = new CommandLineLoader(Lists.newArrayList(argv)); String nodeClassName = loader.getNodeClassName(); System.out.println("Loading node class: " + loader.getNodeClassName()); NodeConfiguration nodeConfiguration = loader.build(); NodeMain nodeMain = null; try { nodeMain = loader.loadClass(nodeClassName); } catch (ClassNotFoundException e) { throw new RosRuntimeException("Unable to locate node: " + nodeClassName, e); } catch (InstantiationException e) { throw new RosRuntimeException("Unable to instantiate node: " + nodeClassName, e); } catch (IllegalAccessException e) { throw new RosRuntimeException("Unable to instantiate node: " + nodeClassName, e); } Preconditions.checkState(nodeMain != null); NodeMainExecutor nodeMainExecutor = DefaultNodeMainExecutor.newDefault(); nodeMainExecutor.execute(nodeMain, nodeConfiguration); } }
@Test public void testEmptyYaml() throws InterruptedException { List<ParameterLoaderNode.Resource> resourceList = new ArrayList<ParameterLoaderNode.Resource>() {{ add(new ParameterLoaderNode.Resource(getClass().getResourceAsStream("/empty.yaml"), "")); }}; ParameterLoaderNode parameterLoaderNode = new ParameterLoaderNode(resourceList); final CountDownLatch parameterNodeLatch = new CountDownLatch(1); nodeMainExecutor.execute(parameterLoaderNode, nodeConfiguration, new ArrayList<NodeListener>() {{ add(new DefaultNodeListener() { @Override public void onShutdown(Node node) { parameterNodeLatch.countDown(); } }); }}); // No exceptions shall be thrown on node execution, and it should shut down properly. assertTrue(parameterNodeLatch.await(1, TimeUnit.SECONDS)); } }
public RosConnectedZeroPoseRobotConfigurationDataProducer(URI rosMasterURI, PacketCommunicator objectCommunicator, final DRCRobotModel robotModel) { this.robotModel = robotModel; this.packetCommunicator = objectCommunicator; fullRobotModel = robotModel.createFullRobotModel(); referenceFrames = new HumanoidReferenceFrames(fullRobotModel); pelvisFrame = referenceFrames.getPelvisFrame(); headFrame = referenceFrames.getNeckFrame(NeckJointName.PROXIMAL_NECK_PITCH); forceSensorDefinitions = fullRobotModel.getForceSensorDefinitions(); updateRobotLocationBasedOnMultisensePose(new RigidBodyTransform()); if(rosMasterURI != null) { NodeConfiguration nodeConfiguration = RosTools.createNodeConfiguration(rosMasterURI); NodeMainExecutor nodeMainExecutor = DefaultNodeMainExecutor.newDefault(); nodeMainExecutor.execute(this, nodeConfiguration); } }
public RosConnectedZeroPoseRobotConfigurationDataProducer(URI rosMasterURI, PacketCommunicator objectCommunicator, final DRCRobotModel robotModel) { this.robotModel = robotModel; this.packetCommunicator = objectCommunicator; fullRobotModel = robotModel.createFullRobotModel(); referenceFrames = new HumanoidReferenceFrames(fullRobotModel); pelvisFrame = referenceFrames.getPelvisFrame(); headFrame = referenceFrames.getNeckFrame(NeckJointName.PROXIMAL_NECK_PITCH); forceSensorDefinitions = fullRobotModel.getForceSensorDefinitions(); updateRobotLocationBasedOnMultisensePose(new RigidBodyTransform()); if(rosMasterURI != null) { NodeConfiguration nodeConfiguration = RosTools.createNodeConfiguration(rosMasterURI); NodeMainExecutor nodeMainExecutor = DefaultNodeMainExecutor.newDefault(); nodeMainExecutor.execute(this, nodeConfiguration); } }
public RosConnectedZeroPoseRobotConfigurationDataProducer(URI rosMasterURI, PacketCommunicator objectCommunicator, final DRCRobotModel robotModel) { this.robotModel = robotModel; this.packetCommunicator = objectCommunicator; fullRobotModel = robotModel.createFullRobotModel(); referenceFrames = new HumanoidReferenceFrames(fullRobotModel); pelvisFrame = referenceFrames.getPelvisFrame(); headFrame = referenceFrames.getNeckFrame(NeckJointName.PROXIMAL_NECK_PITCH); forceSensorDefinitions = fullRobotModel.getForceSensorDefinitions(); updateRobotLocationBasedOnMultisensePose(new RigidBodyTransform()); if(rosMasterURI != null) { NodeConfiguration nodeConfiguration = RosTools.createNodeConfiguration(rosMasterURI); NodeMainExecutor nodeMainExecutor = DefaultNodeMainExecutor.newDefault(); nodeMainExecutor.execute(this, nodeConfiguration); } }
private void checkNodeAddress(final String host) throws InterruptedException { final Holder<InetSocketAddress> holder = Holder.newEmpty(); NodeConfiguration nodeConfiguration = NodeConfiguration.newPublic(host, rosCore.getUri()); nodeMainExecutor.execute(new AbstractNodeMain() { @Override public GraphName getDefaultNodeName() { return GraphName.of("node"); } @Override public void onStart(ConnectedNode connectedNode) { holder.set(((DefaultNode) connectedNode).getAddress()); } }, nodeConfiguration); assertTrue(holder.await(1, TimeUnit.SECONDS)); assertTrue(holder.get().getPort() > 0); assertEquals(holder.get().getHostName(), host); }
@Test public void testRegisterPublisher() throws InterruptedException { publisherListener = CountDownPublisherListener.newDefault(); nodeMainExecutor.execute(new AbstractNodeMain() { @Override public GraphName getDefaultNodeName() { return GraphName.of("node"); } @Override public void onStart(ConnectedNode connectedNode) { publisher = connectedNode.newPublisher("topic", std_msgs.String._TYPE); publisher.addListener(publisherListener); } }, nodeConfiguration); assertTrue(publisherListener.awaitMasterRegistrationSuccess(1, TimeUnit.SECONDS)); publisher.shutdown(); assertTrue(publisherListener.awaitMasterUnregistrationSuccess(1, TimeUnit.SECONDS)); }
@Test public void testRegisterPublisherRetries() throws InterruptedException, IOException, URISyntaxException { int port = rosCore.getUri().getPort(); publisherListener = CountDownPublisherListener.newDefault(); nodeMainExecutor.execute(new AbstractNodeMain() { @Override public GraphName getDefaultNodeName() { return GraphName.of("node"); } @Override public void onStart(ConnectedNode connectedNode) { rosCore.shutdown(); ((DefaultNode) connectedNode).getRegistrar().setRetryDelay(1, TimeUnit.MILLISECONDS); publisher = connectedNode.newPublisher("topic", std_msgs.String._TYPE); publisher.addListener(publisherListener); } }, nodeConfiguration); assertTrue(publisherListener.awaitMasterRegistrationFailure(1, TimeUnit.SECONDS)); rosCore = RosCore.newPrivate(port); rosCore.start(); assertTrue(rosCore.awaitStart(1, TimeUnit.SECONDS)); assertTrue(publisherListener.awaitMasterRegistrationSuccess(1, TimeUnit.SECONDS)); publisher.shutdown(); assertTrue(publisherListener.awaitMasterUnregistrationSuccess(1, TimeUnit.SECONDS)); } }