Skip to content
This repository has been archived by the owner on Oct 27, 2020. It is now read-only.

Commit

Permalink
Merge pull request #22 from FIRST-Tech-Challenge/v5.1
Browse files Browse the repository at this point in the history
SkyStone v5.1
  • Loading branch information
CalKestis authored Aug 21, 2019
2 parents cc40cce + 4b1491d commit c05584b
Show file tree
Hide file tree
Showing 115 changed files with 15,512 additions and 258 deletions.
4 changes: 2 additions & 2 deletions FtcRobotController/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.qualcomm.ftcrobotcontroller"
android:versionCode="32"
android:versionName="5.0">
android:versionCode="33"
android:versionName="5.1">

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@

/**
*
* This OpMode executes a basic Tank Drive Teleop for a two wheeled robot using two REV SPARK Minis.
* To use this example, connect two REV SPARK Minis into servo ports on the Expansion Hub. On the
* robot configuration, use the drop down list under 'Servos' to select 'REV SPARK Mini Controller'
* This OpMode executes a basic Tank Drive Teleop for a two wheeled robot using two REV SPARKminis.
* To use this example, connect two REV SPARKminis into servo ports on the Expansion Hub. On the
* robot configuration, use the drop down list under 'Servos' to select 'REV SPARKmini Controller'
* and name them 'left_drive' and 'right_drive'.
*
* Use Android Studios to Copy this Class, and Paste it into your team's code folder with a new name.
* Remove or comment out the @Disabled line to add this opmode to the Driver Station OpMode list
*/

