當前位置: 首頁>>代碼示例>>Java>>正文


Java VehicleApi類代碼示例

本文整理匯總了Java中com.o3dr.android.client.apis.VehicleApi的典型用法代碼示例。如果您正苦於以下問題:Java VehicleApi類的具體用法?Java VehicleApi怎麽用?Java VehicleApi使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


VehicleApi類屬於com.o3dr.android.client.apis包,在下文中一共展示了VehicleApi類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTakeOffInAutoConfirmation

import com.o3dr.android.client.apis.VehicleApi; //導入依賴的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

示例2: writeModifiedParametersToDrone

import com.o3dr.android.client.apis.VehicleApi; //導入依賴的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

示例3: armDrone

import com.o3dr.android.client.apis.VehicleApi; //導入依賴的package包/類
public void armDrone() {

        // Arm the drone
        VehicleApi.getApi(this.drone).arm(true, false, new SimpleCommandListener() {

            // On successful arming let's takeoff
            @Override
            public void onSuccess() {
                takeOff();
            }

            @Override
            public void onError(int executionError) {
                showToast("Error arming");
            }

            @Override
            public void onTimeout() {
                showToast("Arming timed out");
            }

        });

    }
 
開發者ID:dbaldwin,項目名稱:DronePan-Solo,代碼行數:25,代碼來源:MainActivity.java

示例4: onFlightModeSelected

import com.o3dr.android.client.apis.VehicleApi; //導入依賴的package包/類
public void onFlightModeSelected(View view) {
    VehicleMode vehicleMode = (VehicleMode) this.modeSelector.getSelectedItem();

    VehicleApi.getApi(this.drone).setVehicleMode(vehicleMode, new AbstractCommandListener() {
        @Override
        public void onSuccess() {
            alertUser("Vehicle mode change successful.");
        }

        @Override
        public void onError(int executionError) {
            alertUser("Vehicle mode change failed: " + executionError);
        }

        @Override
        public void onTimeout() {
            alertUser("Vehicle mode change timed out.");
        }
    });
}
 
開發者ID:3drobotics,項目名稱:DroneKit-Android-Starter,代碼行數:21,代碼來源:MainActivity.java

示例5: getArmingConfirmation

import com.o3dr.android.client.apis.VehicleApi; //導入依賴的package包/類
private void getArmingConfirmation() {
    SlideToUnlockDialog unlockDialog = SlideToUnlockDialog.newInstance("arm", new Runnable() {
        @Override
        public void run() {
            VehicleApi.getApi(getDrone()).arm(true);
        }
    });
    unlockDialog.show(getChildFragmentManager(), "Slide To Arm");
}
 
開發者ID:mxiao6,項目名稱:Tower-develop,代碼行數:10,代碼來源:CopterFlightControlFragment.java

示例6: onClick

import com.o3dr.android.client.apis.VehicleApi; //導入依賴的package包/類
@Override
public void onClick(View v) {
    final Drone drone = getDrone();
    HitBuilders.EventBuilder eventBuilder = new HitBuilders.EventBuilder()
            .setCategory(GAUtils.Category.FLIGHT);

    switch (v.getId()) {
        case R.id.mc_connectBtn:
            ((SuperUI) getActivity()).toggleDroneConnection();
            break;

        case R.id.mc_homeBtn:
            VehicleApi.getApi(drone).setVehicleMode(VehicleMode.ROVER_RTL);
            eventBuilder.setAction(ACTION_FLIGHT_ACTION_BUTTON).setLabel(VehicleMode.ROVER_RTL.getLabel());
            break;

        case R.id.mc_pause: {
            VehicleApi.getApi(drone).setVehicleMode(VehicleMode.ROVER_HOLD);
            eventBuilder.setAction(ACTION_FLIGHT_ACTION_BUTTON).setLabel(VehicleMode.ROVER_HOLD.getLabel());
            break;
        }

        case R.id.mc_autoBtn:
            VehicleApi.getApi(drone).setVehicleMode(VehicleMode.ROVER_AUTO);
            eventBuilder.setAction(ACTION_FLIGHT_ACTION_BUTTON).setLabel(VehicleMode.ROVER_AUTO.getLabel());
            break;

        default:
            eventBuilder = null;
            break;
    }

    if (eventBuilder != null) {
        GAUtils.sendEvent(eventBuilder);
    }
}
 
