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


Java Drone类代码示例

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


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

示例1: goToDroneLocation

import com.o3dr.android.client.Drone; //导入依赖的package包/类
@Override
public void goToDroneLocation() {
    Drone dpApi = getDroneApi();
    if (!dpApi.isConnected())
        return;

    Gps gps = dpApi.getGps();
    if (!gps.isValid()) {
        Toast.makeText(getActivity().getApplicationContext(), R.string.drone_no_location, Toast.LENGTH_SHORT).show();
        return;
    }

    final float currentZoomLevel = getBaiduMap().getMapStatus().zoom;
    final LatLong droneLocation = gps.getPosition();
    updateCamera(droneLocation, (int) currentZoomLevel);
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:17,代码来源:BaiduMapFragment.java

示例2: updateItemView

import com.o3dr.android.client.Drone; //导入依赖的package包/类
@Override
public void updateItemView(final Context context, final Drone drone) {
	if (mItemView != null) {

		final String update;
		if (drone == null || !drone.isConnected()) {
			update = "--";
		} else{
                  Gps droneGps = drone.getGps();
                  if (mAppPrefs.shouldGpsHdopBeDisplayed()) {
                      update = String.format(Locale.ENGLISH, "Satellite\n%d, %.1f", droneGps
                              .getSatellitesCount(), droneGps.getGpsEph());
                  } else {
                      update = String.format(Locale.ENGLISH, "Satellite\n%d, %s", droneGps
                              .getSatellitesCount(), droneGps.getFixStatus());
                  }
              }

		((TextView) mItemView).setText(update);
	}
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:22,代码来源:InfoBarItem.java

示例3: proceedWithCalibration

import com.o3dr.android.client.Drone; //导入依赖的package包/类
private void proceedWithCalibration(@CompassCalibrationStep int step) {
    final Drone drone = getDrone();
    if(drone == null || !drone.isConnected()){
        //TODO: send a message to the notification handler for toast and voice
        Toast.makeText(getContext(), "Please connect drone before proceeding.", Toast.LENGTH_LONG).show();
        return;
    }

    switch (step) {
        case STEP_BEGIN_CALIBRATION:
        case STEP_CALIBRATION_FAILED:
        case STEP_CALIBRATION_CANCELLED:
            startCalibration();
            break;

        case STEP_CALIBRATION_SUCCESSFUL:
            startActivity(new Intent(getContext(), FlightActivity.class));
            break;

        case STEP_CALIBRATION_STARTED:
        case STEP_CALIBRATION_WAITING_TO_START:
        default:
            //nothing to do
            break;
    }
}
 
开发者ID:mxiao6,项目名称:Tower-develop,代码行数:27,代码来源:FragmentSetupCompass.java

示例4: enableFollowMe

import com.o3dr.android.client.Drone; //导入依赖的package包/类
private void enableFollowMe(final Drone drone) {
    if(drone == null)
        return;

    final LocationRequest locationReq = LocationRequest.create()
            .setPriority(FOLLOW_LOCATION_PRIORITY)
            .setFastestInterval(FOLLOW_LOCATION_UPDATE_FASTEST_INTERVAL)
            .setInterval(FOLLOW_LOCATION_UPDATE_INTERVAL)
            .setSmallestDisplacement(FOLLOW_LOCATION_UPDATE_MIN_DISPLACEMENT);

    final CheckLocationSettings locationSettingsChecker = new CheckLocationSettings(getActivity(), locationReq,
            new Runnable() {
                @Override
                public void run() {
                    FollowApi.getApi(drone).enableFollowMe(getAppPrefs().getLastKnownFollowType());
                }
            });

    locationSettingsChecker.check();
}
 
开发者ID:mxiao6,项目名称:Tower-develop,代码行数:21,代码来源:BaseFlightControlFragment.java

示例5: getTakeOffInAutoConfirmation

import com.o3dr.android.client.Drone; //导入依赖的package包/类
private void getTakeOffInAutoConfirmation() {
    final SlideToUnlockDialog unlockDialog = SlideToUnlockDialog.newInstance("take off in auto", new Runnable() {
        @Override
        public void run() {

            final double takeOffAltitude = getAppPrefs().getDefaultAltitude();

            final Drone drone = getDrone();
            ControlApi.getApi(drone).takeoff(takeOffAltitude, new SimpleCommandListener() {
                @Override
                public void onSuccess() {
                    VehicleApi.getApi(drone).setVehicleMode(VehicleMode.COPTER_AUTO);
                }
            });
        }
    });
    unlockDialog.show(getChildFragmentManager(), "Slide to take off in auto");
}
 
开发者ID:mxiao6,项目名称:Tower-develop,代码行数:19,代码来源:CopterFlightControlFragment.java

示例6: onReceive

import com.o3dr.android.client.Drone; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    final String action = intent.getAction();
    if (AttributeEvent.STATE_DISCONNECTED.equals(action)) {
        updateMavlinkVersionPreference(null);
        updateFirmwareVersionPreference(null);
    } else if (AttributeEvent.HEARTBEAT_FIRST.equals(action)
            || AttributeEvent.HEARTBEAT_RESTORED.equals(action)) {
        int mavlinkVersion = intent.getIntExtra(AttributeEventExtra.EXTRA_MAVLINK_VERSION, -1);
        if (mavlinkVersion == -1)
            updateMavlinkVersionPreference(null);
        else
            updateMavlinkVersionPreference(String.valueOf(mavlinkVersion));
    } else if (AttributeEvent.TYPE_UPDATED.equals(action)) {
        Drone drone = dpApp.getDrone();
        if (drone.isConnected()) {
            updateFirmwareVersionPreference(drone.getType().getFirmwareVersion());
        } else
            updateFirmwareVersionPreference(null);
    }
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:22,代码来源:SettingsFragment.java

示例7: updateFlightModeButtons

import com.o3dr.android.client.Drone; //导入依赖的package包/类
private void updateFlightModeButtons() {
    resetFlightModeButtons();

    final Drone drone = getDrone();
    final State droneState = drone.getAttribute(AttributeType.STATE);
    final VehicleMode flightMode = droneState.getVehicleMode();
    if (flightMode != null) {
        switch (flightMode) {
            case PLANE_AUTO:
                autoBtn.setActivated(true);
                break;

            case PLANE_GUIDED:
                final GuidedState guidedState = drone.getAttribute(AttributeType.GUIDED_STATE);
                final FollowState followState = drone.getAttribute(AttributeType.FOLLOW_STATE);
                if (guidedState.isInitialized() && !followState.isEnabled()) {
                    pauseBtn.setActivated(true);
                }
                break;

            case PLANE_RTL:
                homeBtn.setActivated(true);
                break;
        }
    }
}
 
开发者ID:mxiao6,项目名称:Tower-develop,代码行数:27,代码来源:PlaneFlightControlFragment.java

示例8: onApiConnected

import com.o3dr.android.client.Drone; //导入依赖的package包/类
@Override
public void onApiConnected() {
    Drone drone = dpApp.getDrone();
    State droneState = drone.getState();
    Type droneType = drone.getType();
    final int mavlinkVersion = droneState == null
            ? State.INVALID_MAVLINK_VERSION
            : droneState.getMavlinkVersion();

    if (mavlinkVersion != State.INVALID_MAVLINK_VERSION) {
        updateMavlinkVersionPreference(String.valueOf(mavlinkVersion));
    } else {
        updateMavlinkVersionPreference(null);
    }

    String firmwareVersion = droneType == null ? null : droneType.getFirmwareVersion();
    updateFirmwareVersionPreference(firmwareVersion);

    LocalBroadcastManager.getInstance(getActivity().getApplicationContext()).registerReceiver(
            broadcastReceiver, intentFilter);
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:22,代码来源:SettingsFragment.java

示例9: onGuidedClick

import com.o3dr.android.client.Drone; //导入依赖的package包/类
@Override
public void onGuidedClick(LatLong coord) {
    final Drone drone = getDrone();
    final FollowState followState = drone.getAttribute(AttributeType.FOLLOW_STATE);
    if (followState != null && followState.isEnabled() && followState.getMode().hasParam(FollowType.EXTRA_FOLLOW_ROI_TARGET)) {
        Toast.makeText(getContext(), R.string.guided_scan_roi_set_message, Toast.LENGTH_LONG).show();

        final double roiHeight = roiHeightWheel.getCurrentValue().toBase().getValue();
        final LatLongAlt roiCoord = new LatLongAlt(coord.getLatitude(), coord.getLongitude(), roiHeight);

        pushROITargetToVehicle(drone, roiCoord);
        updateROITargetMarker(coord);
    } else {
        super.onGuidedClick(coord);
    }
}
 
开发者ID:mxiao6,项目名称:Tower-develop,代码行数:17,代码来源:ModeFollowFragment.java

示例10: writeModifiedParametersToDrone

import com.o3dr.android.client.Drone; //导入依赖的package包/类
private void writeModifiedParametersToDrone() {
    final Drone drone = getDrone();
    if (!drone.isConnected())
        return;

    final int adapterCount = adapter.getCount();
    List<Parameter> parametersList = new ArrayList<Parameter>(adapterCount);
    for (int i = 0; i < adapterCount; i++) {
        final ParamsAdapterItem item = adapter.getItem(i);
        if (!item.isDirty())
            continue;

        parametersList.add(item.getParameter());
        item.commit();
    }

    final int parametersCount = parametersList.size();
    if (parametersCount > 0) {
        VehicleApi.getApi(drone).writeParameters(new Parameters(parametersList));
        adapter.notifyDataSetChanged();
        Toast.makeText(getActivity(),
                parametersCount + " " + getString(R.string.msg_parameters_written_to_drone),
                Toast.LENGTH_SHORT).show();
    }
    snackbar = null;
}
 
开发者ID:mxiao6,项目名称:Tower-develop,代码行数:27,代码来源:ParamsFragment.java

示例11: updateFlightModeButtons

import com.o3dr.android.client.Drone; //导入依赖的package包/类
private void updateFlightModeButtons() {
	resetFlightModeButtons();

	final Drone drone = getDrone();
	final VehicleMode flightMode = drone.getState().getVehicleMode();
       if(flightMode != null) {
           switch (flightMode) {
               case PLANE_AUTO:
                   autoBtn.setActivated(true);
                   break;

               case PLANE_GUIDED:
                   if (drone.getGuidedState().isInitialized() && !drone.getFollowState().isEnabled()) {
                       pauseBtn.setActivated(true);
                   }
                   break;

               case PLANE_RTL:
                   homeBtn.setActivated(true);
                   break;
           }
       }
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:24,代码来源:PlaneFlightActionsFragment.java

示例12: getDroneVariable

import com.o3dr.android.client.Drone; //导入依赖的package包/类
protected void getDroneVariable(Drone mDrone, CheckListItem mListItem) {
	String sys_tag = mListItem.getSys_tag();

       final Battery droneBattery = mDrone.getAttribute(AttributeType.BATTERY);
	if (sys_tag.equalsIgnoreCase("SYS_BATTREM_LVL")) {
		mListItem.setSys_value(droneBattery.getBatteryRemain());
	} else if (sys_tag.equalsIgnoreCase("SYS_BATTVOL_LVL")) {
		mListItem.setSys_value(droneBattery.getBatteryVoltage());
	} else if (sys_tag.equalsIgnoreCase("SYS_BATTCUR_LVL")) {
		mListItem.setSys_value(droneBattery.getBatteryCurrent());
	}

       final Gps droneGps = mDrone.getAttribute(AttributeType.GPS);
       if (sys_tag.equalsIgnoreCase("SYS_GPS3D_LVL")) {
		mListItem.setSys_value(droneGps.getSatellitesCount());
	}

       final State droneState = mDrone.getAttribute(AttributeType.STATE);
       if (sys_tag.equalsIgnoreCase("SYS_ARM_STATE")) {
		mListItem.setSys_activated(droneState.isArmed());
	} else if (sys_tag.equalsIgnoreCase("SYS_FAILSAFE_STATE")) {
		mListItem.setSys_activated(droneState.isWarning());
	} else if (sys_tag.equalsIgnoreCase("SYS_CONNECTION_STATE")) {
		mListItem.setSys_activated(droneState.isConnected());
	}
}
 
开发者ID:mxiao6,项目名称:Tower-develop,代码行数:27,代码来源:ListRow.java

示例13: initItemView

import com.o3dr.android.client.Drone; //导入依赖的package包/类
@Override
protected void initItemView(Context context, View parentView, Drone drone) {
	super.initItemView(context, parentView, drone);
	if (mItemView == null)
		return;

	mPopup = initPopupWindow(context, sPopupWindowLayoutId);

	final View popupView = mPopup.getContentView();
	currentView = (TextView) popupView.findViewById(R.id.bar_power_current);
	mAhView = (TextView) popupView.findViewById(R.id.bar_power_mAh);

	mItemView.setOnClickListener(new View.OnClickListener() {
		@Override
		public void onClick(View v) {
			if (mPopup == null)
				return;

			mPopup.showAsDropDown(mItemView);
		}
	});

	updateItemView(context, drone);
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:25,代码来源:InfoBarItem.java

示例14: goToDroneLocation

import com.o3dr.android.client.Drone; //导入依赖的package包/类
@Override
public void goToDroneLocation() {
    Drone dpApi = getDroneApi();
    if (!dpApi.isConnected())
        return;

    Gps gps = dpApi.getAttribute(AttributeType.GPS);
    if (!gps.isValid()) {
        Toast.makeText(getActivity().getApplicationContext(),
                R.string.drone_no_location, Toast.LENGTH_SHORT).show();
        return;
    }

    final float currentZoomLevel = getBaiduMap().getMapStatus().zoom;
    final LatLong droneLocation = gps.getPosition();
    updateCamera(droneLocation, (int) currentZoomLevel);
}
 
开发者ID:mxiao6,项目名称:Tower-develop,代码行数:18,代码来源:BaiduMapFragment.java

示例15: setDrone

import com.o3dr.android.client.Drone; //导入依赖的package包/类
/**
 * This is used to update the current drone state.
 * 
 * @param drone
 */
public void setDrone(Drone drone) {
       LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(mContext);
       if(drone == null) {
           if(mDrone != null) {
               lbm.unregisterReceiver(eventReceiver);
               updateInfoBar();
           }
       }
       else {
           updateInfoBar();
           lbm.registerReceiver(eventReceiver, eventFilter);
       }

       mDrone = drone;
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:21,代码来源:InfoBarActionProvider.java


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