@TeleOp(name="REV SPARK Mini Simple Drive Example", group="Concept")
@TeleOp(name="REV SPARKmini Simple Drive Example", group="Concept")
@Disabled
public class ConceptRevSPARKMini extends LinearOpMode {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/* Copyright (c) 2018 FIRST. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted (subject to the limitations in the disclaimer below) provided that
* the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* Neither the name of FIRST nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS
* LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 THE COPYRIGHT OWNER OR 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.
*/

package org.firstinspires.ftc.robotcontroller.external.samples;

import android.content.Context;

import com.qualcomm.ftccommon.SoundPlayer;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;

/**
* This file demonstrates how to play one of the several SKYSTONE/Star Wars sounds loaded into the SDK.
* It does this by creating a simple "chooser" controlled by the gamepad Up Down buttons.
* This code also prevents sounds from stacking up by setting a "playing" flag, which is cleared when the sound finishes playing.
*
* Use Android Studios to Copy this Class, and Paste it into your team's code folder with a new name.
* Remove or comment out the @Disabled line to add this opmode to the Driver Station OpMode list
*
* Operation:
* Use the DPAD to change the selected sound, and the Right Bumper to play it.
*/

@TeleOp(name="SKYSTONE Sounds", group="Concept")
@Disabled
public class ConceptSoundsSKYSTONE extends LinearOpMode {

// List of available sound resources
String sounds[] = {"ss_alarm", "ss_bb8_down", "ss_bb8_up", "ss_darth_vader", "ss_fly_by",
"ss_mf_fail", "ss_laser", "ss_laser_burst", "ss_light_saber", "ss_light_saber_long", "ss_light_saber_short",
"ss_light_speed", "ss_mine", "ss_power_up", "ss_r2d2_up", "ss_roger_roger", "ss_siren", "ss_wookie" };
boolean soundPlaying = false;

@Override
public void runOpMode() {

// Variables for choosing from the available sounds
int soundIndex = 0;
int soundID = -1;
boolean was_dpad_up = false;
boolean was_dpad_down = false;

Context myApp = hardwareMap.appContext;

// create a sound parameter that holds the desired player parameters.
SoundPlayer.PlaySoundParams params = new SoundPlayer.PlaySoundParams();
params.loopControl = 0;
params.waitForNonLoopingSoundsToFinish = true;

// In this sample, we will skip waiting for the user to press play, and start displaying sound choices right away
while (!isStopRequested()) {

// Look for DPAD presses to change the selection
if (gamepad1.dpad_down && !was_dpad_down) {
// Go to next sound (with list wrap) and display it
soundIndex = (soundIndex + 1) % sounds.length;
}

if (gamepad1.dpad_up && !was_dpad_up) {
// Go to previous sound (with list wrap) and display it
soundIndex = (soundIndex + sounds.length - 1) % sounds.length;
}

// Look for trigger to see if we should play sound
// Only start a new sound if we are currently not playing one.
if (gamepad1.right_bumper && !soundPlaying) {

// Determine Resource IDs for the sounds you want to play, and make sure it's valid.
if ((soundID = myApp.getResources().getIdentifier(sounds[soundIndex], "raw", myApp.getPackageName())) != 0){

// Signal that the sound is now playing.
soundPlaying = true;

// Start playing, and also Create a callback that will clear the playing flag when the sound is complete.
SoundPlayer.getInstance().startPlaying(myApp, soundID, params, null,
new Runnable() {
public void run() {
soundPlaying = false;
}} );
}
}

// Remember the last state of the dpad to detect changes.
was_dpad_up = gamepad1.dpad_up;
was_dpad_down = gamepad1.dpad_down;

// Display the current sound choice, and the playing status.
telemetry.addData("", "Use DPAD up/down to choose sound.");
telemetry.addData("", "Press Right Bumper to play sound.");
telemetry.addData("", "");
telemetry.addData("Sound >", sounds[soundIndex]);
telemetry.addData("Status >", soundPlaying ? "Playing" : "Stopped");
telemetry.update();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,22 @@ public class SensorREVColorDistance extends LinearOpMode {

/**
* Note that the REV Robotics Color-Distance incorporates two sensors into one device.
* It has a light/distance (range) sensor. It also has an RGB color sensor.
* The light/distance sensor saturates at around 2" (5cm). This means that targets that are 2"
* It has an IR proximity sensor which is used to calculate distance and an RGB color sensor.
*
* There will be some variation in the values measured depending on whether you are using a
* V3 color sensor versus the older V2 and V1 sensors, as the V3 is based around a different chip.
*
* For V1/V2, the light/distance sensor saturates at around 2" (5cm). This means that targets that are 2"
* or closer will display the same value for distance/light detected.
*
* For V3, the distance sensor as configured can handle distances between 0.25" (~0.6cm) and 6" (~15cm).
* Any target closer than 0.25" will dislay as 0.25" and any target farther than 6" will display as 6".
*
* Note that the distance sensor function of both chips is built around an IR proximity sensor, which is
* sensitive to ambient light and the reflectivity of the surface against which you are measuring. If
* very accurate distance is required you should consider calibrating the raw optical values read from the
* chip to your exact situation.
*
* Although you configure a single REV Robotics Color-Distance sensor in your configuration file,
* you can treat the sensor as two separate sensors that share the same name in your op mode.
*
Expand All @@ -70,7 +82,7 @@ public class SensorREVColorDistance extends LinearOpMode {
* color of the screen to match the detected color.
*
* In this example, we also use the distance sensor to display the distance
* to the target object. Note that the distance sensor saturates at around 2" (5 cm).
* to the target object.
*
*/
ColorSensor sensorColor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
import com.qualcomm.robotcore.eventloop.opmode.OpModeRegister;
import com.qualcomm.robotcore.hardware.configuration.LynxConstants;
import com.qualcomm.robotcore.hardware.configuration.Utility;
import com.qualcomm.robotcore.robot.Robot;
import com.qualcomm.robotcore.robot.RobotState;
import com.qualcomm.robotcore.util.Device;
import com.qualcomm.robotcore.util.Dimmer;
import com.qualcomm.robotcore.util.ImmersiveMode;
Expand All @@ -100,7 +102,6 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
import org.firstinspires.ftc.ftccommon.external.SoundPlayingRobotMonitor;
import org.firstinspires.ftc.ftccommon.internal.FtcRobotControllerWatchdogService;
import org.firstinspires.ftc.ftccommon.internal.ProgramAndManageActivity;
import org.firstinspires.ftc.onbotjava.OnBotJavaClassLoader;
import org.firstinspires.ftc.onbotjava.OnBotJavaHelperImpl;
import org.firstinspires.ftc.onbotjava.OnBotJavaProgrammingMode;
import org.firstinspires.ftc.robotcore.external.navigation.MotionDetection;
Expand Down Expand Up @@ -544,6 +545,26 @@ public boolean onCreateOptionsMenu(Menu menu) {
return true;
}

private boolean isRobotRunning() {
if (controllerService == null) {
return false;
}

Robot robot = controllerService.getRobot();

if ((robot == null) || (robot.eventLoopManager == null)) {
return false;
}

RobotState robotState = robot.eventLoopManager.state;

if (robotState != RobotState.RUNNING) {
return false;
} else {
return true;
}
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
Expand All @@ -562,10 +583,14 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
return true;
} else if (id == R.id.action_program_and_manage) {
Intent programmingModeIntent = new Intent(AppUtil.getDefContext(), ProgramAndManageActivity.class);
RobotControllerWebInfo webInfo = programmingModeManager.getWebServer().getConnectionInformation();
programmingModeIntent.putExtra(LaunchActivityConstantsList.RC_WEB_INFO, webInfo.toJson());
startActivity(programmingModeIntent);
if (isRobotRunning()) {
Intent programmingModeIntent = new Intent(AppUtil.getDefContext(), ProgramAndManageActivity.class);
RobotControllerWebInfo webInfo = programmingModeManager.getWebServer().getConnectionInformation();
programmingModeIntent.putExtra(LaunchActivityConstantsList.RC_WEB_INFO, webInfo.toJson());
startActivity(programmingModeIntent);
} else {
AppUtil.getInstance().showToast(UILocation.ONLY_LOCAL, context.getString(R.string.toastWifiUpBeforeProgrammingMode));
}
} else if (id == R.id.action_inspection_mode) {
Intent inspectionModeIntent = new Intent(AppUtil.getDefContext(), RcInspectionActivity.class);
startActivity(inspectionModeIntent);
Expand Down
1 change: 1 addition & 0 deletions FtcRobotController/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<string name="toastWifiConfigurationComplete">Configuration Complete</string>
<string name="toastRestartingRobot">Restarting Robot</string>
<string name="toastConfigureRobotBeforeProgrammingMode">You must Configure Robot before starting Programming Mode.</string>
<string name="toastWifiUpBeforeProgrammingMode">The Robot Controller must be fully up and running before starting Programming Mode. Is Wifi turned on in settings?</string>

<!-- for interpreting pref_app_theme contents. may be override in merged resources -->
<integer-array name="app_theme_ids">
Expand Down
Loading

0 comments on commit c05584b

Please sign in to comment.