開發者ID:mxiao6,項目名稱:Tower-develop,代碼行數:37,代碼來源:RoverFlightControlFragment.java

示例7: refreshParameters

import com.o3dr.android.client.apis.VehicleApi; //導入依賴的package包/類
private void refreshParameters() {
    if (getDrone().isConnected()) {
        VehicleApi.getApi(getDrone()).refreshParameters();
    } else {
        Toast.makeText(getActivity(), R.string.msg_connect_first, Toast.LENGTH_SHORT).show();
    }
}
 
開發者ID:mxiao6,項目名稱:Tower-develop,代碼行數:8,代碼來源:ParamsFragment.java

示例8: doSysArm

import com.o3dr.android.client.apis.VehicleApi; //導入依賴的package包/類
private void doSysArm(CheckListItem checkListItem) {
       final State droneState = drone.getAttribute(AttributeType.STATE);
	if (droneState.isConnected()) {
		if (checkListItem.isSys_activated() && !droneState.isArmed()) {
			VehicleApi.getApi(drone).arm(true);
		} else {
			VehicleApi.getApi(drone).arm(false);
		}
	}
}
 
開發者ID:mxiao6,項目名稱:Tower-develop,代碼行數:11,代碼來源:CheckListSysLink.java

示例9: setupPano

import com.o3dr.android.client.apis.VehicleApi; //導入依賴的package包/類
private void setupPano() {

        totalPhotoCount = 0;
        panoProgressBar.setProgress(totalPhotoCount);
        panoInProgress = true;

        // Change start button to stop button
        panoButton.setText("Stop");

        // Set copter to guided
        VehicleApi.getApi(this.drone).setVehicleMode(VehicleMode.COPTER_GUIDED, new SimpleCommandListener() {
            @Override
            public void onSuccess() {
            }
        });

        // Enable gimbal control
        GimbalApi.getApi(this.drone).startGimbalControl(gimbalListener);

        // Reset gimbal to 0
        pitchGimbal(0);

        // Give the gimbal a couple seconds to reset and begin pano
        final Handler h = new Handler();

        final Runnable begin = new Runnable() {

            @Override
            public void run() {
                loopAndShoot(); // Let's begin the pano process
            }
        };

        h.postDelayed(begin, 3000);

    }
 
開發者ID:dbaldwin,項目名稱:DronePan-Solo,代碼行數:37,代碼來源:MainActivity.java

示例10: onClick

