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


Java Subscriber.addMessageListener方法代码示例

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


在下文中一共展示了Subscriber.addMessageListener方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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.addMessageListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。