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


Java Time类代码示例

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


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

示例1: getCurrentTime

import org.ros.message.Time; //导入依赖的package包/类
Time getCurrentTime() {

        long msecs = System.currentTimeMillis();
        switch (pref.getInt("quadControl", 1)) {
            case 1:
                msecs = msecs - mRef1;
                break;
            case 2:
                msecs = msecs - mRef2;
                break;
            case 3:
                msecs = msecs - mRef3;
                break;
        }

        Time mTime = new Time();
        mTime.secs = (int) (msecs / 1000);
        mTime.nsecs = (int)((msecs % 1000) * 1000000);

        return mTime;
    }
 
开发者ID:radionavlab,项目名称:utmg-android-interface,代码行数:22,代码来源:CanvasView.java

示例2: startPublishing

import org.ros.message.Time; //导入依赖的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

示例3: onSensorChanged

import org.ros.message.Time; //导入依赖的package包/类
@Override
public void onSensorChanged(SensorEvent event) {
  if (event.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR) {
    float[] quaternion = new float[4];
    SensorManager.getQuaternionFromVector(quaternion, event.values);
    PoseStamped pose = publisher.newMessage();
    pose.getHeader().setFrameId("/map");
    // TODO(damonkohler): Should get time from the Node.
    pose.getHeader().setStamp(Time.fromMillis(System.currentTimeMillis()));
    pose.getPose().getOrientation().setW(quaternion[0]);
    pose.getPose().getOrientation().setX(quaternion[1]);
    pose.getPose().getOrientation().setY(quaternion[2]);
    pose.getPose().getOrientation().setZ(quaternion[3]);
    publisher.publish(pose);
  }
}
 
开发者ID:frankjoshua,项目名称:AndroidRosJava,代码行数:17,代码来源:OrientationPublisher.java

示例4: updateLocation

import org.ros.message.Time; //导入依赖的package包/类
public void updateLocation(Location location) {
		//TODO: fill out rest of nav information, and also publish velocity and time_reference
//		sensor_msgs.NavSatStatus.
		sensor_msgs.NavSatFix msg = fixPublisher.newMessage();
		//time since jan 1 1970...convert msec to seconds (double)
		msg.getHeader().setStamp(new Time(location.getTime()/1000.0));
		//NOTE: this may not be right...android reports alt above sealevel, ROS expects altitude above ellipsoid
		msg.setAltitude(location.getAltitude());
		msg.setLatitude(location.getLatitude());
		msg.setLongitude(location.getLongitude());
//		sensor_msgs.NavSatStatus status;
//		status.
		//TODO: accuracy, velocity (Twist)
		// TODO Auto-generated method stub
		fixPublisher.publish(msg);
	}
 
开发者ID:gtagency,项目名称:android_nav,代码行数:17,代码来源:AndroidLocationNode.java

示例5: setTraj1

import org.ros.message.Time; //导入依赖的package包/类
void setTraj1(ArrayList<Float> x, ArrayList<Float> y, ArrayList<Float> z, ArrayList<Time> t) {
    xes1 = x;
    yes1 = y;
    zes1 = z;
    tes1 = t;
    publishToggle1 = true;
    Log.i("Traj1","Arrays transferred to node");
}
 
开发者ID:radionavlab,项目名称:utmg-android-interface,代码行数:9,代码来源:ROSNode.java

示例6: setTraj2

import org.ros.message.Time; //导入依赖的package包/类
void setTraj2(ArrayList<Float> x, ArrayList<Float> y, ArrayList<Float> z, ArrayList<Time> t) {
    xes2 = x;
    yes2 = y;
    zes2 = z;
    tes2 = t;
    publishToggle2 = true;
    Log.i("Traj2","Arrays transferred to node");
}
 
开发者ID:radionavlab,项目名称:utmg-android-interface,代码行数:9,代码来源:ROSNode.java

示例7: setTraj3

import org.ros.message.Time; //导入依赖的package包/类
void setTraj3(ArrayList<Float> x, ArrayList<Float> y, ArrayList<Float> z, ArrayList<Time> t) {
    xes3 = x;
    yes3 = y;
    zes3 = z;
    tes3 = t;
    publishToggle3 = true;
    Log.i("Traj3","Arrays transferred to node");
}
 