import com.o3dr.android.client.apis.VehicleApi; //導入依賴的package包/類
@Override
public void onClick(View v) {
    HitBuilders.EventBuilder eventBuilder = new HitBuilders.EventBuilder()
            .setCategory(GAUtils.Category.FLIGHT);

    final Drone drone = getDrone();
    switch (v.getId()) {
        case R.id.mc_connectBtn:
            ((SuperUI) getActivity()).toggleDroneConnection();
            break;

        case R.id.mc_armBtn:
            getArmingConfirmation();
            eventBuilder.setAction(ACTION_FLIGHT_ACTION_BUTTON).setLabel("Arm");
            break;

        case R.id.mc_disarmBtn:
            VehicleApi.getApi(drone).arm(false);
            eventBuilder.setAction(ACTION_FLIGHT_ACTION_BUTTON).setLabel("Disarm");
            break;

        case R.id.mc_land:
            VehicleApi.getApi(drone).setVehicleMode(VehicleMode.COPTER_LAND);
            eventBuilder.setAction(ACTION_FLIGHT_ACTION_BUTTON).setLabel(VehicleMode
                    .COPTER_LAND.getLabel());
            break;

        case R.id.mc_takeoff:
            getTakeOffConfirmation();
            eventBuilder.setAction(ACTION_FLIGHT_ACTION_BUTTON).setLabel("Takeoff");
            break;

        case R.id.mc_homeBtn:
            VehicleApi.getApi(drone).setVehicleMode(VehicleMode.COPTER_RTL);
            eventBuilder.setAction(ACTION_FLIGHT_ACTION_BUTTON).setLabel(VehicleMode.COPTER_RTL
                    .getLabel());
            break;

        case R.id.mc_pause: {
            final FollowState followState = drone.getAttribute(AttributeType.FOLLOW_STATE);
            if (followState.isEnabled()) {
                FollowApi.getApi(drone).disableFollowMe();
            }

            ControlApi.getApi(drone).pauseAtCurrentLocation(null);
            eventBuilder.setAction(ACTION_FLIGHT_ACTION_BUTTON).setLabel("Pause");
            break;
        }

        case R.id.mc_autoBtn:
            VehicleApi.getApi(drone).setVehicleMode(VehicleMode.COPTER_AUTO);
            eventBuilder.setAction(ACTION_FLIGHT_ACTION_BUTTON).setLabel(VehicleMode.COPTER_AUTO.getLabel());
            break;

        case R.id.mc_TakeoffInAutoBtn:
            getTakeOffInAutoConfirmation();
            eventBuilder.setAction(ACTION_FLIGHT_ACTION_BUTTON).setLabel(VehicleMode.COPTER_AUTO.getLabel());
            break;

        case R.id.mc_follow:
            toggleFollowMe();
            break;

        case R.id.mc_dronieBtn:
            getDronieConfirmation();
            eventBuilder.setAction(ACTION_FLIGHT_ACTION_BUTTON).setLabel("Dronie uploaded");
            break;

        default:
            eventBuilder = null;
            break;
    }

    if (eventBuilder != null) {
        GAUtils.sendEvent(eventBuilder);
    }

}
 
開發者ID:mxiao6,項目名稱:Tower-develop,代碼行數:79,代碼來源:CopterFlightControlFragment.java

示例11: onClick

import com.o3dr.android.client.apis.VehicleApi; //導入依賴的package包/類
@Override
public void onClick(View v) {
    final Drone drone = getDrone();
    HitBuilders.EventBuilder eventBuilder = new HitBuilders.EventBuilder()
            .setCategory(GAUtils.Category.FLIGHT);

    switch (v.getId()) {
        case R.id.mc_connectBtn:
            ((SuperUI) getActivity()).toggleDroneConnection();
            break;

        case R.id.mc_armBtn:
            getArmingConfirmation();
            eventBuilder.setAction(ACTION_FLIGHT_ACTION_BUTTON).setLabel("Arm");
            break;

        case R.id.mc_disarmBtn:
            VehicleApi.getApi(drone).arm(false);
            eventBuilder.setAction(ACTION_FLIGHT_ACTION_BUTTON).setLabel("Disarm");
            break;

        case R.id.mc_homeBtn:
            VehicleApi.getApi(drone).setVehicleMode(VehicleMode.PLANE_RTL);
            eventBuilder.setAction(ACTION_FLIGHT_ACTION_BUTTON)
                    .setLabel(VehicleMode.PLANE_RTL.getLabel());
            break;

        case R.id.mc_pause: {
            final FollowState followState = drone.getAttribute(AttributeType.FOLLOW_STATE);
            if (followState.isEnabled()) {
                FollowApi.getApi(drone).disableFollowMe();
            }

            ControlApi.getApi(drone).pauseAtCurrentLocation(null);
            eventBuilder.setAction(ACTION_FLIGHT_ACTION_BUTTON).setLabel("Pause");
            break;
        }

        case R.id.mc_TakeoffInAutoBtn:
        case R.id.mc_autoBtn:
            VehicleApi.getApi(drone).setVehicleMode(VehicleMode.PLANE_AUTO);
            eventBuilder.setAction(ACTION_FLIGHT_ACTION_BUTTON).setLabel(VehicleMode.PLANE_AUTO.getLabel());
            break;

        case R.id.mc_follow: {
            toggleFollowMe();
            break;
        }

        default:
            eventBuilder = null;
            break;
    }

    if (eventBuilder != null) {
        GAUtils.sendEvent(eventBuilder);
    }
}
 
