Skip to content

Commit

Permalink
UI/settings update
Browse files Browse the repository at this point in the history
  • Loading branch information
mtbii committed May 14, 2016
1 parent cbb47b9 commit 3a70f5e
Show file tree
Hide file tree
Showing 20 changed files with 1,222 additions and 1,320 deletions.
2 changes: 1 addition & 1 deletion src/android_foo/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 1 addition & 28 deletions src/android_foo/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,398 changes: 514 additions & 884 deletions src/android_foo/.idea/workspace.xml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/android_foo/control_app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ dependencies {
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:cardview-v7:23.2.0'
compile 'com.android.support:recyclerview-v7:23.2.0'
compile 'org.osmdroid:osmdroid-android:5.0.1'
compile 'org.slf4j:slf4j-android:1.6.1-RC1'
compile 'com.github.MKergall.osmbonuspack:OSMBonusPack:v5.7'
compile 'org.osmdroid:osmdroid-android:5.2@aar'
compile 'com.github.MKergall:osmbonuspack:v5.8.1'
compile 'com.android.support:support-v4:23.2.0'
compile 'com.github.amlcurran.showcaseview:library:5.4.1'
compile project(':control_app_lib')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class ControlModeTest {

static
{
ControlApp.ROBOT_INFO = new RobotInfo(null, "HUDTestRobotInfo", "HUDMasterURI", null, null, null, null, null, null);
ControlApp.ROBOT_INFO = new RobotInfo(null, "HUDTestRobotInfo", "HUDMasterURI", null, null, null, null, null, null, false, false, false, false);
}

@Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class RobotControllerTest {

static
{
ControlApp.ROBOT_INFO = new RobotInfo(null, "HUDTestRobotInfo", "HUDMasterURI", null, null, null, null, null, null);
ControlApp.ROBOT_INFO = new RobotInfo(null, "HUDTestRobotInfo", "HUDMasterURI", null, null, null, null, null, null, false, false, false, false);
}

@Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class HUDFragmentTest {

static
{
ControlApp.ROBOT_INFO = new RobotInfo(null, "HUDTestRobotInfo", "HUDMasterURI", null, null, null, null, null, null);
ControlApp.ROBOT_INFO = new RobotInfo(null, "HUDTestRobotInfo", "HUDMasterURI", null, null, null, null, null, null, false, false, false, false);
}

private static final String TAG = "HUDFragmentTest";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class RobotChooserTest {

@Before
public void setUp() throws Exception {
robotInfo = new RobotInfo(UUID.randomUUID(), "TestRobotInfo", "TestMasterURI", null, null, null, null, null, null);
robotInfo = new RobotInfo(UUID.randomUUID(), "TestRobotInfo", "TestMasterURI", null, null, null, null, null, null, false, false, false, false);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,14 @@ public void onCreate(Bundle savedInstanceState) {
PreferenceManager.setDefaultValues(this, R.xml.prefs, false);

if (ROBOT_INFO != null) {
editor.putString(getString(R.string.prefs_joystick_topic_edittext_key), ROBOT_INFO.getJoystickTopic());
editor.putString(getString(R.string.prefs_laserscan_topic_edittext_key), ROBOT_INFO.getLaserTopic());
editor.putString(getString(R.string.prefs_camera_topic_edittext_key), ROBOT_INFO.getCameraTopic());
editor.putString(getString(R.string.prefs_navsat_topic_edittext_key), ROBOT_INFO.getNavSatTopic());
editor.putString(getString(R.string.prefs_odometry_topic_edittext_key), ROBOT_INFO.getOdometryTopic());
editor.putString(getString(R.string.prefs_pose_topic_edittext_key), ROBOT_INFO.getPoseTopic());
ROBOT_INFO.save(editor);

// editor.putString(getString(R.string.prefs_joystick_topic_edittext_key), ROBOT_INFO.getJoystickTopic());
// editor.putString(getString(R.string.prefs_laserscan_topic_edittext_key), ROBOT_INFO.getLaserTopic());
// editor.putString(getString(R.string.prefs_camera_topic_edittext_key), ROBOT_INFO.getCameraTopic());
// editor.putString(getString(R.string.prefs_navsat_topic_edittext_key), ROBOT_INFO.getNavSatTopic());
// editor.putString(getString(R.string.prefs_odometry_topic_edittext_key), ROBOT_INFO.getOdometryTopic());
// editor.putString(getString(R.string.prefs_pose_topic_edittext_key), ROBOT_INFO.getPoseTopic());
}

// editor.putBoolean(getString(R.string.prefs_warning_checkbox_key), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,18 @@ public void publishVelocity(double linearVelocityX, double linearVelocityY, doub
Log.e("Emergency Stop", e.getMessage());
}

if(PreferenceManager.getDefaultSharedPreferences(context).getBoolean(context.getString(R.string.prefs_invert_x_axis_key), false)){
linearVelocityX *= -1;
}

if(PreferenceManager.getDefaultSharedPreferences(context).getBoolean(context.getString(R.string.prefs_invert_y_axis_key), false)){
linearVelocityY *= -1;
}

if(PreferenceManager.getDefaultSharedPreferences(context).getBoolean(context.getString(R.string.prefs_invert_angular_velocity_key), false)){
angularVelocityZ *= -1;
}

currentVelocityCommand.getLinear().setX(linearVelocityX * scale);
currentVelocityCommand.getLinear().setY(-linearVelocityY * scale);
currentVelocityCommand.getLinear().setZ(0.0);
Expand Down Expand Up @@ -583,6 +595,18 @@ public LaserScan getLaserScan() {
protected void setLaserScan(LaserScan laserScan) {
synchronized (laserScanMutex) {
this.laserScan = laserScan;

boolean invertLaserScan = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(context.getString(R.string.prefs_reverse_angle_reading_key), false);

if(invertLaserScan) {
float[] ranges = this.laserScan.getRanges();

for (int i = 0; i < this.laserScan.getRanges().length / 2; i++) {
float range = ranges[i];
ranges[i] = ranges[ranges.length - i - 1];
ranges[ranges.length - i - 1] = range;
}
}
}

// Call the listener callbacks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.robotca.ControlApp.Core;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.NonNull;

import java.net.URI;
Expand All @@ -11,11 +13,39 @@
*
* Created by Michael Brunson on 1/23/16.
*/
public class RobotInfo implements Comparable<RobotInfo> {
public class RobotInfo implements Comparable<RobotInfo>, Savable {

// Number of RobotInfos in storage
private static int robotCount = 1;

/** Bundle key for UUID */
public static final String UUID_KEY = "UUID_KEY";
/** Bundle key for robot name */
public static final String ROBOT_NAME_KEY = "ROBOT_NAME_KEY";
/** Bundle key for master URI */
public static final String MASTER_URI_KEY = "MASTER_URI_KEY";
/** Bundle key for joystick topic */
public static final String JOYSTICK_TOPIC_KEY = "JOYSTICK_TOPIC_KEY";
/** Bundle key for laser scan topic */
public static final String LASER_SCAN_TOPIC_KEY = "LASER_SCAN_TOPIC_KEY";
/** Bundle key for camera topic */
public static final String CAMERA_TOPIC_KEY = "CAMERA_TOPIC_KEY";
/** Bundle key for navsat topic */
public static final String NAVSAT_TOPIC_KEY = "NAVSAT_TOPIC_KEY";
/** Bundle key for odometry topic */
public static final String ODOMETRY_TOPIC_KEY = "ODOMETRY_TOPIC_KEY";
/** Bundle key for pose topic */
public static final String POSE_TOPIC_KEY = "POSE_TOPIC_KEY";
/** Bundle key for reverse laser scan */
public static final String REVERSE_LASER_SCAN_KEY = "REVERSE_LASER_SCAN_KEY";
/** Bundle key for invert x-axis */
public static final String INVERT_X_KEY = "INVERT_X_KEY";
/** Bundle key for invert x-axis */
public static final String INVERT_Y_KEY = "INVERT_Y_KEY";
/** Bundle key for invert x-axis */
public static final String INVERT_ANGULAR_VELOCITY_KEY = "INVERT_ANGULAR_VELOCITY_KEY";


// UUID for this RobotInfo
private UUID id = UUID.randomUUID();

Expand All @@ -31,6 +61,10 @@ public class RobotInfo implements Comparable<RobotInfo> {
private String navsatTopic;
private String odometryTopic;
private String poseTopic;
private boolean reverseLaserScan;
private boolean invertX;
private boolean invertY;
private boolean invertAngularVelocity;

@SuppressWarnings("unused")
private static final String TAG = "RobotInfo";
Expand All @@ -47,7 +81,11 @@ public RobotInfo() {
laserTopic = "/scan";
navsatTopic = "/navsat/fix";
odometryTopic = "/odometry/filtered";
poseTopic = "/pose/";
poseTopic = "/pose";
reverseLaserScan = false;
invertX = false;
invertY = false;
invertAngularVelocity = false;
}

// public RobotInfo(String mName, String mMasterUri) {
Expand All @@ -65,7 +103,9 @@ public RobotInfo() {
* @param cameraTopic CameraTopic name for this RobotInfo
*/
public RobotInfo(UUID id, String name, String masterUriString, String joystickTopic,
String laserTopic, String cameraTopic,String navsatTopic, String odometryTopic, String poseTopic) {
String laserTopic, String cameraTopic,String navsatTopic,
String odometryTopic, String poseTopic, boolean reverseLaserScan,
boolean invertX, boolean invertY, boolean invertAngularVelocity) {
this.id = id;
this.name = name;
this.masterUriString = masterUriString;
Expand All @@ -75,6 +115,10 @@ public RobotInfo(UUID id, String name, String masterUriString, String joystickTo
this.navsatTopic = navsatTopic;
this.odometryTopic = odometryTopic;
this.poseTopic = poseTopic;
this.reverseLaserScan = reverseLaserScan;
this.invertX = invertX;
this.invertY = invertY;
this.invertAngularVelocity = invertAngularVelocity;
}

/**
Expand Down Expand Up @@ -215,6 +259,66 @@ public URI getUri(){
return URI.create(getMasterUri());
}

/**
* @return If laser scan should be reversed
*/
public boolean isReverseLaserScan() {
return reverseLaserScan;
}

/**
* Sets whether the laser scan should be reversed
* @param reverseLaserScan Reverse if true, false otherwise
*/
public void setReverseLaserScan(boolean reverseLaserScan) {
this.reverseLaserScan = reverseLaserScan;
}

/**
* @return If x-axis should be inverted
*/
public boolean isInvertX() {
return invertX;
}

/**
* Sets whether to invert x-axis
* @param invertX Invert if true, false otherwise
*/
public void setInvertX(boolean invertX) {
this.invertX = invertX;
}

/**
* @return If y-axis should be inverted
*/
public boolean isInvertY() {
return invertY;
}

/**
* Sets whether to invert y-axis
* @param invertY Invert if true, false otherwise
*/
public void setInvertY(boolean invertY) {
this.invertY = invertY;
}

/**
* @return If angular velocity should be inverted
*/
public boolean isInvertAngularVelocity() {
return invertAngularVelocity;
}

/**
* Sets whether to invert angular velocity
* @param invertAngularVelocity Invert if true, false otherwise
*/
public void setInvertAngularVelocity(boolean invertAngularVelocity) {
this.invertAngularVelocity = invertAngularVelocity;
}

/**
* Compares this RobotInfo to another based on UUID.
* @param another The other RobotInfo
Expand Down Expand Up @@ -272,4 +376,64 @@ static int getRobotCount()
{
return robotCount;
}

@Override
public void load(@NonNull Bundle bundle) {
id = UUID.fromString(bundle.getString(UUID_KEY, UUID.randomUUID().toString()));
name = bundle.getString(ROBOT_NAME_KEY, "");
masterUriString = bundle.getString(MASTER_URI_KEY, "http://localhost:11311");
joystickTopic = bundle.getString(JOYSTICK_TOPIC_KEY, "/joy_teleop/cmd_vel");
cameraTopic = bundle.getString(CAMERA_TOPIC_KEY, "/image_raw/compressed");
laserTopic = bundle.getString(LASER_SCAN_TOPIC_KEY, "/scan");
navsatTopic = bundle.getString(NAVSAT_TOPIC_KEY, "/navsat/fix");
odometryTopic = bundle.getString(ODOMETRY_TOPIC_KEY, "/odometry/filtered");
poseTopic = bundle.getString(POSE_TOPIC_KEY, "/pose");
reverseLaserScan = bundle.getBoolean(REVERSE_LASER_SCAN_KEY, false);
invertX = bundle.getBoolean(INVERT_X_KEY, false);
invertY = bundle.getBoolean(INVERT_Y_KEY, false);
invertAngularVelocity = bundle.getBoolean(INVERT_ANGULAR_VELOCITY_KEY, false);
}

public void load(@NonNull SharedPreferences prefs) {
joystickTopic = prefs.getString(RobotStorage.getPreferenceKey(JOYSTICK_TOPIC_KEY), "/joy_teleop/cmd_vel");
cameraTopic = prefs.getString(RobotStorage.getPreferenceKey(CAMERA_TOPIC_KEY), "/image_raw/compressed");
laserTopic = prefs.getString(RobotStorage.getPreferenceKey(LASER_SCAN_TOPIC_KEY), "/scan");
navsatTopic = prefs.getString(RobotStorage.getPreferenceKey(NAVSAT_TOPIC_KEY), "/navsat/fix");
odometryTopic = prefs.getString(RobotStorage.getPreferenceKey(ODOMETRY_TOPIC_KEY), "/odometry/filtered");
poseTopic = prefs.getString(RobotStorage.getPreferenceKey(POSE_TOPIC_KEY), "/pose");
reverseLaserScan = prefs.getBoolean(RobotStorage.getPreferenceKey(REVERSE_LASER_SCAN_KEY), false);
invertX = prefs.getBoolean(RobotStorage.getPreferenceKey(INVERT_X_KEY), false);
invertY = prefs.getBoolean(RobotStorage.getPreferenceKey(INVERT_Y_KEY), false);
invertAngularVelocity = prefs.getBoolean(RobotStorage.getPreferenceKey(INVERT_ANGULAR_VELOCITY_KEY), false);
}

@Override
public void save(@NonNull Bundle bundle) {
bundle.putString(UUID_KEY, id.toString());
bundle.putString(ROBOT_NAME_KEY, name);
bundle.putString(MASTER_URI_KEY, masterUriString);
bundle.putString(JOYSTICK_TOPIC_KEY, joystickTopic);
bundle.putString(CAMERA_TOPIC_KEY, cameraTopic);
bundle.putString(LASER_SCAN_TOPIC_KEY, laserTopic);
bundle.putString(NAVSAT_TOPIC_KEY, navsatTopic);
bundle.putString(ODOMETRY_TOPIC_KEY, odometryTopic);
bundle.putString(POSE_TOPIC_KEY, poseTopic);
bundle.putBoolean(REVERSE_LASER_SCAN_KEY, reverseLaserScan);
bundle.putBoolean(INVERT_X_KEY, invertX);
bundle.putBoolean(INVERT_Y_KEY, invertY);
bundle.putBoolean(INVERT_ANGULAR_VELOCITY_KEY, invertAngularVelocity);
}

public void save(@NonNull SharedPreferences.Editor prefs) {
prefs.putString(RobotStorage.getPreferenceKey(JOYSTICK_TOPIC_KEY), joystickTopic);
prefs.putString(RobotStorage.getPreferenceKey(CAMERA_TOPIC_KEY), cameraTopic);
prefs.putString(RobotStorage.getPreferenceKey(LASER_SCAN_TOPIC_KEY), laserTopic);
prefs.putString(RobotStorage.getPreferenceKey(NAVSAT_TOPIC_KEY), navsatTopic);
prefs.putString(RobotStorage.getPreferenceKey(ODOMETRY_TOPIC_KEY), odometryTopic);
prefs.putString(RobotStorage.getPreferenceKey(POSE_TOPIC_KEY), poseTopic);
prefs.putBoolean(RobotStorage.getPreferenceKey(REVERSE_LASER_SCAN_KEY), reverseLaserScan);
prefs.putBoolean(RobotStorage.getPreferenceKey(INVERT_X_KEY), invertX);
prefs.putBoolean(RobotStorage.getPreferenceKey(INVERT_Y_KEY), invertY);
prefs.putBoolean(RobotStorage.getPreferenceKey(INVERT_ANGULAR_VELOCITY_KEY), invertAngularVelocity);
}
}
Loading

0 comments on commit 3a70f5e

Please sign in to comment.