当前位置: 首页>>代码示例>>Java>>正文


Java ConnectedNode类代码示例

本文整理汇总了Java中org.ros.node.ConnectedNode的典型用法代码示例。如果您正苦于以下问题:Java ConnectedNode类的具体用法?Java ConnectedNode怎么用?Java ConnectedNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ConnectedNode类属于org.ros.node包,在下文中一共展示了ConnectedNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onStart

import org.ros.node.ConnectedNode; //导入依赖的package包/类
@Override
public void onStart(ConnectedNode connectedNode) {
  publisher = connectedNode.newPublisher(topicName, geometry_msgs.Twist._TYPE);
  currentVelocityCommand = publisher.newMessage();
  Subscriber<nav_msgs.Odometry> subscriber =
      connectedNode.newSubscriber("odom", nav_msgs.Odometry._TYPE);
  subscriber.addMessageListener(this);
  publisherTimer = new Timer();
  publisherTimer.schedule(new TimerTask() {
    @Override
    public void run() {
      if (publishVelocity) {
        publisher.publish(currentVelocityCommand);
      }
    }
  }, 0, 80);
}
 
开发者ID:frankjoshua,项目名称:AndroidRosJava,代码行数:18,代码来源:VirtualJoystickView.java

示例2: startMoveBaseNode

import org.ros.node.ConnectedNode; //导入依赖的package包/类
private void startMoveBaseNode() {
    // Create ROS node for base move
    mLog.info("Starting move base native node");
    mRosNavigationStatusIndicator.updateStatus(ModuleStatusIndicator.Status.LOADING);
    NodeConfiguration nodeConfiguration = NodeConfiguration.newPublic(mHostName);
    nodeConfiguration.setMasterUri(mMasterUri);
    nodeConfiguration.setNodeName(MoveBaseNode.NODE_NAME);
    mMoveBaseNode = new MoveBaseNode();
    mNodeMainExecutor.execute(mMoveBaseNode, nodeConfiguration,
            new ArrayList<NodeListener>(){{
                add(new DefaultNodeListener() {
                    @Override
                    public void onStart(ConnectedNode connectedNode) {
                        mRosNavigationStatusIndicator.updateStatus(ModuleStatusIndicator.Status.OK);
                    }

                    @Override
                    public void onError(Node node, Throwable throwable) {
                        mRosNavigationStatusIndicator.updateStatus(ModuleStatusIndicator.Status.ERROR);
                    }
                });
            }});
}
 
开发者ID:ekumenlabs,项目名称:tangobot,代码行数:24,代码来源:MainActivity.java

示例3: startPublishing

import org.ros.node.ConnectedNode; //导入依赖的package包/类
private void startPublishing(ConnectedNode connectedNode) {
    connectedNode.executeCancellableLoop(new CancellableLoop() {
        @Override
        protected void loop() throws InterruptedException {
            WallTimeRate rate = new WallTimeRate(mPublishRate);

            if (!mTfList.isEmpty()) {
                Time time = Time.fromMillis(System.currentTimeMillis());
                for (TransformStamped tfs : mTfList) {
                    tfs.getHeader().setStamp(time);
                }

                TFMessage tfm = mTfPublisher.newMessage();
                tfm.setTransforms(mTfList);
                mTfPublisher.publish(tfm);
            }
            rate.sleep();
        }
    });
}
 
开发者ID:ekumenlabs,项目名称:tangobot,代码行数:21,代码来源:ExtrinsicsTfPublisherNode.java

示例4: onStart

import org.ros.node.ConnectedNode; //导入依赖的package包/类
@Override
public synchronized void onStart(final ConnectedNode connectedNode) {
    m_node = connectedNode;
    m_cmdPublisher = connectedNode.newPublisher("command", CommandStamped._TYPE);
    m_cmdPublisher.addListener(new DefaultPublisherListener<CommandStamped>() {
        @Override
        public void onNewSubscriber(Publisher<CommandStamped> publisher, SubscriberIdentifier subscriberIdentifier) {
            while (!m_queue.isEmpty()) {
                CommandStamped cmd = m_queue.poll();
                publisher.publish(cmd);
            }
            synchronized(RobotNodeMain.this) {
                m_ready = true;
            }
        }
    });
    Subscriber<AckStamped> subscriber = connectedNode.newSubscriber("mgt/ack", AckStamped._TYPE);
    subscriber.addMessageListener(this);

    Subscriber<EkfState> ekfSub = connectedNode.newSubscriber("gnc/ekf", EkfState._TYPE);
    ekfSub.addMessageListener(new MessageListener<EkfState>() {
        @Override
        public void onNewMessage(final EkfState ekfState) {
            synchronized(m_kinematics_lock) {
                m_kinematics = new DefaultKinematics(ekfState);
            }
        }
    });
}
 
开发者ID:nasa,项目名称:astrobee_android,代码行数:30,代码来源:RobotNodeMain.java

示例5: onStart

import org.ros.node.ConnectedNode; //导入依赖的package包/类
@Override
public void onStart(ConnectedNode connectedNode) {
  Subscriber<T> subscriber = connectedNode.newSubscriber(topicName, messageType);
  subscriber.addMessageListener(new MessageListener<T>() {
    @Override
    public void onNewMessage(final T message) {
      if (callable != null) {
        post(new Runnable() {
          @Override
          public void run() {
            setText(callable.call(message));
          }
        });
      } else {
        post(new Runnable() {
          @Override
          public void run() {
            setText(message.toString());
          }
        });
      }
      postInvalidate();
    }
  });
}
 
开发者ID:frankjoshua,项目名称:AndroidRosJava,代码行数:26,代码来源:RosTextView.java

示例6: onStart

import org.ros.node.ConnectedNode; //导入依赖的package包/类
@Override
public void onStart(ConnectedNode connectedNode) {
  Subscriber<T> subscriber = connectedNode.newSubscriber(topicName, messageType);
  subscriber.addMessageListener(new MessageListener<T>() {
    @Override
    public void onNewMessage(final T message) {
      post(new Runnable() {
        @Override
        public void run() {
          setImageBitmap(callable.call(message));
        }
      });
      postInvalidate();
    }
  });
}
 
开发者ID:frankjoshua,项目名称:AndroidRosJava,代码行数:17,代码来源:RosImageView.java

示例7: onStart

import org.ros.node.ConnectedNode; //导入依赖的package包/类
@Override
public void onStart(final VisualizationView view, ConnectedNode connectedNode) {
  this.connectedNode = connectedNode;
  shape = new PixelSpacePoseShape();
  posePublisher = connectedNode.newPublisher(topic, geometry_msgs.PoseStamped._TYPE);
  view.post(new Runnable() {
    @Override
    public void run() {
      gestureDetector =
          new GestureDetector(view.getContext(), new GestureDetector.SimpleOnGestureListener() {
            @Override
            public void onLongPress(MotionEvent e) {
              pose =
                  Transform.translation(view.getCamera().toCameraFrame((int) e.getX(),
                      (int) e.getY()));
              shape.setTransform(pose);
              visible = true;
            }
          });
    }
  });
}
 
开发者ID:frankjoshua,项目名称:AndroidRosJava,代码行数:23,代码来源:PosePublisherLayer.java

示例8: onStart

import org.ros.node.ConnectedNode; //导入依赖的package包/类
@Override
public void onStart(final VisualizationView view, ConnectedNode connectedNode) {
  super.onStart(view, connectedNode);
  shape = new GoalShape();
  getSubscriber().addMessageListener(new MessageListener<geometry_msgs.PoseStamped>() {
    @Override
    public void onNewMessage(geometry_msgs.PoseStamped pose) {
      GraphName source = GraphName.of(pose.getHeader().getFrameId());
      FrameTransform frameTransform = view.getFrameTransformTree().transform(source, targetFrame);
      if (frameTransform != null) {
        Transform poseTransform = Transform.fromPoseMessage(pose.getPose());
        shape.setTransform(frameTransform.getTransform().multiply(poseTransform));
        ready = true;
      }
    }
  });
}
 
