Commit 29f18cfe authored by kazushi.kawamura's avatar kazushi.kawamura
Browse files

Remove unused files

parent 85a059f8
Loading
Loading
Loading
Loading
+0 −495
Changes for src/com/shigeodayo/ardrone/ARDrone.java~: 0 added lines, 495 removed lines.
Original line number Diff line number Diff line
/**
   ARDroneForP5
   https://github.com/shigeodayo/ARDroneForP5
   Copyright (C) 2013, Shigeo YOSHIDA.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
*/

package com.shigeodayo.ardrone;

import java.awt.image.BufferedImage;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.StringTokenizer;

import com.shigeodayo.ardrone.command.CommandManager;
import com.shigeodayo.ardrone.command.CommandManager1;
import com.shigeodayo.ardrone.command.CommandManager2;
import com.shigeodayo.ardrone.navdata.AttitudeListener;
import com.shigeodayo.ardrone.navdata.BatteryListener;
import com.shigeodayo.ardrone.navdata.DroneState;
import com.shigeodayo.ardrone.navdata.NavDataManager;
import com.shigeodayo.ardrone.navdata.NavDataManager1;
import com.shigeodayo.ardrone.navdata.NavDataManager2;
import com.shigeodayo.ardrone.navdata.StateListener;
import com.shigeodayo.ardrone.navdata.VelocityListener;
import com.shigeodayo.ardrone.utils.ARDroneConstants;
import com.shigeodayo.ardrone.utils.ARDroneInfo;
import com.shigeodayo.ardrone.utils.ARDroneVersion;
import com.shigeodayo.ardrone.video.ImageListener;
import com.shigeodayo.ardrone.video.VideoManager;
import com.shigeodayo.ardrone.video.VideoManager1;
import com.shigeodayo.ardrone.video.VideoManager2;

public class ARDrone implements ARDroneInterface {

	private String ipaddr = null;
	private InetAddress inetaddr = null;

	// managers
	private CommandManager manager = null;
	private VideoManager videoManager = null;
	private NavDataManager navdataManager = null;

	// listeners
	private ImageListener imageListener = null;
	private AttitudeListener attitudeListener = null;
	private BatteryListener batteryListener = null;
	private StateListener stateListener = null;
	private VelocityListener velocityListener = null;

	private ARDroneVersion ardroneVersion = null;

	/** constructor */
	public ARDrone() {
		this(ARDroneConstants.IP_ADDRESS, null);
	}

	/**
	 * constructor
	 * 
	 * @param ipaddr
	 */
	public ARDrone(String ipaddr) {
		this(ipaddr, null);
	}

	/**
	 * constructor
	 * 
	 * @param ardroneVersion
	 */
	public ARDrone(ARDroneVersion ardroneVersion) {
		this(ARDroneConstants.IP_ADDRESS, ardroneVersion);
	}

	/**
	 * constructor
	 * 
	 * @param ipaddr
	 * @param ardroneVersion
	 */
	public ARDrone(String ipaddr, ARDroneVersion ardroneVersion) {
		this.ipaddr = ipaddr;
		this.ardroneVersion = ardroneVersion;
		/*System.out.println("hoge");
		if (ardroneVersion == null)
			ardroneVersion = new ARDroneInfo().getDroneVersion();
		System.out.println("AR.Drone version:" + ardroneVersion);*/
	}


	
	/** connect to AR.Drone */
	@Override
	public boolean connect() {
		return connect(false);
	}

	private boolean connect(boolean useHighRezVideoStreaming) {
		if (inetaddr == null) {
			inetaddr = getInetAddress(ipaddr);
		}
		if (ardroneVersion == null)
			ardroneVersion = new ARDroneInfo().getDroneVersion();			
		
		//System.out.println("(connect) AR.Drone version:" + ardroneVersion);

		if (ardroneVersion == ARDroneVersion.ARDRONE1)
			manager = new CommandManager1(inetaddr, useHighRezVideoStreaming);
		else if (ardroneVersion == ARDroneVersion.ARDRONE2)
			manager = new CommandManager2(inetaddr, useHighRezVideoStreaming);
		else {
			error("Cannot create Control manager", this);
			error("Maybe this is not AR.Drone?", this);
			return false;
		}

		return manager.connect(ARDroneConstants.PORT);
	}