開發者ID:mxiao6,項目名稱:Tower-develop,代碼行數:59,代碼來源:PlaneFlightControlFragment.java

示例12: onOptionsItemSelected

import com.o3dr.android.client.apis.VehicleApi; //導入依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    final Drone dpApi = dpApp.getDrone();

    switch (item.getItemId()) {
        case R.id.menu_connect:
            toggleDroneConnection();
            return true;

        case R.id.menu_upload_mission: {
            final MissionProxy missionProxy = dpApp.getMissionProxy();
            if (missionProxy.getItems().isEmpty() || missionProxy.hasTakeoffAndLandOrRTL()) {
                missionProxy.sendMissionToAPM(dpApi);
            } else {
                SupportYesNoWithPrefsDialog dialog = SupportYesNoWithPrefsDialog.newInstance(
                        getApplicationContext(), MISSION_UPLOAD_CHECK_DIALOG_TAG,
                        getString(R.string.mission_upload_title),
                        getString(R.string.mission_upload_message),
                        getString(android.R.string.ok),
                        getString(R.string.label_skip),
                        DroidPlannerPrefs.PREF_AUTO_INSERT_MISSION_TAKEOFF_RTL_LAND, this);

                if (dialog != null) {
                    dialog.show(getSupportFragmentManager(), MISSION_UPLOAD_CHECK_DIALOG_TAG);
                }
            }
            return true;
        }

        case R.id.menu_download_mission:
            MissionApi.getApi(dpApi).loadWaypoints();
            return true;

        case R.id.menu_kill_switch:
            SlideToUnlockDialog unlockDialog = SlideToUnlockDialog.newInstance("disable vehicle", new Runnable() {
                @Override
                public void run() {
                    VehicleApi.getApi(dpApi).arm(false, true, new SimpleCommandListener() {
                        @Override
                        public void onError(int error) {
                            final int errorMsgId;
                            switch(error){
                                case CommandExecutionError.COMMAND_UNSUPPORTED:
                                    errorMsgId = R.string.error_kill_switch_unsupported;
                                    break;

                                default:
                                    errorMsgId = R.string.error_kill_switch_failed;
                                    break;
                            }

                            Toast.makeText(getApplicationContext(), errorMsgId, Toast.LENGTH_LONG).show();
                        }

                        @Override
                        public void onTimeout() {
                            Toast.makeText(getApplicationContext(), R.string.error_kill_switch_failed, Toast.LENGTH_LONG).show();
                        }
                    });
                }
            });
            unlockDialog.show(getSupportFragmentManager(), "Slide to use the Kill Switch");
            return true;

        case android.R.id.home:
            NavUtils.navigateUpFromSameTask(this);
            return true;

        default:
            return super.onOptionsItemSelected(item);
    }
}
 
開發者ID:mxiao6,項目名稱:Tower-develop,代碼行數:73,代碼來源:SuperUI.java

示例13: takeNadirPhotoAndFinishPano

import com.o3dr.android.client.apis.VehicleApi; //導入依賴的package包/類
private void takeNadirPhotoAndFinishPano() {

        final Handler h = new Handler();

        final Runnable pitch = new Runnable() {

            @Override
            public void run() {

                if(Build.MODEL.contains("SDK")) {

                    showToast("Panorama complete!!!");

                } else {

                    pitchGimbal(0);

                    // Change mode back to FLY mode, which is Loiter
                    VehicleApi.getApi(drone).setVehicleMode(VehicleMode.COPTER_LOITER, new SimpleCommandListener() {
                        @Override
                        public void onSuccess() {
                            showToast("Panorama complete! You can now take control of Solo.");
                        }
                    });

                }
            }

        };

        final Runnable finish = new Runnable() {

            @Override
            public void run() {

                if(Build.MODEL.contains("SDK")) {

                    showToast("Taking nadir shot");

                } else {

                    takePhoto();

                }

                h.postDelayed(pitch, 3000);

            }
        };

        h.postDelayed(finish, 3000);

    }
 
開發者ID:dbaldwin,項目名稱:DronePan-Solo,代碼行數:54,代碼來源:MainActivity.java


注:本文中的com.o3dr.android.client.apis.VehicleApi類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。