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


Java ConnectedNode.newPublisher方法代码示例

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


在下文中一共展示了ConnectedNode.newPublisher方法的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: onStart

import org.ros.node.ConnectedNode; //导入方法依赖的package包/类
@Override
public void onStart(ConnectedNode connectedNode) {
    final Publisher<DiagnosticArray> batteryPublisher = connectedNode.newPublisher(TOPIC_NAME, DiagnosticArray._TYPE);
    final DiagnosticArray diagnosticArray = batteryPublisher.newMessage();

    final DiagnosticStatus deviceBattery = mMessageFactory.newFromType(DiagnosticStatus._TYPE);
    deviceBattery.setName("/Power System/Laptop Battery");
    KeyValue deviceKeyValueCapacity = mMessageFactory.newFromType(KeyValue._TYPE);
    deviceKeyValueCapacity.setKey("Capacity (Ah)");
    deviceKeyValueCapacity.setValue("100.0");
    final KeyValue deviceKeyValueCharge = mMessageFactory.newFromType(KeyValue._TYPE);
    deviceKeyValueCharge.setKey("Charge (Ah)");
    deviceBattery.setValues(Arrays.asList(deviceKeyValueCapacity, deviceKeyValueCharge));

    diagnosticArray.setStatus(Arrays.asList(deviceBattery));

    connectedNode.executeCancellableLoop(new CancellableLoop() {
        @Override
        protected void loop() throws InterruptedException {
            diagnosticArray.getHeader().setStamp(Time.fromMillis(System.currentTimeMillis()));

            double deviceBatteryPercentage = mBatteryLevel.get();
            if (deviceBatteryPercentage > 0) {
                deviceKeyValueCharge.setValue(Double.toString(deviceBatteryPercentage));
            }

            batteryPublisher.publish(diagnosticArray);
            Thread.sleep(1000);
        }
    });
}
 
开发者ID:ekumenlabs,项目名称:tangobot,代码行数:32,代码来源:DeviceBatteryPublisherNode.java

示例8: onStart

import org.ros.node.ConnectedNode; //导入方法依赖的package包/类
@Override
public void onStart(ConnectedNode connectedNode) {
    super.onStart(connectedNode);

    mPublisher = connectedNode.newPublisher("map", OccupancyGrid._TYPE);
    mPublisher.setLatchMode(true);

    OccupancyGrid message = mPublisher.newMessage();

    mGridGenerator.fillHeader(message.getHeader());
    mGridGenerator.fillInformation(message.getInfo());
    message.setData(mGridGenerator.generateData());
    mPublisher.publish(message);
}
 
开发者ID:ekumenlabs,项目名称:tangobot,代码行数:15,代码来源:OccupancyGridPublisherNode.java

示例9: onStart

import org.ros.node.ConnectedNode; //导入方法依赖的package包/类
@Override
public void onStart(ConnectedNode connectedNode) {
    final Publisher<DiagnosticArray> batteryPublisher = connectedNode.newPublisher(TOPIC_NAME, DiagnosticArray._TYPE);
    final DiagnosticArray diagnosticArray = batteryPublisher.newMessage();
    final DiagnosticStatus robotBattery = mMessageFactory.newFromType(DiagnosticStatus._TYPE);
    robotBattery.setName("/Power System/Battery");
    final KeyValue robotKeyValueCapacity = mMessageFactory.newFromType(KeyValue._TYPE);
    robotKeyValueCapacity.setKey("Capacity (Ah)");
    robotKeyValueCapacity.setValue("100.0");
    final KeyValue robotKeyValueCharge = mMessageFactory.newFromType(KeyValue._TYPE);
    robotKeyValueCharge.setKey("Charge (Ah)");
    robotBattery.setValues(Arrays.asList(robotKeyValueCapacity, robotKeyValueCharge));

    diagnosticArray.setStatus(Arrays.asList(robotBattery));

    connectedNode.executeCancellableLoop(new CancellableLoop() {
        @Override
        protected void loop() throws InterruptedException {
            diagnosticArray.getHeader().setStamp(Time.fromMillis(System.currentTimeMillis()));
            double baseBatteryVoltage = UnsignedBytes.toInt(mBaseDevice.getBaseStatus().getBattery()) * 0.1;
            double baseBatteryPercentage =
                    (baseBatteryVoltage - BASE_MIN_VOLTAGE) /
                            (BASE_MAX_VOLTAGE - BASE_MIN_VOLTAGE) * 100.0;
            robotKeyValueCharge.setValue(Double.toString(baseBatteryPercentage));

            batteryPublisher.publish(diagnosticArray);
            Thread.sleep(1000);
        }
    });
}
 
开发者ID:ekumenlabs,项目名称:tangobot,代码行数:31,代码来源:RobotBatteryPublisherNode.java

示例10: onStart

import org.ros.node.ConnectedNode; //导入方法依赖的package包/类
@Override
public void onStart(ConnectedNode connectedNode) {
    super.onStart(connectedNode);
    mTfPublisher = connectedNode.newPublisher("/tf", TFMessage._TYPE);

    startPublishing(connectedNode);
}
 
开发者ID:ekumenlabs,项目名称:tangobot,代码行数:8,代码来源:ExtrinsicsTfPublisherNode.java

示例11: onStart

import org.ros.node.ConnectedNode; //导入方法依赖的package包/类
@Override
public void onStart(ConnectedNode connectedNode) {
    Publisher<std_msgs.String> publisher = connectedNode.newPublisher(
            getDefaultNodeName().join("out"),
            std_msgs.String._TYPE);
    mPublisher = publisher;

    Subscriber<std_msgs.String> subscriber = connectedNode.newSubscriber(
            getDefaultNodeName().join("in"),
            std_msgs.String._TYPE);
    subscriber.addMessageListener(this);
}
 
开发者ID:nasa,项目名称:astrobee_android,代码行数:13,代码来源:SimpleNode.java

示例12: onStart

import org.ros.node.ConnectedNode; //导入方法依赖的package包/类
@Override
public void onStart(ConnectedNode connectedNode) {
    Publisher<ff_msgs.CommandStamped> publisher = connectedNode.newPublisher(
            "command", ff_msgs.CommandStamped._TYPE);
    mPublisher = publisher;

    Subscriber<AckStamped> subscriber = connectedNode.newSubscriber(
            "mgt/ack", ff_msgs.AckStamped._TYPE);
    subscriber.addMessageListener(this);

    mNodeConfig = NodeConfiguration.newPrivate();
    mMsgFac = mNodeConfig.getTopicMessageFactory();
}
 
开发者ID:nasa,项目名称:astrobee_android,代码行数:14,代码来源:GuestScienceRosMessages.java

示例13: onStart

import org.ros.node.ConnectedNode; //导入方法依赖的package包/类
@Override
public void onStart(ConnectedNode connectedNode) {
    Publisher<ff_msgs.CommandStamped> publisher = connectedNode.newPublisher(
            "command", ff_msgs.CommandStamped._TYPE);
    mPublisher = publisher;

    Subscriber<ff_msgs.AckStamped> subscriber = connectedNode.newSubscriber(
            "mgt/ack", ff_msgs.AckStamped._TYPE);
    subscriber.addMessageListener(this);

    mNodeConfig = NodeConfiguration.newPrivate();
    mMsgFac = mNodeConfig.getTopicMessageFactory();
}
 
开发者ID:nasa,项目名称:astrobee_android,代码行数:14,代码来源:SimpleNode.java

示例14: onStart

import org.ros.node.ConnectedNode; //导入方法依赖的package包/类
@Override
public void onStart(ConnectedNode connectedNode) {
    Log.i(TAG, "onStart: starting...");

    if (mShutdownFuture != null) {
        mShutdownFuture.cancel(false);
    }

    Publisher<sensor_msgs.PointCloud2> publisher =
            connectedNode.newPublisher(getDefaultNodeName().join("image"),
                    sensor_msgs.PointCloud2._TYPE);
    publisher.setLatchMode(false);
    mPublisher = publisher;
    mConnectedNode = connectedNode;

    // Pre-fill a message
    mCloud = publisher.newMessage();
    mCloud.setIsDense(false);
    mCloud.setIsBigendian(ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN);
    mCloud.getHeader().setFrameId("perch_image_link");

    MessageFactory mf = connectedNode.getTopicMessageFactory();

    // Fill in the fields
    int offset = 0;
    for (final String name : Arrays.asList("x", "y", "z")){
        final PointField pf = mf.newFromType(PointField._TYPE);

        pf.setName(name);
        pf.setCount(1);
        pf.setOffset(offset);
        pf.setDatatype(PointField.FLOAT32);

        mCloud.getFields().add(pf);
        offset += 4;
    }

    mCloud.setPointStep(offset);
}
 
开发者ID:nasa,项目名称:astrobee_android,代码行数:40,代码来源:MainActivity.java

示例15: CompressedImagePublisher

import org.ros.node.ConnectedNode; //导入方法依赖的package包/类
public CompressedImagePublisher(ConnectedNode connectedNode) {
  this.connectedNode = connectedNode;
  NameResolver resolver = connectedNode.getResolver().newChild("camera");
  imagePublisher =
      connectedNode.newPublisher(resolver.resolve("image/compressed"),
          sensor_msgs.CompressedImage._TYPE);
  cameraInfoPublisher =
      connectedNode.newPublisher(resolver.resolve("camera_info"), sensor_msgs.CameraInfo._TYPE);
  stream = new ChannelBufferOutputStream(MessageBuffers.dynamicBuffer());
}
 
开发者ID:frankjoshua,项目名称:AndroidRosJava,代码行数:11,代码来源:CompressedImagePublisher.java


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