	/** connect video */
	@Override
	public boolean connectVideo() {
		if (inetaddr == null) {
			inetaddr = getInetAddress(ipaddr);
		}
		//System.out.println("(connect video) AR.Drone version:" + ardroneVersion);

		if (ardroneVersion == ARDroneVersion.ARDRONE1) {
			videoManager = new VideoManager1(inetaddr, manager);
		} else if (ardroneVersion == ARDroneVersion.ARDRONE2) {
			videoManager = new VideoManager2(inetaddr, manager);
		} else {
			error("Cannot create Video manager", this);
			error("Maybe this is not AR.Drone?", this);
			return false;
		}

		videoManager.setImageListener(new ImageListener() {
			@Override
			public void imageUpdated(BufferedImage image) {
				if (imageListener != null) {
					imageListener.imageUpdated(image);
				}
			}
		});
		return videoManager.connect(ARDroneConstants.VIDEO_PORT);
	}

	/** connect navdata */
	@Override
	public boolean connectNav() {
		if (inetaddr == null) {
			inetaddr = getInetAddress(ipaddr);
		}
		
		//System.out.println("(connect nav) AR.Drone version:" + ardroneVersion);

		if (ardroneVersion == ARDroneVersion.ARDRONE1) {
			navdataManager = new NavDataManager1(inetaddr, manager);
		} else if (ardroneVersion == ARDroneVersion.ARDRONE2) {
			navdataManager = new NavDataManager2(inetaddr, manager);
		} else {
			error("Cannot create NavData manager", this);
			error("Maybe this is not AR.Drone?", this);
			return false;
		}
		navdataManager.setAttitudeListener(new AttitudeListener() {
			@Override
			public void attitudeUpdated(float pitch, float roll, float yaw,
					int altitude) {
				if (attitudeListener != null) {
					attitudeListener
							.attitudeUpdated(pitch, roll, yaw, altitude);
				}
			}
		});
		navdataManager.setBatteryListener(new BatteryListener() {
			@Override
			public void batteryLevelChanged(int percentage) {
				if (batteryListener != null) {
					batteryListener.batteryLevelChanged(percentage);
				}
			}
		});
		navdataManager.setStateListener(new StateListener() {
			@Override
			public void stateChanged(DroneState state) {
				if (stateListener != null) {
					stateListener.stateChanged(state);
				}
			}
		});
		navdataManager.setVelocityListener(new VelocityListener() {
			@Override
			public void velocityChanged(float vx, float vy, float vz) {
				if (velocityListener != null) {
					velocityListener.velocityChanged(vx, vy, vz);
				}
			}
		});

		return navdataManager.connect(ARDroneConstants.NAV_PORT);
	}

	@Override
	public void disconnect() {
		stop();
		landing();
		manager.close();
		if (videoManager != null)
			videoManager.close();
		if (navdataManager != null)
			navdataManager.close();
	}

	@Override
	public void start() {
		if (manager != null)
			new Thread(manager).start();
		if (videoManager != null)
			new Thread(videoManager).start();
		if (navdataManager != null)
			new Thread(navdataManager).start();
	}

	@Override
	public void setHorizontalCamera() {
		if (manager != null)
			manager.setHorizontalCamera();
	}

	@Override
	public void setVerticalCamera() {
		if (manager != null)
			manager.setVerticalCamera();
	}

	@Override
	public void setHorizontalCameraWithVertical() {
		if (manager != null)
			manager.setHorizontalCameraWithVertical();
	}

	@Override
	public void setVerticalCameraWithHorizontal() {
		if (manager != null)
			manager.setVerticalCameraWithHorizontal();
	}

	@Override
	public void toggleCamera() {
		if (manager != null)
			manager.toggleCamera();
	}

	@Override
	public void landing() {
		if (manager != null)
			manager.landing();
	}

	@Override
	public void takeOff() {
		if (manager != null)
			manager.takeOff();
	}

	@Override
	public void reset() {
		if (manager != null)
			manager.reset();
	}

	@Override
	public void forward() {
		if (manager != null)
			manager.forward();
	}

	@Override
	public void forward(int speed) {
		if (manager != null)
			manager.forward(speed);
	}

	@Override
	public void backward() {
		if (manager != null)
			manager.backward();
	}

	@Override
	public void backward(int speed) {
		if (manager != null)
			manager.backward(speed);
	}

	@Override
	public void spinRight() {
		if (manager != null)
			manager.spinRight();
	}

	@Override
	public void spinRight(int speed) {
		if (manager != null)
			manager.spinRight(speed);
	}

	@Override
	public void spinLeft() {
		if (manager != null)
			manager.spinLeft();
	}

