Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ private ErrorType(@StringRes int labelResId){
}

public CharSequence getLabel(Context context){
if(context == null)
return null;

return context.getText(this.labelResId);
}

Expand Down
2 changes: 1 addition & 1 deletion ServiceApp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies {
compile 'com.android.support:cardview-v7:21.0.0'
compile 'com.android.support:recyclerview-v7:21.0.2'

compile files('libs/j2xx.jar')
compile files('libs/d2xx.jar')
compile files('libs/jeromq-0.3.4.jar')
compile files('libs/droneapi-java.jar')
compile files('libs/protobuf-java-2.5.0.jar')
Expand Down
Binary file removed ServiceApp/libs/android-support-v4.jar
Binary file not shown.
Binary file added ServiceApp/libs/d2xx.jar
Binary file not shown.
Binary file removed ServiceApp/libs/j2xx.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ public DroneAttribute getAttribute(String attributeType) {

default:
final DroneAttribute droneAttribute = drone.getAttribute(attributeType);
if(drone instanceof ArduSolo && isCompanionComputerEnabled() && droneAttribute instanceof State){
if(drone instanceof ArduSolo && droneAttribute instanceof State){
final State droneState = (State) droneAttribute;
droneState.addToVehicleUid("solo_mac_address", soloComp.getSoloMacAddress());
droneState.addToVehicleUid("controller_mac_address", soloComp.getControllerMacAddress());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
import org.droidplanner.services.android.core.parameters.Parameter;
import org.droidplanner.services.android.utils.CommonApiUtils;

import java.util.HashMap;
import java.util.Map;

/**
* Base class for the ArduPilot autopilots
*/
Expand Down Expand Up @@ -108,6 +111,11 @@ public abstract class ArduPilot extends GenericMavLinkDrone {

private final Context context;

/**
* Used to store parameter metadata since it's expensive to load that metadata from the xml assets file.
*/
private final Map<String, com.o3dr.services.android.lib.drone.property.Parameter> cachedParameters = new HashMap<>();

public ArduPilot(Context context, MAVLinkStreams.MAVLinkOutputStream mavClient,
DroneInterfaces.Handler handler, Preferences pref, AutopilotWarningParser warningParser,
LogMessageListener logListener, DroneInterfaces.AttributeEventListener listener) {
Expand Down Expand Up @@ -280,7 +288,7 @@ public DroneAttribute getAttribute(String attributeType) {
return CommonApiUtils.getGps(this);

case AttributeType.PARAMETERS:
return CommonApiUtils.getParameters(this, context);
return CommonApiUtils.getParameters(this, context, cachedParameters);

case AttributeType.HOME:
return CommonApiUtils.getHome(this);
Expand Down Expand Up @@ -481,7 +489,7 @@ public void onTimeout() {
case GimbalActions.ACTION_SET_GIMBAL_MOUNT_MODE:
final int mountMode = data.getInt(GimbalActions.GIMBAL_MOUNT_MODE, MAV_MOUNT_MODE.MAV_MOUNT_MODE_MAVLINK_TARGETING);

Parameter mountParam = getParameters().getParameter("MNT_MODE");
Parameter mountParam = this.parameters.getParameter("MNT_MODE");
if (mountParam == null) {
msg_mount_configure msg = new msg_mount_configure();
msg.target_system = getSysid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class VideoManager extends AbstractLinkManager {
private final MediaCodecManager mediaCodecManager;

VideoManager(Context context, Handler handler, ExecutorService asyncExecutor) {
super(context, new UdpConnection(handler, ControllerLinkManager.ARTOO_UDP_PORT, UDP_BUFFER_SIZE, true, 42), handler, asyncExecutor);
super(context, new UdpConnection(handler, ControllerLinkManager.ARTOO_UDP_PORT, UDP_BUFFER_SIZE, true, 16), handler, asyncExecutor);
this.mediaCodecManager = new MediaCodecManager(handler);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,6 @@ public String getValue() {
return format.format(value);
}

public static void checkParameterName(String name) throws Exception {
if (name.equals("SYSID_SW_MREV")) {
throw new Exception("ExludedName");
} else if (name.contains("WP_TOTAL")) {
throw new Exception("ExludedName");
} else if (name.contains("CMD_TOTAL")) {
throw new Exception("ExludedName");
} else if (name.contains("FENCE_TOTAL")) {
throw new Exception("ExludedName");
} else if (name.contains("SYS_NUM_RESETS")) {
throw new Exception("ExludedName");
} else if (name.contains("ARSPD_OFFSET")) {
throw new Exception("ExludedName");
} else if (name.contains("GND_ABS_PRESS")) {
throw new Exception("ExludedName");
} else if (name.contains("GND_TEMP")) {
throw new Exception("ExludedName");
} else if (name.contains("CMD_INDEX")) {
throw new Exception("ExludedName");
} else if (name.contains("LOG_LASTFILE")) {
throw new Exception("ExludedName");
} else if (name.contains("FORMAT_VERSION")) {
throw new Exception("ExludedName");
} else {
}
}

public static DecimalFormat getFormat() {
return format;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,35 +415,45 @@ public static State getState(MavLinkDrone drone, boolean isConnected, Vibration
vibration);
}

public static Parameters getParameters(MavLinkDrone drone, Context context) {
public static Parameters getParameters(MavLinkDrone drone, Context context, Map<String, Parameter> cachedParameters) {
if (drone == null)
return new Parameters();

final Map<String, Parameter> proxyParams = new HashMap<>();
final Map<String, Parameter> incompleteParams = new HashMap<>();
final List<Parameter> parametersList = new ArrayList<>();

Map<String, org.droidplanner.services.android.core.parameters.Parameter> droneParameters = drone.getParameters().getParameters();
if (!droneParameters.isEmpty()) {
for (org.droidplanner.services.android.core.parameters.Parameter param : droneParameters.values()) {
if (param.name != null) {
proxyParams.put(param.name, new com.o3dr.services.android.lib.drone.property
.Parameter(param.name, param.value, param.type));
Parameter cachedParam = cachedParameters.get(param.name);
if (cachedParam == null) {
cachedParam = new Parameter(param.name, param.value, param.type);
incompleteParams.put(param.name, cachedParam);
cachedParameters.put(param.name, cachedParam);
}else {
cachedParam.setValue(param.value);
cachedParam.setType(param.type);
}

parametersList.add(cachedParam);
}
}

try {
final VehicleProfile profile = drone.getVehicleProfile();
if (profile != null) {
final VehicleProfile profile = drone.getVehicleProfile();
if (!incompleteParams.isEmpty() && profile != null) {
try {
String metadataType = profile.getParameterMetadataType();
if (metadataType != null) {
ParameterMetadataLoader.load(context, metadataType, proxyParams);
ParameterMetadataLoader.load(context, metadataType, incompleteParams);
}
} catch (IOException | XmlPullParserException e) {
Timber.e(e, e.getMessage());
}
} catch (IOException | XmlPullParserException e) {
Timber.e(e, e.getMessage());
}
}

return new Parameters(new ArrayList<>(proxyParams.values()));
return new Parameters(new ArrayList<>(parametersList));
}

public static float fromRadToDeg(float rad) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
* Created by Fredia Huya-Kouadio on 2/5/15.
*/
public class AppsUpdateReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(RecommendedAppsFragment
.ACTION_REFRESH_RECOMMENDED_APPS));
LocalBroadcastManager.getInstance(context)
.sendBroadcast(new Intent(RecommendedAppsFragment.ACTION_REFRESH_RECOMMENDED_APPS));
}
}
18 changes: 9 additions & 9 deletions dependencyLibs/Mavlink/src/com/MAVLink/MAVLinkPacket.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class MAVLinkPacket implements Serializable {
/**
* Message length. NOT counting STX, LENGTH, SEQ, SYSID, COMPID, MSGID, CRC1 and CRC2
*/
public int len;
public final int len;

/**
* Message sequence
Expand Down Expand Up @@ -80,18 +80,16 @@ public class MAVLinkPacket implements Serializable {
*/
public CRC crc;

public MAVLinkPacket(){
payload = new MAVLinkPayload();
public MAVLinkPacket(int payloadLength){
this.len = payloadLength;
payload = new MAVLinkPayload(payloadLength);
}

/**
* Check if the size of the Payload is equal to the "len" byte
*/
public boolean payloadIsFilled() {
if (payload.size() >= MAVLinkPayload.MAX_PAYLOAD_SIZE-1) {
return true;
}
return (payload.size() == len);
return payload.size() >= len;
}

/**
Expand All @@ -113,7 +111,8 @@ public void generateCRC(){

payload.resetIndex();

for (int i = 0; i < payload.size(); i++) {
final int payloadSize = payload.size();
for (int i = 0; i < payloadSize; i++) {
crc.update_checksum(payload.getByte());
}
crc.finish_checksum(msgid);
Expand All @@ -135,7 +134,8 @@ public byte[] encodePacket() {
buffer[i++] = (byte) compid;
buffer[i++] = (byte) msgid;

for (int j = 0; j < payload.size(); j++) {
final int payloadSize = payload.size();
for (int j = 0; j < payloadSize; j++) {
buffer[i++] = payload.payload.get(j);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ public class MAVLinkPayload {

private static final long UNSIGNED_LONG_MIN_VALUE = 0;

public static final int MAX_PAYLOAD_SIZE = 512;

public final ByteBuffer payload;
public int index;

public MAVLinkPayload() {
payload = ByteBuffer.allocate(MAX_PAYLOAD_SIZE);
public MAVLinkPayload(int payloadSize) {
//Payload size should be less than 512.
payload = ByteBuffer.allocate(payloadSize);
}

public ByteBuffer getData() {
Expand Down
5 changes: 2 additions & 3 deletions dependencyLibs/Mavlink/src/com/MAVLink/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ enum MAV_states {

MAV_states state = MAV_states.MAVLINK_PARSE_STATE_UNINIT;

static boolean msg_received;
private boolean msg_received;

public MAVLinkStats stats = new MAVLinkStats();
private MAVLinkPacket m;
Expand All @@ -43,7 +43,6 @@ public MAVLinkPacket mavlink_parse_char(int c) {

if (c == MAVLinkPacket.MAVLINK_STX) {
state = MAV_states.MAVLINK_PARSE_STATE_GOT_STX;
m = new MAVLinkPacket();
}
break;

Expand All @@ -52,7 +51,7 @@ public MAVLinkPacket mavlink_parse_char(int c) {
msg_received = false;
state = MAV_states.MAVLINK_PARSE_STATE_IDLE;
} else {
m.len = c;
m = new MAVLinkPacket(c);
state = MAV_states.MAVLINK_PARSE_STATE_GOT_LENGTH;
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public class msg_ahrs extends MAVLinkMessage{
* @return
*/
public MAVLinkPacket pack(){
MAVLinkPacket packet = new MAVLinkPacket();
packet.len = MAVLINK_MSG_LENGTH;
MAVLinkPacket packet = new MAVLinkPacket(MAVLINK_MSG_LENGTH);
packet.sysid = 255;
packet.compid = 190;
packet.msgid = MAVLINK_MSG_ID_AHRS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public class msg_ahrs2 extends MAVLinkMessage{
* @return
*/
public MAVLinkPacket pack(){
MAVLinkPacket packet = new MAVLinkPacket();
packet.len = MAVLINK_MSG_LENGTH;
MAVLinkPacket packet = new MAVLinkPacket(MAVLINK_MSG_LENGTH);
packet.sysid = 255;
packet.compid = 190;
packet.msgid = MAVLINK_MSG_ID_AHRS2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ public class msg_ahrs3 extends MAVLinkMessage{
* @return
*/
public MAVLinkPacket pack(){
MAVLinkPacket packet = new MAVLinkPacket();
packet.len = MAVLINK_MSG_LENGTH;
MAVLinkPacket packet = new MAVLinkPacket(MAVLINK_MSG_LENGTH);
packet.sysid = 255;
packet.compid = 190;
packet.msgid = MAVLINK_MSG_ID_AHRS3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public class msg_airspeed_autocal extends MAVLinkMessage{
* @return
*/
public MAVLinkPacket pack(){
MAVLinkPacket packet = new MAVLinkPacket();
packet.len = MAVLINK_MSG_LENGTH;
MAVLinkPacket packet = new MAVLinkPacket(MAVLINK_MSG_LENGTH);
packet.sysid = 255;
packet.compid = 190;
packet.msgid = MAVLINK_MSG_ID_AIRSPEED_AUTOCAL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public class msg_ap_adc extends MAVLinkMessage{
* @return
*/
public MAVLinkPacket pack(){
MAVLinkPacket packet = new MAVLinkPacket();
packet.len = MAVLINK_MSG_LENGTH;
MAVLinkPacket packet = new MAVLinkPacket(MAVLINK_MSG_LENGTH);
packet.sysid = 255;
packet.compid = 190;
packet.msgid = MAVLINK_MSG_ID_AP_ADC;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public class msg_autopilot_version_request extends MAVLinkMessage{
* @return
*/
public MAVLinkPacket pack(){
MAVLinkPacket packet = new MAVLinkPacket();
packet.len = MAVLINK_MSG_LENGTH;
MAVLinkPacket packet = new MAVLinkPacket(MAVLINK_MSG_LENGTH);
packet.sysid = 255;
packet.compid = 190;
packet.msgid = MAVLINK_MSG_ID_AUTOPILOT_VERSION_REQUEST;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public class msg_battery2 extends MAVLinkMessage{
* @return
*/
public MAVLinkPacket pack(){
MAVLinkPacket packet = new MAVLinkPacket();
packet.len = MAVLINK_MSG_LENGTH;
MAVLinkPacket packet = new MAVLinkPacket(MAVLINK_MSG_LENGTH);
packet.sysid = 255;
packet.compid = 190;
packet.msgid = MAVLINK_MSG_ID_BATTERY2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ public class msg_camera_feedback extends MAVLinkMessage{
* @return
*/
public MAVLinkPacket pack(){
MAVLinkPacket packet = new MAVLinkPacket();
packet.len = MAVLINK_MSG_LENGTH;
MAVLinkPacket packet = new MAVLinkPacket(MAVLINK_MSG_LENGTH);
packet.sysid = 255;
packet.compid = 190;
packet.msgid = MAVLINK_MSG_ID_CAMERA_FEEDBACK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ public class msg_camera_status extends MAVLinkMessage{
* @return
*/
public MAVLinkPacket pack(){
MAVLinkPacket packet = new MAVLinkPacket();
packet.len = MAVLINK_MSG_LENGTH;
MAVLinkPacket packet = new MAVLinkPacket(MAVLINK_MSG_LENGTH);
packet.sysid = 255;
packet.compid = 190;
packet.msgid = MAVLINK_MSG_ID_CAMERA_STATUS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public class msg_compassmot_status extends MAVLinkMessage{
* @return
*/
public MAVLinkPacket pack(){
MAVLinkPacket packet = new MAVLinkPacket();
packet.len = MAVLINK_MSG_LENGTH;
MAVLinkPacket packet = new MAVLinkPacket(MAVLINK_MSG_LENGTH);
packet.sysid = 255;
packet.compid = 190;
packet.msgid = MAVLINK_MSG_ID_COMPASSMOT_STATUS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public class msg_data16 extends MAVLinkMessage{
* @return
*/
public MAVLinkPacket pack(){
MAVLinkPacket packet = new MAVLinkPacket();
packet.len = MAVLINK_MSG_LENGTH;
MAVLinkPacket packet = new MAVLinkPacket(MAVLINK_MSG_LENGTH);
packet.sysid = 255;
packet.compid = 190;
packet.msgid = MAVLINK_MSG_ID_DATA16;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public class msg_data32 extends MAVLinkMessage{
* @return
*/
public MAVLinkPacket pack(){
MAVLinkPacket packet = new MAVLinkPacket();
packet.len = MAVLINK_MSG_LENGTH;
MAVLinkPacket packet = new MAVLinkPacket(MAVLINK_MSG_LENGTH);
packet.sysid = 255;
packet.compid = 190;
packet.msgid = MAVLINK_MSG_ID_DATA32;
Expand Down
Loading