public static NodeConfiguration createNodeConfiguration(URI master) { InetAddress listenAddress = getMyIP(master); NodeConfiguration nodeConfiguration = NodeConfiguration.newPublic(listenAddress.getHostAddress(), master); nodeConfiguration.setMasterUri(master); return nodeConfiguration; }
@Override protected void init(NodeMainExecutor nodeMainExecutor) { // talker = new Talker("TALKING"); NodeConfiguration nodeConfiguration = NodeConfiguration.newPublic(InetAddressFactory.newNonLoopback().getHostAddress()); // At this point, the user has already been prompted to either enter the URI // of a master to use or to start a master locally. nodeConfiguration.setMasterUri(getMasterUri()); // nodeMainExecutor.execute(talker, nodeConfiguration); // The RosTextView is also a NodeMain that must be executed in order to // start displaying incoming messages. nodeMainExecutor.execute(rosTextView, nodeConfiguration); }
@Override protected void init(NodeMainExecutor nodeMainExecutor) { // TODO Auto-generated method stub String host = InetAddressFactory.newNonLoopback().getHostName(); NodeConfiguration nodeConfiguration = NodeConfiguration.newPublic(host, getMasterUri()); // Execute the location node sensorNode = new AndroidPhoneSensorNode(); nodeMainExecutor.execute(sensorNode, nodeConfiguration); }
/** * Creates a new {@link NodeConfiguration} for a {@link Node} that is only accessible on the local * host. * * @param masterUri the {@link URI} for the master that the {@link Node} will register with * @return a new {@link NodeConfiguration} for a private {@link Node} */ public static NodeConfiguration newPrivate(URI masterUri) { NodeConfiguration configuration = new NodeConfiguration(); configuration.setXmlRpcBindAddress(BindAddress.newPrivate()); configuration.setXmlRpcAdvertiseAddressFactory(new PrivateAdvertiseAddressFactory()); configuration.setTcpRosBindAddress(BindAddress.newPrivate()); configuration.setTcpRosAdvertiseAddressFactory(new PrivateAdvertiseAddressFactory()); configuration.setMasterUri(masterUri); return configuration; }
/** * Creates a new {@link NodeConfiguration} for a publicly accessible {@link Node}. * * @param host the host that the {@link Node} will run on * @param masterUri the {@link URI} for the master that the {@link Node} will register with * @return a new {@link NodeConfiguration} for a publicly accessible {@link Node} */ public static NodeConfiguration newPublic(String host, URI masterUri) { NodeConfiguration configuration = new NodeConfiguration(); configuration.setXmlRpcBindAddress(BindAddress.newPublic()); configuration.setXmlRpcAdvertiseAddressFactory(new PublicAdvertiseAddressFactory(host)); configuration.setTcpRosBindAddress(BindAddress.newPublic()); configuration.setTcpRosAdvertiseAddressFactory(new PublicAdvertiseAddressFactory(host)); configuration.setMasterUri(masterUri); return configuration; }
public LookatFeedback newFeedbackMessage() { NodeConfiguration nc = NodeConfiguration.newPrivate(); MessageFactory mf = nc.getTopicMessageFactory(); return mf.newFromType(LookatFeedback._TYPE); }
public LookatResult newResultMessage() { NodeConfiguration nc = NodeConfiguration.newPrivate(); MessageFactory mf = nc.getTopicMessageFactory(); return mf.newFromType(LookatResult._TYPE); }
@Override public void run() { try { // Check if the concert exists by looking for concert name parameter // getParam throws when it can't find the parameter. ParameterClient paramClient = new ParameterClient( NodeIdentifier.forNameAndUri("/concert_checker", concertUri.toString()), concertUri); String name = (String) paramClient.getParam(GraphName.of(CONCERT_NAME_PARAM)).getResult(); Log.i("ConcertRemocon", "Concert " + name + " found; retrieve additional information"); NodeMainExecutorService nodeMainExecutorService = new NodeMainExecutorService(); NodeConfiguration nodeConfiguration = NodeConfiguration.newPublic( InetAddressFactory.newNonLoopback().getHostAddress(), concertUri); // Check for the concert information topic ListenerNode<concert_msgs.ConcertInfo> readInfoTopic = new ListenerNode(CONCERT_INFO_TOPIC, concert_msgs.ConcertInfo._TYPE); nodeMainExecutorService.execute( readInfoTopic, nodeConfiguration.setNodeName("read_info_node")); readInfoTopic.waitForResponse(); concert_msgs.ConcertInfo concertInfo = readInfoTopic.getLastMessage(); String concertName = concertInfo.getName(); String concertDesc = concertInfo.getDescription(); rocon_std_msgs.Icon concertIcon = concertInfo.getIcon(); if (name.equals(concertName) == false) Log.w( "ConcertRemocon", "Concert names from parameter and topic differs; we use the later"); // Check for the concert roles topic ListenerNode<concert_msgs.Roles> readRolesTopic = new ListenerNode(CONCERT_ROLES_TOPIC, concert_msgs.Roles._TYPE); nodeMainExecutorService.execute( readRolesTopic, nodeConfiguration.setNodeName("concert_roles_node")); readRolesTopic.waitForResponse(); nodeMainExecutorService.shutdownNodeMain(readInfoTopic); nodeMainExecutorService.shutdownNodeMain(readRolesTopic); // configure concert description Date timeLastSeen = new Date(); ConcertDescription description = new ConcertDescription(masterId, concertName, concertDesc, concertIcon, timeLastSeen); Log.i("ConcertRemocon", "Concert is available"); description.setConnectionStatus(ConcertDescription.OK); description.setUserRoles(readRolesTopic.getLastMessage()); foundConcertCallback.receive(description); return; } catch (RuntimeException e) { // thrown if concert could not be found in the getParam call (from // java.net.ConnectException) Log.w( "ConcertRemocon", "could not find concert [" + concertUri + "][" + e.toString() + "]"); failureCallback.handleFailure(e.toString()); } catch (Throwable e) { Log.w( "ConcertRemocon", "exception while creating node in concert checker for URI " + concertUri, e); failureCallback.handleFailure(e.toString()); } }
/** * @param nodeConfiguration the {@link NodeConfiguration} to copy * @return a copy of the supplied {@link NodeConfiguration} */ public static NodeConfiguration copyOf(NodeConfiguration nodeConfiguration) { NodeConfiguration copy = new NodeConfiguration(); copy.parentResolver = nodeConfiguration.parentResolver; copy.masterUri = nodeConfiguration.masterUri; copy.rosRoot = nodeConfiguration.rosRoot; copy.rosPackagePath = nodeConfiguration.rosPackagePath; copy.nodeName = nodeConfiguration.nodeName; copy.messageSerializationFactory = nodeConfiguration.messageSerializationFactory; copy.tcpRosBindAddress = nodeConfiguration.tcpRosBindAddress; copy.tcpRosAdvertiseAddressFactory = nodeConfiguration.tcpRosAdvertiseAddressFactory; copy.timeProvider = nodeConfiguration.timeProvider; copy.xmlRpcBindAddress = nodeConfiguration.xmlRpcBindAddress; copy.xmlRpcAdvertiseAddressFactory = nodeConfiguration.xmlRpcAdvertiseAddressFactory; copy.executorService = nodeConfiguration.executorService; copy.log = nodeConfiguration.log; return copy; }