	@Override
	public void spinLeft(int speed) {
		if (manager != null)
			manager.spinLeft(speed);
	}

	@Override
	public void up() {
		if (manager != null)
			manager.up();
	}

	@Override
	public void up(int speed) {
		if (manager != null)
			manager.up(speed);
	}

	@Override
	public void down() {
		if (manager != null)
			manager.down();
	}

	@Override
	public void down(int speed) {
		if (manager != null)
			manager.down(speed);
	}

	@Override
	public void goRight() {
		if (manager != null)
			manager.goRight();
	}

	@Override
	public void goRight(int speed) {
		if (manager != null)
			manager.goRight(speed);
	}

	@Override
	public void goLeft() {
		if (manager != null)
			manager.goLeft();
	}

	@Override
	public void goLeft(int speed) {
		if (manager != null)
			manager.goLeft(speed);
	}

	@Override
	public void setSpeed(int speed) {
		if (manager != null)
			manager.setSpeed(speed);
	}

	@Override
	public void stop() {
		if (manager != null)
			manager.stop();
	}

	/**
	 * 0.01-1.0 -> 1-100%
	 * 
	 * @return 1-100%
	 */
	@Override
	public int getSpeed() {
		if (manager == null)
			return -1;
		return manager.getSpeed();
	}

	@Override
	public void setMaxAltitude(int altitude) {
		if (manager != null)
			manager.setMaxAltitude(altitude);
	}

	@Override
	public void setMinAltitude(int altitude) {
		if (manager != null)
			manager.setMinAltitude(altitude);
	}

	@Override
	public void move3D(int speedX, int speedY, int speedZ, int speedSpin) {
		if (manager != null)
			manager.move3D(speedX, speedY, speedZ, speedSpin);
	}

	// update listeners
	public void addImageUpdateListener(ImageListener imageListener) {
		this.imageListener = imageListener;
	}

	public void addAttitudeUpdateListener(AttitudeListener attitudeListener) {
		this.attitudeListener = attitudeListener;
	}

	public void addBatteryUpdateListener(BatteryListener batteryListener) {
		this.batteryListener = batteryListener;
	}

	public void addStateUpdateListener(StateListener stateListener) {
		this.stateListener = stateListener;
	}

	public void addVelocityUpdateListener(VelocityListener velocityListener) {
		this.velocityListener = velocityListener;
	}

	// remove listeners
	public void removeImageUpdateListener() {
		imageListener = null;
	}

	public void removeAttitudeUpdateListener() {
		attitudeListener = null;
	}

	public void removeBatteryUpdateListener() {
		batteryListener = null;
	}

	public void removeStateUpdateListener() {
		stateListener = null;
	}

	public void removeVelocityUpdateListener() {
		velocityListener = null;
	}

	/**
	 * print error message
	 * 
	 * @param message
	 * @param obj
	 */
	public static void error(String message, Object obj) {
		System.err.println("[" + obj.getClass() + "] " + message);
	}

	private InetAddress getInetAddress(String ipaddr) {
		InetAddress inetaddr = null;
		StringTokenizer st = new StringTokenizer(ipaddr, ".");
		byte[] ipBytes = new byte[4];
		if (st.countTokens() == 4) {
			for (int i = 0; i < 4; i++) {
				ipBytes[i] = (byte) Integer.parseInt(st.nextToken());
			}
		} else {
			error("Incorrect IP address format: " + ipaddr, this);
			return null;
		}
		try {
			inetaddr = InetAddress.getByAddress(ipBytes);
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
		return inetaddr;
	}
}
 No newline at end of file
+0 −97
Changes for src/com/shigeodayo/ardrone/ARDroneInterface.java~: 0 added lines, 97 removed lines.
Original line number Diff line number Diff line
/**
   ARDroneForP5
   https://github.com/shigeodayo/ARDroneForP5
   Copyright (C) 2013, Shigeo YOSHIDA.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
*/

package com.shigeodayo.ardrone;

public interface ARDroneInterface {

	
	// connection
	public boolean connect();

	public boolean connectVideo();

	public boolean connectNav();

	public void disconnect();

	public void start();

	// camera
	public void setHorizontalCamera();// setFrontCameraStreaming()

	public void setVerticalCamera();// setBellyCameraStreaming()

	public void setHorizontalCameraWithVertical();// setFrontCameraWithSmallBellyStreaming()

	public void setVerticalCameraWithHorizontal();// setBellyCameraWithSmallFrontStreaming()