开发者ID:frankjoshua,项目名称:AndroidRosJava,代码行数:18,代码来源:PoseSubscriberLayer.java

示例9: onStart

import org.ros.node.ConnectedNode; //导入依赖的package包/类
@Override
public void onStart(final VisualizationView view, ConnectedNode connectedNode) {
  super.onStart(view, connectedNode);
  getSubscriber().addMessageListener(new MessageListener<nav_msgs.GridCells>() {
    @Override
    public void onNewMessage(nav_msgs.GridCells data) {
      frame = GraphName.of(data.getHeader().getFrameId());
      if (view.getFrameTransformTree().lookUp(frame) != null) {
        if (lock.tryLock()) {
          message = data;
          ready = true;
          lock.unlock();
        }
      }
    }
  });
}
 
开发者ID:frankjoshua,项目名称:AndroidRosJava,代码行数:18,代码来源:GridCellsLayer.java

示例10: onStart

import org.ros.node.ConnectedNode; //导入依赖的package包/类
@Override
public void onStart(ConnectedNode connectedNode) {
  // Subscribe to the laser scans.
  Subscriber<sensor_msgs.LaserScan> laserScanSubscriber =
      connectedNode.newSubscriber(laserTopic, sensor_msgs.LaserScan._TYPE);
  laserScanSubscriber.addMessageListener(this);
  // Subscribe to the command velocity. This is needed for auto adjusting the
  // zoom in ZoomMode.VELOCITY_ZOOM_MODE mode.
  Subscriber<geometry_msgs.Twist> twistSubscriber =
      connectedNode.newSubscriber("cmd_vel", geometry_msgs.Twist._TYPE);
  twistSubscriber.addMessageListener(new MessageListener<geometry_msgs.Twist>() {
    @Override
    public void onNewMessage(final geometry_msgs.Twist robotVelocity) {
      post(new Runnable() {
        @Override
        public void run() {
          distanceRenderer.currentSpeed(robotVelocity.getLinear().getX());
        }
      });
    }
  });
  setOnTouchListener(this);
  // Load the last saved setting.
  distanceRenderer.loadPreferences(this.getContext());
}
 
开发者ID:frankjoshua,项目名称:AndroidRosJava,代码行数:26,代码来源:DistanceView.java

示例11: makeNewCopy

import org.ros.node.ConnectedNode; //导入依赖的package包/类
private static PlayerInfo makeNewCopy(ConnectedNode conectedNode,
        PlayerInfo player) {
    PlayerInfo result = conectedNode.getTopicMessageFactory().newFromType(PlayerInfo._TYPE);
    if (player != null) {
        result.setCanseek(player.getCanseek());
        result.setFile(player.getFile());
        result.setMediaid(player.getMediaid());
        result.getMediatype().setValue(player.getMediatype().getValue());;
        result.setSpeed(player.getSpeed());
        result.setStamp(player.getStamp());
        result.setState(player.getState());
        result.setSubtitleenabled(player.getSubtitleenabled());
        result.setThumbnail(player.getThumbnail());
        result.setTitle(player.getTitle());
        result.setTotaltime(player.getTotaltime());
    }
    return result;
}
 
开发者ID:rosalfred,项目名称:smarthome_common_driver,代码行数:19,代码来源:MediaStateDataComparator.java

示例12: makeNewCopy

import org.ros.node.ConnectedNode; //导入依赖的package包/类
@Override
public HeatingStateData makeNewCopy(
        ConnectedNode connectedNode,
        String frameId,
        HeatingStateData stateData) {

    HeatingStateData result = connectedNode.getTopicMessageFactory()
            .newFromType(HeatingStateData._TYPE);

    result.getHeader().setFrameId(frameId);
    result.getHeader().setStamp(connectedNode.getCurrentTime());
    result.setProportional(stateData.getProportional());
    result.setIntegral(stateData.getIntegral());
    result.setDerivative(stateData.getDerivative());
    result.setTemperatureGoal(SensorTemperatureStateDataComparator.makeNewCopy(connectedNode, frameId, stateData.getTemperatureGoal()));
    result.setTemperatureReal(SensorTemperatureStateDataComparator.makeNewCopy(connectedNode, frameId, stateData.getTemperatureReal()));
    result.setTimeSlotCurrent(makeNewCopy(connectedNode, frameId, stateData.getTimeSlotCurrent()));

    return result;
}
 
开发者ID:rosalfred,项目名称:smarthome_common_driver,代码行数:21,代码来源:HeaterTemperatureStateDataComparator.java

示例13: onStart

import org.ros.node.ConnectedNode; //导入依赖的package包/类
@Override
public void onStart(final ConnectedNode connectedNode) {
  // This CancellableLoop will be canceled automatically when the node shuts
  // down.
  final Publisher<Message> publisher = connectedNode.newPublisher(nodeName, publishType);
  connectedNode.executeCancellableLoop(new CancellableLoop() {

    @Override
    protected void loop() throws InterruptedException {
      semaphore.acquire();
      publishMe.ifPresent(publishAction -> {
        final Message message = publisher.newMessage();
        publishAction.convert(message, connectedNode.getTopicMessageFactory());
        publisher.publish(message);
      });
    }
  });
}
 
开发者ID:WPIRoboticsProjects,项目名称:GRIP,代码行数:19,代码来源:ROSManager.java

示例14: onStart

import org.ros.node.ConnectedNode; //导入依赖的package包/类
@Override
public void onStart(ConnectedNode connectedNode) {
    final Publisher<std_msgs.String> publisher = connectedNode.newPublisher(GraphName.of("time"), std_msgs.String._TYPE);

    final CancellableLoop loop = new CancellableLoop() {
        @Override
        protected void loop() throws InterruptedException {
            // retrieve current system time
            String time = new SimpleDateFormat("HH:mm:ss").format(new Date());

            Log.i(TAG, "publishing the current time: " + time);

            // create and publish a simple string message
            std_msgs.String str = publisher.newMessage();
            str.setData("The current time is: " + time);
            publisher.publish(str);

            // go to sleep for one second
            Thread.sleep(1000);
        }
    };
    connectedNode.executeCancellableLoop(loop);
}
 
开发者ID:ollide,项目名称:rosjava_android_template,代码行数:24,代码来源:SimplePublisherNode.java

示例15: onStart

import org.ros.node.ConnectedNode; //导入依赖的package包/类
/**
* Invoked by rosjava framework when this node connects to a ROS master
*/
@Override
public void onStart(ConnectedNode connectedNode)
/*************************************************************************/
{
    super.onStart(connectedNode);
    connectedNode_ = connectedNode;
    Log.d("JoystickNode", "JoystickNode: Connected to ROS master. Creating publisher object...");
    joystickPublisher_ = connectedNode.newPublisher(joystickTopic_, sensor_msgs.Joy._TYPE);

    Timer publisherTimer = new Timer();
    publisherTimer.schedule(new TimerTask() { //Note: This is a very interesting feature of Java, anonymous classes! Overriding a method for an object of type TimerTask without having to subclass explicitly!
        @Override
        public void run()
        {
            publishLatestJoystickMessage();
        }
    }, 0, 100);
}
 
开发者ID:willowgarage,项目名称:shield_teleop,代码行数:22,代码来源:JoystickNode.java


注:本文中的org.ros.node.ConnectedNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。