开发者ID:radionavlab,项目名称:utmg-android-interface,代码行数:9,代码来源:ROSNode.java

示例8: fillInformation

import org.ros.message.Time; //导入依赖的package包/类
@Override
public void fillInformation(MapMetaData information) {
    information.setMapLoadTime(Time.fromMillis(System.currentTimeMillis()));
    // Set the origin to the center of the map
    Pose origin = information.getOrigin();
    origin.getPosition().setX(-1 * WIDTH * RESOLUTION / 2);
    origin.getPosition().setY(-1 * HEIGHT * RESOLUTION / 2);
    Quaternion.identity().toQuaternionMessage(origin.getOrientation());
    information.setWidth(WIDTH);
    information.setHeight(HEIGHT);
    information.setResolution(RESOLUTION);
}
 
开发者ID:ekumenlabs,项目名称:tangobot,代码行数:13,代码来源:EmptyMapGenerator.java

示例9: onStart

import org.ros.message.Time; //导入依赖的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

示例10: onStart

import org.ros.message.Time; //导入依赖的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

示例11: stopAllMotion

import org.ros.message.Time; //导入依赖的package包/类
public void stopAllMotion() {
    if (mPublisher == null) {
        return;
    }

    ff_msgs.CommandStamped cmdToSend = mPublisher.newMessage();
    std_msgs.Header hdr = mMsgFac.newFromType(Header._TYPE);
    Time myTime = new Time();
    myTime.secs = 1487370000;
    myTime.nsecs = 0;
    hdr.setStamp(myTime);
    cmdToSend.setHeader(hdr);
    // Command names listed in CommandConstants.h
    cmdToSend.setCmdName(ff_msgs.CommandConstants.CMD_NAME_STOP_ALL_MOTION);

    // Command id needs to be a unique id that you will use make sure the command
    // was executed, usually a combination of username and timestamp
    // move_cmd.setCmdId("guest_science_1");
    cmdToSend.setCmdId("guest_science_" + ff_msgs.CommandConstants.CMD_NAME_STOP_ALL_MOTION);

    // Source of the command, set to guest_science so that the system knows that
    // the command didn't come from the ground
    cmdToSend.setCmdSrc("guest_science");

    ff_msgs.CommandArg cmdArg1 = mMsgFac.newFromType(CommandArg._TYPE);

    // can really set it to anything
    cmdArg1.setDataType(ff_msgs.CommandArg.DATA_TYPE_STRING);
    cmdArg1.setS("world");

    List<CommandArg> args = new ArrayList<CommandArg>();
    args.add(cmdArg1);

    cmdToSend.setArgs(args);

    mPublisher.publish(cmdToSend);
}
 
开发者ID:nasa,项目名称:astrobee_android,代码行数:38,代码来源:GuestScienceRosMessages.java

示例12: onNewRawImage

import org.ros.message.Time; //导入依赖的package包/类
@Override
public void onNewRawImage(byte[] data, Size size) {
  Preconditions.checkNotNull(data);
  Preconditions.checkNotNull(size);
  if (data != rawImageBuffer || !size.equals(rawImageSize)) {
    rawImageBuffer = data;
    rawImageSize = size;
    yuvImage = new YuvImage(rawImageBuffer, ImageFormat.NV21, size.width, size.height, null);
    rect = new Rect(0, 0, size.width, size.height);
  }

  Time currentTime = connectedNode.getCurrentTime();
  String frameId = "camera";

  sensor_msgs.CompressedImage image = imagePublisher.newMessage();
  image.setFormat("jpeg");
  image.getHeader().setStamp(currentTime);
  image.getHeader().setFrameId(frameId);

  Preconditions.checkState(yuvImage.compressToJpeg(rect, 20, stream));
  image.setData(stream.buffer().copy());
  stream.buffer().clear();

  imagePublisher.publish(image);

  sensor_msgs.CameraInfo cameraInfo = cameraInfoPublisher.newMessage();
  cameraInfo.getHeader().setStamp(currentTime);
  cameraInfo.getHeader().setFrameId(frameId);

  cameraInfo.setWidth(size.width);
  cameraInfo.setHeight(size.height);
  cameraInfoPublisher.publish(cameraInfo);
}
 