	public void toggleCamera();

	// control command
	public void landing();

	public void takeOff();

	public void reset();

	public void forward();

	public void forward(int speed);

	public void backward();

	public void backward(int speed);

	public void spinRight();

	public void spinRight(int speed);

	public void spinLeft();

	public void spinLeft(int speed);

	public void up();

	public void up(int speed);

	public void down();

	public void down(int speed);

	public void goRight();

	public void goRight(int speed);

	public void goLeft();

	public void goLeft(int speed);

	public void stop();

	public void move3D(int speedX, int speedY, int speedZ, int speedSpin);

	// speed
	public int getSpeed();
	public void setSpeed(int speed);

	// set max altitude
	public void setMaxAltitude(int altitude);
	// set min altitude
	public void setMinAltitude(int altitude);
}
 No newline at end of file
+0 −365
Changes for src/com/shigeodayo/ardrone/command/CommandManager.java~: 0 added lines, 365 removed lines.
Original line number Diff line number Diff line
/**
   ARDroneForP5
   https://github.com/shigeodayo/ARDroneForP5
   Copyright (C) 2013, Shigeo YOSHIDA.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
*/
package com.shigeodayo.ardrone.command;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;

import com.shigeodayo.ardrone.manager.AbstractManager;
import com.shigeodayo.ardrone.utils.ARDroneConstants;

public abstract class CommandManager extends AbstractManager {

	protected static final String CR = "\r";
	protected static final String SEQ = "$SEQ$";

	private static int seq = 1;

	private FloatBuffer fb = null;
	private IntBuffer ib = null;

	private boolean landing = true;
	
	private boolean continuance = false;
	private String command = null;

	/** speed */
	private float speed = 0.05f; // 0.01f - 1.0f

	protected String VIDEO_CODEC;

	public CommandManager(InetAddress inetaddr) {
		this.inetaddr = inetaddr;

		ByteBuffer bb = ByteBuffer.allocate(4);
		fb = bb.asFloatBuffer();
		ib = bb.asIntBuffer();
	}

	public void setHorizontalCamera() {
		command = "AT*CONFIG=" + SEQ + ",\"video:video_channel\",\"0\"";
		continuance = false;
	}

	public void setVerticalCamera() {
		command = "AT*CONFIG=" + SEQ + ",\"video:video_channel\",\"1\"";
		continuance = false;
	}

	public void setHorizontalCameraWithVertical() {
		command = "AT*CONFIG=" + SEQ + ",\"video:video_channel\",\"2\"";
		continuance = false;
	}

	public void setVerticalCameraWithHorizontal() {
		command = "AT*CONFIG=" + SEQ + ",\"video:video_channel\",\"3\"";
		continuance = false;
	}

	public void toggleCamera() {
		command = "AT*CONFIG=" + SEQ + ",\"video:video_channel\",\"4\"";
		continuance = false;
	}

	public void landing() {
		command = "AT*REF=" + SEQ + ",290717696";
		continuance = false;
		landing = true;
		//System.out.println("landing");
	}

	public void takeOff() {
		sendCommand("AT*FTRIM=" + SEQ);
		command = "AT*REF=" + SEQ + ",290718208";
		continuance = false;
		landing = false;
		//System.out.println("take off");
	}

	public void reset() {
		command = "AT*REF=" + SEQ + ",290717952";
		continuance = true;
		landing = true;
	}

	/*public void forward() {
		command = "AT*PCMD=" + SEQ + ",1,0," + intOfFloat(-speed) + ",0,0"
				+ "\r" + "AT*REF=" + SEQ + ",290718208";
		continuance = true;
	}*/

	public void forward(int speed) {
		setSpeed(speed);
		forward();
	}

	public void backward() {
		command = "AT*PCMD=" + SEQ + ",1,0," + intOfFloat(speed) + ",0,0"
				+ "\r" + "AT*REF=" + SEQ + ",290718208";
		continuance = true;
	}

	public void backward(int speed) {
		setSpeed(speed);
		backward();
	}

	public void spinRight() {
		command = "AT*PCMD=" + SEQ + ",1,0,0,0," + intOfFloat(speed) + "\r"
				+ "AT*REF=" + SEQ + ",290718208";
		continuance = true;
	}

	public void spinRight(int speed) {
		setSpeed(speed);
		spinRight();
	}

	public void spinLeft() {
		command = "AT*PCMD=" + SEQ + ",1,0,0,0," + intOfFloat(-speed) + "\r"
				+ "AT*REF=" + SEQ + ",290718208";
		continuance = true;
	}

