本文整理汇总了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);
}
示例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);
}
});
}});
}
示例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();
}
});
}
示例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);
}
}
});
}
示例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();
}
});
}
示例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();
}
});
}
示例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;
}
});
}
});
}
示例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;
}
}
});
}
示例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();
}
}
}
});
}
示例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());
}
示例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;
}
示例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;
}
示例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);
});
}
});
}
示例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);
}
示例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);
}