开发者ID:frankjoshua,项目名称:AndroidRosJava,代码行数:34,代码来源:CompressedImagePublisher.java

示例13: setCompressedImage

import org.ros.message.Time; //导入依赖的package包/类
private void setCompressedImage(Mat inputFrame, tms_ss_rcnn.obj_detectionRequest request) throws IOException {
    Time time = mConnectedNode.getCurrentTime();
    request.getImage().getHeader().setStamp(time);
    request.getImage().getHeader().setFrameId("ObjectDetection");
    request.getImage().getHeader().setSeq(sequenceNumber++);
    request.getImage().setFormat("jpg");

    MatOfByte buf = new MatOfByte();
    Highgui.imencode(".jpg", inputFrame, buf);
    ChannelBufferOutputStream stream = new ChannelBufferOutputStream(MessageBuffers.dynamicBuffer());
    stream.write(buf.toArray());

    request.getImage().setData(stream.buffer().copy());
}
 
开发者ID:kazuto1011,项目名称:ros-tms-perception,代码行数:15,代码来源:ObjectDetectionClient.java

示例14: fillHeader

import org.ros.message.Time; //导入依赖的package包/类
@Override
public void fillHeader(Header header) {
    header.setFrameId("map");
    header.setStamp(Time.fromMillis(System.currentTimeMillis()));
}
 
开发者ID:ekumenlabs,项目名称:tangobot,代码行数:6,代码来源:EmptyMapGenerator.java

示例15: armPanAndTilt

import org.ros.message.Time; //导入依赖的package包/类
public void armPanAndTilt(float pan, float tilt, String componentToMove) {
    if (mPublisher == null) {
        return;
    }

    ff_msgs.CommandStamped cmdToSend = mPublisher.newMessage();
    std_msgs.Header hdr = mMsgFac.newFromType(Header._TYPE);
    Time myTime = new Time();
    myTime.secs = 1487370000;
    myTime.nsecs = 0;
    hdr.setStamp(myTime);
    cmdToSend.setHeader(hdr);
    // Command names listed in CommandConstants.h
    cmdToSend.setCmdName(ff_msgs.CommandConstants.CMD_NAME_ARM_PAN_AND_TILT);

    // Command id needs to be a unique id that you will use make sure the command
    // was executed, usually a combination of username and timestamp
    cmdToSend.setCmdId("guest_science_" + ff_msgs.CommandConstants.CMD_NAME_ARM_PAN_AND_TILT);

    // Source of the command, set to guest_science so that the system knows that
    // the command didn't come from the ground
    cmdToSend.setCmdSrc("guest_science");

    // Set the ARM component to move
    ff_msgs.CommandArg cmdArg1 = mMsgFac.newFromType(CommandArg._TYPE);
    cmdArg1.setDataType(ff_msgs.CommandArg.DATA_TYPE_FLOAT);
    cmdArg1.setF(pan);

    // Set the ARM angle1 to move
    ff_msgs.CommandArg cmdArg2 = mMsgFac.newFromType(CommandArg._TYPE);
    cmdArg2.setDataType(CommandArg.DATA_TYPE_FLOAT);
    cmdArg2.setF(tilt);

    // Set the ARM angle2 to move
    ff_msgs.CommandArg cmdArg3 = mMsgFac.newFromType(CommandArg._TYPE);
    cmdArg3.setDataType(CommandArg.DATA_TYPE_STRING);
    cmdArg3.setS(componentToMove);

    List<CommandArg> args = new ArrayList<CommandArg>();
    args.add(cmdArg1);
    args.add(cmdArg2);
    args.add(cmdArg3);

    cmdToSend.setArgs(args);

    mPublisher.publish(cmdToSend);

}
 
开发者ID:nasa,项目名称:astrobee_android,代码行数:49,代码来源:GuestScienceRosMessages.java


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