	public void spinLeft(int speed) {
		setSpeed(speed);
		spinLeft();
	}

	public void up() {
		command = "AT*PCMD=" + SEQ + ",1," + intOfFloat(0) + ","
				+ intOfFloat(0) + "," + intOfFloat(speed) + "," + intOfFloat(0)
				+ "\r" + "AT*REF=" + SEQ + ",290718208";
		continuance = true;
	}

	public void up(int speed) {
		setSpeed(speed);
		up();
	}

	public void down() {
		command = "AT*PCMD=" + SEQ + ",1," + intOfFloat(0) + ","
				+ intOfFloat(0) + "," + intOfFloat(-speed) + ","
				+ intOfFloat(0) + "\r" + "AT*REF=" + SEQ + ",290718208";
		continuance = true;
	}

	public void down(int speed) {
		setSpeed(speed);
		down();
	}

	public void goRight() {
		command = "AT*PCMD=" + SEQ + ",1," + intOfFloat(speed) + ",0,0,0"
				+ "\r" + "AT*REF=" + SEQ + ",290718208";
		continuance = true;
	}

	public void goRight(int speed) {
		setSpeed(speed);
		goRight();
	}

	public void goLeft() {
		command = "AT*PCMD=" + SEQ + ",1," + intOfFloat(-speed) + ",0,0,0"
				+ "\r" + "AT*REF=" + SEQ + ",290718208";
		continuance = true;
	}

	public void goLeft(int speed) {
		setSpeed(speed);
		goLeft();
	}

	public void parallel(int lr,int fb){		//original
		float lr_speed=(float)(lr/100.0);
		float fb_speed=(float)(fb/100.0);

		command = "AT*PCMD=" + SEQ + ",1," + intOfFloat(lr_speed) +","+ intOfFloat(fb_speed) +",0,0"
				+ "\r" + "AT*REF=" + SEQ + ",290718208";
		continuance = true;

	} 




	public void stop() {
		command = "AT*PCMD=" + SEQ + ",1,0,0,0,0";
		continuance = true;
	}

	public void setSpeed(int speed) {
		if (speed > 100)
			speed = 100;
		else if (speed < 1)
			speed = 1;

		this.speed = (float) (speed / 100.0);
	}

	public void enableVideoData() {
		command = "AT*CONFIG=" + SEQ + ",\"general:video_enable\",\"TRUE\""
				+ CR + "AT*FTRIM=" + SEQ;
		continuance = false;
	}

	public void enableDemoData() {
		command = "AT*CONFIG=" + SEQ + ",\"general:navdata_demo\",\"TRUE\""
				+ CR + "AT*FTRIM=" + SEQ;
		continuance = false;
	}

	public void disableBootStrap() {
		command = "AT*CONFIG_IDS=" + SEQ + ",\"" + ARDroneConstants.SESSION_ID
				+ "\",\"" + ARDroneConstants.PROFILE_ID + "\",\""
				+ ARDroneConstants.APPLICATION_ID + "\"" + CR;
	}

	public void sendControlAck() {
		command = "AT*CTRL=" + SEQ + ",0";
		continuance = false;
	}

	public int getSpeed() {
		return (int) (speed * 100);
	}

	public void disableAutomaticVideoBitrate() {
		command = "AT*CONFIG=" + SEQ + ",\"video:bitrate_ctrl_mode\",\"0\"";
		continuance = false;
	}

	public void setMaxAltitude(int altitude) {
		command = "AT*CONFIG=" + SEQ + ",\"control:altitude_max\",\""
				+ altitude + "\"";
		continuance = false;
	}

	public void setMinAltitude(int altitude) {
		command = "AT*CONFIG=" + SEQ + ",\"control:altitude_min\",\""
				+ altitude + "\"";
		continuance = false;
	}

	/*
	 * 
	 */
	public void move3D(int speedX, int speedY, int speedZ, int speedSpin) {
		if (speedX > 100)
			speedX = 100;
		else if (speedX < -100)
			speedX = -100;
		if (speedY > 100)
			speedY = 100;
		else if (speedY < -100)
			speedY = -100;
		if (speedZ > 100)
			speedZ = 100;
		else if (speedZ < -100)
			speedZ = -100;

		command = "AT*PCMD=" + SEQ + ",1," + intOfFloat(-speedY / 100.0f) + ","
				+ intOfFloat(-speedX / 100.0f) + ","
				+ intOfFloat(-speedZ / 100.0f) + ","
				+ intOfFloat(-speedSpin / 100.0f) + "\r" + "AT*REF=" + SEQ
				+ ",290718208";
		continuance = true;
	}

