• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Subscriber类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: onStart

import org.ros.node.topic.Subscriber; //导入依赖的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.topic.Subscriber; //导入依赖的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.topic.Subscriber; //导入依赖的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


示例4: onStart

import org.ros.node.topic.Subscriber; //导入依赖的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


示例5: onStart

import org.ros.node.topic.Subscriber; //导入依赖的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


示例6: onStart

import org.ros.node.topic.Subscriber; //导入依赖的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


示例7: onStart

import org.ros.node.topic.Subscriber; //导入依赖的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


示例8: onStart

import org.ros.node.topic.Subscriber; //导入依赖的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


示例9: onStart

import org.ros.node.topic.Subscriber; //导入依赖的package包/类
@Override
public void onStart(ConnectedNode connectedNode) {
  Subscriber<DiagnosticArray> subscriber =
      connectedNode.newSubscriber(DIAGNOSTICS_AGGREGATOR_TOPIC,
          diagnostic_msgs.DiagnosticArray._TYPE);
  subscriber.addMessageListener(new MessageListener<DiagnosticArray>() {
    @Override
    public void onNewMessage(final DiagnosticArray message) {
      final List<DiagnosticStatus> diagnosticStatusMessages = message.getStatus();
      post(new Runnable() {
        @Override
        public void run() {
          removeAllViews();
          for (final DiagnosticStatus diagnosticStatusMessage : diagnosticStatusMessages) {
            Button button = new Button(getContext());
            button.setText(diagnosticStatusMessage.getName());
            if (diagnosticStatusMessage.getLevel() == STALE) {
              button.setCompoundDrawablesWithIntrinsicBounds(staleDrawable, null, null, null);
            } else if (diagnosticStatusMessage.getLevel() == DiagnosticStatus.ERROR) {
              button.setCompoundDrawablesWithIntrinsicBounds(errorDrawable, null, null, null);
            } else if (diagnosticStatusMessage.getLevel() == DiagnosticStatus.WARN) {
              button.setCompoundDrawablesWithIntrinsicBounds(warningDrawable, null, null, null);
            } else {
              button.setCompoundDrawablesWithIntrinsicBounds(okDrawable, null, null, null);
            }
            addView(button);
          }
        }
      });
      postInvalidate();
    }
  });
}
 
开发者ID:frankjoshua,项目名称:AndroidRosJava,代码行数:34,代码来源:DiagnosticsArrayView.java


示例10: onStart

import org.ros.node.topic.Subscriber; //导入依赖的package包/类
@Override
public void onStart(VisualizationView view, ConnectedNode connectedNode) {
  super.onStart(view, connectedNode);
  Subscriber<LaserScan> subscriber = getSubscriber();
  subscriber.addMessageListener(new MessageListener<LaserScan>() {
    @Override
    public void onNewMessage(LaserScan laserScan) {
      frame = GraphName.of(laserScan.getHeader().getFrameId());
      updateVertexBuffer(laserScan, LASER_SCAN_STRIDE);
    }
  });
}
 
开发者ID:frankjoshua,项目名称:AndroidRosJava,代码行数:13,代码来源:LaserScanLayer.java


示例11: onStart

import org.ros.node.topic.Subscriber; //导入依赖的package包/类
@Override
public void onStart(VisualizationView view, ConnectedNode connectedNode) {
  super.onStart(view, connectedNode);
  Subscriber<PointCloud2> subscriber = getSubscriber();
  subscriber.addMessageListener(new MessageListener<PointCloud2>() {
    @Override
    public void onNewMessage(PointCloud2 pointCloud) {
      frame = GraphName.of(pointCloud.getHeader().getFrameId());
      updateVertexBuffer(pointCloud);
    }
  });
}
 
开发者ID:frankjoshua,项目名称:AndroidRosJava,代码行数:13,代码来源:PointCloud2DLayer.java


示例12: onStart

import org.ros.node.topic.Subscriber; //导入依赖的package包/类
@Override
public void onStart(ConnectedNode connectedNode) {
    Subscriber<ff_msgs.CommandStamped> subscriber = connectedNode.newSubscriber(
            getDefaultNodeName().join("command"), ff_msgs.CommandStamped._TYPE);
    subscriber.addMessageListener(new MessageListener<ff_msgs.CommandStamped>() {
        private static final String TAG = "Subscriber<Command>";

        @Override
        public void onNewMessage(final ff_msgs.CommandStamped cmd) {
            Log.i(TAG, "I received a command");

            if (!cmd.getCmdName().equals("set_color")) {
                Log.e(TAG, "wrong command name");
                return;
            }

            final List<ff_msgs.CommandArg> args = cmd.getArgs();
            if (args.size() != 3) {
                Log.e(TAG, "wrong number of args");
                return;
            }

            final ff_msgs.CommandArg red = args.get(0);
            final ff_msgs.CommandArg green = args.get(1);
            final ff_msgs.CommandArg blue = args.get(2);

            if (red.getDataType() != CommandArg.DATA_TYPE_INT ||
                    blue.getDataType() != CommandArg.DATA_TYPE_INT ||
                    green.getDataType() != CommandArg.DATA_TYPE_INT) {
                Log.e(TAG, "args not integers");
                return;
            }

            mMainHandler.post(new Runnable() {
                @Override
                public void run() {
                    mRed.setValue(red.getI());
                    mGreen.setValue(green.getI());
                    mBlue.setValue(blue.getI());
                    onColorChanged();
                }
            });
        }
    });

    Publisher<std_msgs.ColorRGBA> publisher = connectedNode.newPublisher(
            getDefaultNodeName().join("color"),
            std_msgs.ColorRGBA._TYPE);
    publisher.setLatchMode(true);

    synchronized(mPublisherLock) {
        mColorPublisher = publisher;
    }
}
 
开发者ID:nasa,项目名称:astrobee_android,代码行数:55,代码来源:MainActivity.java


示例13: getSubscriber

import org.ros.node.topic.Subscriber; //导入依赖的package包/类
public Subscriber<T> getSubscriber() {
  Preconditions.checkNotNull(subscriber);
  return subscriber;
}
 
开发者ID:frankjoshua,项目名称:AndroidRosJava,代码行数:5,代码来源:SubscriberLayer.java


示例14: onStart

import org.ros.node.topic.Subscriber; //导入依赖的package包/类
public void onStart(ConnectedNode connectedNode) {
    final Subscriber subscriber = connectedNode.newSubscriber(this.topic_name, this.message_type);
    subscriber.addMessageListener(this.messageListener);
}
 
开发者ID:NEU-TEAM,项目名称:JARVIS,代码行数:5,代码来源:Listener.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DoStmt类代码示例发布时间:2022-05-22
下一篇:
Java RemoteConsoleCommandSender类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap