本文整理汇总了Java中com.o3dr.services.android.lib.drone.property.Speed类的典型用法代码示例。如果您正苦于以下问题:Java Speed类的具体用法?Java Speed怎么用?Java Speed使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Speed类属于com.o3dr.services.android.lib.drone.property包,在下文中一共展示了Speed类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: changedConnectionStateTest
import com.o3dr.services.android.lib.drone.property.Speed; //导入依赖的package包/类
@Test
public void changedConnectionStateTest() throws Exception {
Altitude altitude = new Altitude();
altitude.setAltitude(100);
altitude.setTargetAltitude(150);
Speed speed = new Speed();
speed.setGroundSpeed(5);
speed.setVerticalSpeed(1);
Type type = new Type();
type.setFirmware(Type.Firmware.ARDU_COPTER);
when(drone.getAttribute(AttributeType.ALTITUDE)).thenReturn(altitude);
when(drone.getAttribute(AttributeType.SPEED)).thenReturn(speed);
when(drone.getAttribute(AttributeType.TYPE)).thenReturn(type);
service.addConnectionListener(droneConnectionListener);
service.onDroneEvent(AttributeEvent.STATE_CONNECTED, new Bundle());
DroneState droneState = new DroneStateMapper().getDroneState(drone);
droneState.setIsConnected(true);
verify(droneConnectionListener).onDroneStateChange(droneState);
}
示例2: checkForGroundCollision
import com.o3dr.services.android.lib.drone.property.Speed; //导入依赖的package包/类
private void checkForGroundCollision() {
Speed speed = getSpeed();
Altitude altitude = getAltitude();
if (speed == null || altitude == null)
return;
double verticalSpeed = speed.getVerticalSpeed();
double altitudeValue = altitude.getAltitude();
boolean isCollisionImminent = altitudeValue
+ (verticalSpeed * COLLISION_SECONDS_BEFORE_COLLISION) < 0
&& verticalSpeed < COLLISION_DANGEROUS_SPEED_METERS_PER_SECOND
&& altitudeValue > COLLISION_SAFE_ALTITUDE_METERS;
Bundle extrasBundle = new Bundle(1);
extrasBundle.putBoolean(EXTRA_IS_GROUND_COLLISION_IMMINENT, isCollisionImminent);
notifyAttributeUpdated(ACTION_GROUND_COLLISION_IMMINENT, extrasBundle);
}
示例3: onReceive
import com.o3dr.services.android.lib.drone.property.Speed; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
final Drone drone = getDrone();
switch (action) {
case AttributeEvent.ATTITUDE_UPDATED:
final Attitude attitude = drone.getAttribute(AttributeType.ATTITUDE);
onOrientationUpdate(attitude);
break;
case AttributeEvent.SPEED_UPDATED:
final Speed droneSpeed = drone.getAttribute(AttributeType.SPEED);
onSpeedUpdate(droneSpeed);
final Altitude droneAltitude = drone.getAttribute(AttributeType.ALTITUDE);
onAltitudeUpdate(droneAltitude);
break;
case AttributeEvent.STATE_UPDATED:
updateFlightTimer();
break;
}
}
示例4: speakPeriodic
import com.o3dr.services.android.lib.drone.property.Speed; //导入依赖的package包/类
private void speakPeriodic(Drone drone) {
// Drop the message if the previous one is not done yet.
if (mIsPeriodicStatusStarted.compareAndSet(false, true)) {
final Map<String, Boolean> speechPrefs = mAppPrefs.getPeriodicSpeechPrefs();
mMessageBuilder.setLength(0);
if (speechPrefs.get(DroidPlannerPrefs.PREF_TTS_PERIODIC_BAT_VOLT)) {
final Battery droneBattery = drone.getAttribute(AttributeType.BATTERY);
mMessageBuilder.append(context.getString(R.string.periodic_status_bat_volt,
droneBattery.getBatteryVoltage()));
}
if (speechPrefs.get(DroidPlannerPrefs.PREF_TTS_PERIODIC_ALT)) {
final Altitude altitude = drone.getAttribute(AttributeType.ALTITUDE);
mMessageBuilder.append(context.getString(R.string.periodic_status_altitude, (int) (altitude.getAltitude())));
}
if (speechPrefs.get(DroidPlannerPrefs.PREF_TTS_PERIODIC_AIRSPEED)) {
final Speed droneSpeed = drone.getAttribute(AttributeType.SPEED);
mMessageBuilder.append(context.getString(R.string.periodic_status_airspeed, (int) (droneSpeed.getAirSpeed())));
}
if (speechPrefs.get(DroidPlannerPrefs.PREF_TTS_PERIODIC_RSSI)) {
final Signal signal = drone.getAttribute(AttributeType.SIGNAL);
mMessageBuilder.append(context.getString(R.string.periodic_status_rssi, (int) signal.getRssi()));
}
speak(mMessageBuilder.toString(), true, PERIODIC_STATUS_UTTERANCE_ID);
}
}
示例5: onSpeedAltitudeAndClimbRateUpdate
import com.o3dr.services.android.lib.drone.property.Speed; //导入依赖的package包/类
public void onSpeedAltitudeAndClimbRateUpdate(Speed speed, Altitude altitude) {
if(speed != null) {
airSpeed.setText(String.format("%3.1f", speed.getAirSpeed()));
groundSpeed.setText(String.format("%3.1f", speed.getGroundSpeed()));
climbRate.setText(String.format("%3.1f", speed.getVerticalSpeed()));
}
if(altitude != null) {
double alt = altitude.getAltitude();
double targetAlt = altitude.getTargetAltitude();
this.altitude.setText(String.format("%3.1f", alt));
targetAltitude.setText(String.format("%3.1f", targetAlt));
}
}
示例6: speakPeriodic
import com.o3dr.services.android.lib.drone.property.Speed; //导入依赖的package包/类
private void speakPeriodic(Drone drone) {
// Drop the message if the previous one is not done yet.
if (mIsPeriodicStatusStarted.compareAndSet(false, true)) {
final SparseBooleanArray speechPrefs = mAppPrefs.getPeriodicSpeechPrefs();
mMessageBuilder.setLength(0);
if (speechPrefs.get(R.string.pref_tts_periodic_bat_volt_key)) {
final Battery droneBattery = drone.getAttribute(AttributeType.BATTERY);
mMessageBuilder.append(String.format("battery %2.1f volts. ", droneBattery.getBatteryVoltage()));
}
if (speechPrefs.get(R.string.pref_tts_periodic_alt_key)) {
final Altitude altitude = drone.getAttribute(AttributeType.ALTITUDE);
mMessageBuilder.append("altitude, ").append((int) (altitude.getAltitude())).append(" meters. ");
}
if (speechPrefs.get(R.string.pref_tts_periodic_airspeed_key)) {
final Speed droneSpeed = drone.getAttribute(AttributeType.SPEED);
mMessageBuilder.append("airspeed, ").append((int) (droneSpeed.getAirSpeed()))
.append(" meters per second. ");
}
if (speechPrefs.get(R.string.pref_tts_periodic_rssi_key)) {
final Signal signal = drone.getAttribute(AttributeType.SIGNAL);
mMessageBuilder.append("r s s i, ").append((int) signal.getRssi()).append(" decibels");
}
speak(mMessageBuilder.toString(), true, PERIODIC_STATUS_UTTERANCE_ID);
}
}
示例7: onSpeedUpdate
import com.o3dr.services.android.lib.drone.property.Speed; //导入依赖的package包/类
private void onSpeedUpdate(Speed speed) {
if (speed != null) {
final SpeedUnitProvider speedUnitProvider = getSpeedUnitProvider();
airSpeed.setText(speedUnitProvider.boxBaseValueToTarget(speed.getAirSpeed()).toString());
groundSpeed.setText(speedUnitProvider.boxBaseValueToTarget(speed.getGroundSpeed()).toString());
climbRate.setText(speedUnitProvider.boxBaseValueToTarget(speed.getVerticalSpeed()).toString());
}
}
示例8: getSpeed
import com.o3dr.services.android.lib.drone.property.Speed; //导入依赖的package包/类
private Speed getSpeed() {
org.droidplanner.core.drone.variables.Speed droneSpeed = this.droneMgr.getDrone().getSpeed();
return new Speed(droneSpeed.getVerticalSpeed().valueInMetersPerSecond(),
droneSpeed.getGroundSpeed().valueInMetersPerSecond(),
droneSpeed.getAirSpeed().valueInMetersPerSecond());
}
示例9: getSpeed
import com.o3dr.services.android.lib.drone.property.Speed; //导入依赖的package包/类
public Speed getSpeed() {
Speed speed = getAttribute(AttributeType.SPEED, Speed.class.getClassLoader());
return speed == null ? new Speed() : speed;
}
示例10: updateSpeed
import com.o3dr.services.android.lib.drone.property.Speed; //导入依赖的package包/类
protected void updateSpeed() {
TextView speedTextView = (TextView) findViewById(R.id.speedValueTextView);
Speed droneSpeed = this.drone.getAttribute(AttributeType.SPEED);
speedTextView.setText(String.format("%3.1f", droneSpeed.getGroundSpeed()) + "m/s");
}