	@Override
	public void run() {
		initializeDrone();
		while (true) {
			if (this.command != null) {
				// sendCommand();
				sendCommand(this.command);
				if (!continuance) {
					command = null;
				}
			} else {
				if (landing) {
					sendCommand("AT*PCMD=" + SEQ + ",1,0,0,0,0" + CR
							+ "AT*REF=" + SEQ + ",290717696");
				} else {
					sendCommand("AT*PCMD=" + SEQ + ",1,0,0,0,0" + CR
							+ "AT*REF=" + SEQ + ",290718208");
				}
			}

			try {
				Thread.sleep(20); // < 50ms
			} catch (InterruptedException e) {
				e.printStackTrace();
			}

			if (seq % 5 == 0) { // < 2000ms
				sendCommand("AT*COMWDG=" + SEQ);
			}

		}
	}

	protected abstract void initializeDrone();

	/*
	 * private void initializeDrone() { sendCommand("AT*CONFIG=" + SEQ +
	 * ",\"general:navdata_demo\",\"TRUE\"" + CR + "AT*FTRIM=" + SEQ); // 1
	 * sendCommand("AT*PMODE=" + SEQ + ",2" + CR + "AT*MISC=" + SEQ +
	 * ",2,20,2000,3000" + CR + "AT*FTRIM=" + SEQ + CR + "AT*REF=" + SEQ +
	 * ",290717696"); // 2-5 sendCommand("AT*PCMD=" + SEQ + ",1,0,0,0,0" + CR +
	 * "AT*REF=" + SEQ + ",290717696" + CR + "AT*COMWDG=" + SEQ); // 6-8
	 * sendCommand("AT*PCMD=" + SEQ + ",1,0,0,0,0" + CR + "AT*REF=" + SEQ +
	 * ",290717696" + CR + "AT*COMWDG=" + SEQ); // 6-8 sendCommand("AT*FTRIM=" +
	 * SEQ); //System.out.println("Initialize completed!"); }
	 */

	/*
	 * Thank you Dirk !! 
	 */
	protected synchronized void sendCommand(String command) {
		int seqIndex = -1;
		while ((seqIndex = command.indexOf(SEQ)) != -1)
			command = command.substring(0, seqIndex) + (seq++)
					+ command.substring(seqIndex + SEQ.length());

		byte[] buffer = (command + CR).getBytes();
		//System.out.println(command);
		DatagramPacket packet = new DatagramPacket(buffer, buffer.length,
				inetaddr, ARDroneConstants.PORT);

		try {
			socket.send(packet);
			 //Thread.sleep(20); // < 50ms
		} catch (IOException e) {
			e.printStackTrace();
		} /*catch (InterruptedException e) {
			e.printStackTrace();
		}*/
	}

	private int intOfFloat(float f) {
		fb.put(0, f);
		return ib.get(0);
	}
}
+0 −1083

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −32
Changes for src/com/shigeodayo/ardrone/video/ImageSlice.java~: 0 added lines, 32 removed lines.
Original line number Diff line number Diff line
package com.shigeodayo.ardrone.video;

//Copyright © 2007-2011, PARROT SA, all rights reserved. 

//DISCLAIMER 
//The APIs is provided by PARROT and contributors "AS IS" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability 
//and fitness for a particular purpose are disclaimed. In no event shall PARROT and contributors be liable for any direct, indirect, incidental, special, exemplary, or 
//consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however 
//caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this 
//software, even if advised of the possibility of such damage. 

//Author            : Daniel Schmidt
//Publishing date   : 2010-01-06 
//based on work by  : Wilke Jansoone

//Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions
//are met:
//- Redistributions of source code must retain the above copyright notice, this list of conditions, the disclaimer and the original author of the source code.
//- Neither the name of the PixVillage Team, nor the names of its contributors may be used to endorse or promote products derived from this software without 
//specific prior written permission.

public class ImageSlice {
	MacroBlock[] MacroBlocks;

	ImageSlice(int macroBlockCount) {
		MacroBlocks = new MacroBlock[macroBlockCount];

		for (int index = 0; index < macroBlockCount; index++) {
			MacroBlocks[index] = new MacroBlock();
		}
	}
}
 No newline at end of file
Loading