diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/ant/AntPropertiesParser.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/ant/AntPropertiesParser.java index e23dc96e53..001b0a8d19 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/ant/AntPropertiesParser.java +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/ant/AntPropertiesParser.java @@ -64,8 +64,8 @@ public class AntPropertiesParser { matcher.appendReplacement(sb, Matcher.quoteReplacement(props.getProperty(prop))); } else if (prop.equals("user.home")) { matcher.appendReplacement(sb, Matcher.quoteReplacement(System.getProperty("user.home"))); - } else { - throw new CoreException(new Status(0, "WPI", "Could not parse build.properties file, unsupported property: "+prop)); + } else { + matcher.appendReplacement(sb, Matcher.quoteReplacement(matcher.group())); } } matcher.appendTail( sb ); diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/installer/AbstractInstaller.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/installer/AbstractInstaller.java index 96fe0422bf..b7547a6fcc 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/installer/AbstractInstaller.java +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/installer/AbstractInstaller.java @@ -12,7 +12,6 @@ import javax.swing.JOptionPane; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.DebugPlugin; -import org.omg.CORBA.Environment; import edu.wpi.first.wpilib.plugins.core.WPILibCore; diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/NewProjectMainPage.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/NewProjectMainPage.java index 972d9ebed9..d2b7235398 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/NewProjectMainPage.java +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/NewProjectMainPage.java @@ -2,6 +2,7 @@ package edu.wpi.first.wpilib.plugins.core.wizards; import java.util.Map; +import javax.activation.FileDataSource; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -11,10 +12,14 @@ import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; @@ -29,6 +34,8 @@ public class NewProjectMainPage extends WizardPage { private Text projectNameText; private Text packageText; Map types; + private Text worldText; + private Button worldButton; Button simpleRobot, iterativeRobot, commandRobot; private boolean showPackage; @@ -113,6 +120,32 @@ public class NewProjectMainPage extends WizardPage { gd.widthHint = 300; commandRobot.setLayoutData(gd); } + + label = new Label(container, SWT.NULL); + label.setText("Simulation &World:"); + + + Composite comp = new Composite(container, SWT.NULL); + gd = new GridData(GridData.FILL_HORIZONTAL); + comp.setLayoutData(gd); + GridLayout groupLayout = new GridLayout(); + groupLayout.numColumns = 2; + comp.setLayout(groupLayout); + worldText = new Text(comp, SWT.BORDER | SWT.SINGLE); + worldText.setLayoutData(gd); + worldText.setText("/usr/share/frcsim/worlds/GearsBotDemo.world"); + worldText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + dialogChanged(); + } + }); + worldButton = new Button(comp, SWT.NULL); + worldButton.setText("Browse"); + worldButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { + browse(); + } + }); initialize(); dialogChanged(); @@ -125,12 +158,12 @@ public class NewProjectMainPage extends WizardPage { private void initialize() { String teamNumber = TeamNumberPage.getTeamNumberFromPage(teamNumberPage); if (showPackage) { - packageText.setText("com.first.team"+teamNumber+".robot"); + packageText.setText("org.usfirst.frc.team"+teamNumber+".robot"); if (teamNumberPage != null) { teamNumberPage.registerChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { String teamNumber = TeamNumberPage.getTeamNumberFromPage(teamNumberPage); - packageText.setText("com.first.team"+teamNumber+".robot"); + packageText.setText("org.usfirst.frc.team"+teamNumber+".robot"); } }); @@ -159,9 +192,22 @@ public class NewProjectMainPage extends WizardPage { updateStatus("Must be valid java package"); return; } + updateStatus(null); } + private void browse() { + FileDialog dialog = new FileDialog(getShell(), SWT.OPEN); + dialog.setText("Pick a World to Simulate"); + dialog.setFileName(worldText.getText()); + dialog.setFilterNames(new String[] { "World Files", "All Files (*.*)" }); + dialog.setFilterExtensions(new String[] { "*.world", "*.*" }); + String result = dialog.open(); + if (result != null) { + worldText.setText(result); + } + } + private void updateStatus(String message) { setErrorMessage(message); setPageComplete(message == null); @@ -182,6 +228,10 @@ public class NewProjectMainPage extends WizardPage { else return types.get(ProjectType.COMMAND_BASED); } + public String getWorld() { + return worldText.getText().replace(System.getenv("HOME"), "${user.home}"); + } + public void setShowPackage(boolean bool) { showPackage = bool; } @@ -194,4 +244,4 @@ public class NewProjectMainPage extends WizardPage { showProjectTypes = true; this.types = types; } -} \ No newline at end of file +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/plugin.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/plugin.xml index 1aa3c2b5e6..b3ec0f9c48 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/plugin.xml +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/plugin.xml @@ -180,6 +180,41 @@ mode="debug"> + + + + + + + + + + + + + + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/pom.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/pom.xml index c74a120789..77083af70e 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/pom.xml +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/pom.xml @@ -63,9 +63,16 @@ edu.wpi.first.wpilib.cmake cpp-root 1.0.0 - zip + zip cpp-root.jar + + edu.wpi.first.wpilibc.simulation + WPILibCSim + 0.1.0 + zip + sim-include.zip + ${project.build.directory} false @@ -73,6 +80,38 @@ true + + + + fetch-sim-jar-zip-dependencies + compile + + copy + + + ${cpp-zip}/sim/lib + false + true + + + + net.java.jinput + jinput-platform + 2.0.5 + natives-linux + jar + + + + edu.wpi.first.wpilibj.simulation + SimDS + 0.1.0-SNAPSHOT + SimDS.jar + ${cpp-zip}/sim/tools + + + + @@ -80,6 +119,7 @@ maven-antrun-plugin 1.7 + set-version-info @@ -100,6 +140,7 @@ true + unzip-cpp-includes @@ -112,11 +153,29 @@ + + + + + unzip-jinput-libs + compile + + run + + + + + + + + generate-cpp-zip @@ -141,5 +200,11 @@ 1.0.0 zip + + edu.wpi.first.wpilibc.simulation + WPILibCSim + 0.1.0 + zip + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/.cproject b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/.cproject index 08aebc6031..1f7bf740af 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/.cproject +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/.cproject @@ -128,6 +128,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -195,5 +265,8 @@ + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/build.properties index e89514796f..ae7c0ab297 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/build.properties +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/build.properties @@ -18,4 +18,11 @@ classloadertask.jar=${wpilib.ant.dir}/ant-classloadertask.jar out=FRCUserProgram src.dir=src build.dir=build -out.exe=Debug/${out} \ No newline at end of file +out.exe=Debug/${out} + +# Simulation +simulation.world.file=$world +sim.exe=Simulate/${out} +wpilib.sim=${wpilib}/sim +sim.tools=${wpilib.sim}/tools +sim.lib=${wpilib.sim}/lib \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/Autonomous.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/Autonomous.cpp new file mode 100644 index 0000000000..fd5077762d --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/Autonomous.cpp @@ -0,0 +1,22 @@ +#include "Autonomous.h" +#include "PrepareToPickup.h" +#include "Pickup.h" +#include "Place.h" +#include "SetDistanceToBox.h" +#include "DriveStraight.h" +#include "SetWristSetpoint.h" +#include "CloseClaw.h" + +#include + +Autonomous::Autonomous() : CommandGroup("Autonomous") { + AddSequential(new PrepareToPickup()); + AddSequential(new Pickup()); + AddSequential(new SetDistanceToBox(0.10)); + // AddSequential(new DriveStraight(4)); // Use Encoders if ultrasonic is broken + AddSequential(new Place()); + AddSequential(new SetDistanceToBox(0.60)); + // addSequential(new DriveStraight(-2)); // Use Encoders if ultrasonic is broken + AddParallel(new SetWristSetpoint(-45)); + AddSequential(new CloseClaw()); +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/Autonomous.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/Autonomous.h new file mode 100644 index 0000000000..143f89401c --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/Autonomous.h @@ -0,0 +1,15 @@ +#ifndef Autonomous_H +#define Autonomous_H + +#include "Commands/CommandGroup.h" + +/** + * The main autonomous command to pickup and deliver the + * soda to the box. + */ +class Autonomous: public CommandGroup { +public: + Autonomous(); +}; + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/CloseClaw.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/CloseClaw.cpp new file mode 100644 index 0000000000..8e91eaa47d --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/CloseClaw.cpp @@ -0,0 +1,34 @@ +#include "CloseClaw.h" +#include "Robot.h" + +CloseClaw::CloseClaw() : Command("CloseClaw") { + Requires(Robot::claw); +} + +// Called just before this Command runs the first time +void CloseClaw::Initialize() { + Robot::claw->Close(); +} + +// Called repeatedly when this Command is scheduled to run +void CloseClaw::Execute() {} + +// Make this return true when this Command no longer needs to run execute() +bool CloseClaw::IsFinished() { + return Robot::claw->IsGripping() ; +} + +// Called once after isFinished returns true +void CloseClaw::End() { + // NOTE: Doesn't stop in simulation due to lower friction causing the can to fall out + // + there is no need to worry about stalling the motor or crushing the can. + #ifdef REAL + Robot::claw->Stop(); + #endif +} + +// Called when another command which requires one or more of the same +// subsystems is scheduled to run +void CloseClaw::Interrupted() { + End(); +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/CloseClaw.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/CloseClaw.h new file mode 100644 index 0000000000..d265091495 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/CloseClaw.h @@ -0,0 +1,20 @@ +#ifndef CloseClaw_H +#define CloseClaw_H + +#include "Commands/Command.h" + +/** + * Opens the claw for one second. Real robots should use sensors, stalling + * motors is BAD! + */ +class CloseClaw: public Command { +public: + CloseClaw(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +}; + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/DriveStraight.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/DriveStraight.cpp new file mode 100644 index 0000000000..fd63c70bf4 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/DriveStraight.cpp @@ -0,0 +1,50 @@ +#include "DriveStraight.h" +#include "Robot.h" + +DriveStraight::DriveStraight(double distance) { + Requires(Robot::drivetrain); + pid = new PIDController(4, 0, 0, new DriveStraightPIDSource(), + new DriveStraightPIDOutput()); + pid->SetAbsoluteTolerance(0.01); + pid->SetSetpoint(distance); +} + +// Called just before this Command runs the first time +void DriveStraight::Initialize() { + // Get everything in a safe starting state. + Robot::drivetrain->Reset(); + pid->Reset(); + pid->Enable(); +} + +// Called repeatedly when this Command is scheduled to run +void DriveStraight::Execute() {} + +// Make this return true when this Command no longer needs to run execute() +bool DriveStraight::IsFinished() { + return pid->OnTarget(); +} + +// Called once after isFinished returns true +void DriveStraight::End() { + // Stop PID and the wheels + pid->Disable(); + Robot::drivetrain->Drive(0, 0); +} + +// Called when another command which requires one or more of the same +// subsystems is scheduled to run +void DriveStraight::Interrupted() { + End(); +} + + +DriveStraightPIDSource::~DriveStraightPIDSource() {} +double DriveStraightPIDSource::PIDGet() { + return Robot::drivetrain->GetDistance(); +} + +DriveStraightPIDOutput::~DriveStraightPIDOutput() {} +void DriveStraightPIDOutput::PIDWrite(float d) { + Robot::drivetrain->Drive(d, d); +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/DriveStraight.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/DriveStraight.h new file mode 100644 index 0000000000..50cd0b8e60 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/DriveStraight.h @@ -0,0 +1,37 @@ +#ifndef DriveStraight_H +#define DriveStraight_H + +#include "WPILib.h" +#include "Commands/Command.h" + +/** + * Drive the given distance straight (negative values go backwards). + * Uses a local PID controller to run a simple PID loop that is only + * enabled while this command is running. The input is the averaged + * values of the left and right encoders. + */ +class DriveStraight: public Command { +public: + DriveStraight(double distance); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +private: + PIDController* pid; +}; + +class DriveStraightPIDSource: public PIDSource { +public: + virtual ~DriveStraightPIDSource(); + double PIDGet(); +}; + +class DriveStraightPIDOutput: public PIDOutput { +public: + virtual ~DriveStraightPIDOutput(); + void PIDWrite(float d); +}; + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/OpenClaw.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/OpenClaw.cpp new file mode 100644 index 0000000000..4e9aec34ad --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/OpenClaw.cpp @@ -0,0 +1,31 @@ +#include "OpenClaw.h" +#include "Robot.h" + +OpenClaw::OpenClaw() : Command("OpenClaw") { + Requires(Robot::claw); + SetTimeout(1); +} + +// Called just before this Command runs the first time +void OpenClaw::Initialize() { + Robot::claw->Open(); +} + +// Called repeatedly when this Command is scheduled to run +void OpenClaw::Execute() {} + +// Make this return true when this Command no longer needs to run execute() +bool OpenClaw::IsFinished() { + return IsTimedOut(); +} + +// Called once after isFinished returns true +void OpenClaw::End() { + Robot::claw->Stop(); +} + +// Called when another command which requires one or more of the same +// subsystems is scheduled to run +void OpenClaw::Interrupted() { + End(); +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/OpenClaw.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/OpenClaw.h new file mode 100644 index 0000000000..15a059c2d4 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/OpenClaw.h @@ -0,0 +1,20 @@ +#ifndef OpenClaw_H +#define OpenClaw_H + +#include "Commands/Command.h" + +/** + * Opens the claw for one second. Real robots should use sensors, stalling + * motors is BAD! + */ +class OpenClaw: public Command { +public: + OpenClaw(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +}; + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/Pickup.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/Pickup.cpp new file mode 100644 index 0000000000..c8e8dbe3b8 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/Pickup.cpp @@ -0,0 +1,12 @@ +#include "Pickup.h" +#include "CloseClaw.h" +#include "SetWristSetpoint.h" +#include "SetElevatorSetpoint.h" + +#include + +Pickup::Pickup() : CommandGroup("Pickup") { + AddSequential(new CloseClaw()); + AddParallel(new SetWristSetpoint(-45)); + AddSequential(new SetElevatorSetpoint(0.25)); +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/Pickup.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/Pickup.h new file mode 100644 index 0000000000..ba08500a09 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/Pickup.h @@ -0,0 +1,15 @@ +#ifndef Pickup_H +#define Pickup_H + +#include "Commands/CommandGroup.h" + +/** + * Pickup a soda can (if one is between the open claws) and + * get it in a safe state to drive around. + */ +class Pickup: public CommandGroup { +public: + Pickup(); +}; + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/Place.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/Place.cpp new file mode 100644 index 0000000000..c535b4b4cc --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/Place.cpp @@ -0,0 +1,12 @@ +#include "Place.h" +#include "OpenClaw.h" +#include "SetWristSetpoint.h" +#include "SetElevatorSetpoint.h" + +#include + +Place::Place() : CommandGroup("Place") { + AddSequential(new SetElevatorSetpoint(0.25)); + AddSequential(new SetWristSetpoint(0)); + AddSequential(new OpenClaw()); +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/Place.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/Place.h new file mode 100644 index 0000000000..d8fbc9b9ba --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/Place.h @@ -0,0 +1,14 @@ +#ifndef Place_H +#define Place_H + +#include "Commands/CommandGroup.h" + +/** + * Place a held soda can onto the platform. + */ +class Place: public CommandGroup { +public: + Place(); +}; + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/PrepareToPickup.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/PrepareToPickup.cpp new file mode 100644 index 0000000000..f63d242199 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/PrepareToPickup.cpp @@ -0,0 +1,12 @@ +#include "PrepareToPickup.h" +#include "OpenClaw.h" +#include "SetWristSetpoint.h" +#include "SetElevatorSetpoint.h" + +#include + +PrepareToPickup::PrepareToPickup() : CommandGroup("PrepareToPickup") { + AddParallel(new OpenClaw()); + AddParallel(new SetWristSetpoint(0)); + AddSequential(new SetElevatorSetpoint(0)); +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/PrepareToPickup.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/PrepareToPickup.h new file mode 100644 index 0000000000..ec336a0037 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/PrepareToPickup.h @@ -0,0 +1,14 @@ +#ifndef PrepareToPickup_H +#define PrepareToPickup_H + +#include "Commands/CommandGroup.h" + +/** + * Make sure the robot is in a state to pickup soda cans. + */ +class PrepareToPickup: public CommandGroup { +public: + PrepareToPickup(); +}; + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/SetDistanceToBox.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/SetDistanceToBox.cpp new file mode 100644 index 0000000000..81c8bbdfcb --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/SetDistanceToBox.cpp @@ -0,0 +1,50 @@ +#include "SetDistanceToBox.h" +#include "Robot.h" + +SetDistanceToBox::SetDistanceToBox(double distance) { + Requires(Robot::drivetrain); + pid = new PIDController(-2, 0, 0, new SetDistanceToBoxPIDSource(), + new SetDistanceToBoxPIDOutput()); + pid->SetAbsoluteTolerance(0.01); + pid->SetSetpoint(distance); +} + +// Called just before this Command runs the first time +void SetDistanceToBox::Initialize() { + // Get everything in a safe starting state. + Robot::drivetrain->Reset(); + pid->Reset(); + pid->Enable(); +} + +// Called repeatedly when this Command is scheduled to run +void SetDistanceToBox::Execute() {} + +// Make this return true when this Command no longer needs to run execute() +bool SetDistanceToBox::IsFinished() { + return pid->OnTarget(); +} + +// Called once after isFinished returns true +void SetDistanceToBox::End() { + // Stop PID and the wheels + pid->Disable(); + Robot::drivetrain->Drive(0, 0); +} + +// Called when another command which requires one or more of the same +// subsystems is scheduled to run +void SetDistanceToBox::Interrupted() { + End(); +} + + +SetDistanceToBoxPIDSource::~SetDistanceToBoxPIDSource() {} +double SetDistanceToBoxPIDSource::PIDGet() { + return Robot::drivetrain->GetDistanceToObstacle(); +} + +SetDistanceToBoxPIDOutput::~SetDistanceToBoxPIDOutput() {} +void SetDistanceToBoxPIDOutput::PIDWrite(float d) { + Robot::drivetrain->Drive(d, d); +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/SetDistanceToBox.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/SetDistanceToBox.h new file mode 100644 index 0000000000..1c284884db --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/SetDistanceToBox.h @@ -0,0 +1,37 @@ +#ifndef SetDistanceToBox_H +#define SetDistanceToBox_H + +#include "WPILib.h" +#include "Commands/Command.h" + +/** + * Drive until the robot is the given distance away from the box. Uses a local + * PID controller to run a simple PID loop that is only enabled while this + * command is running. The input is the averaged values of the left and right + * encoders. + */ +class SetDistanceToBox: public Command { +public: + SetDistanceToBox(double distance); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +private: + PIDController* pid; +}; + +class SetDistanceToBoxPIDSource: public PIDSource { +public: + virtual ~SetDistanceToBoxPIDSource(); + double PIDGet(); +}; + +class SetDistanceToBoxPIDOutput: public PIDOutput { +public: + virtual ~SetDistanceToBoxPIDOutput(); + void PIDWrite(float d); +}; + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/SetElevatorSetpoint.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/SetElevatorSetpoint.cpp new file mode 100644 index 0000000000..6603ddfacc --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/SetElevatorSetpoint.cpp @@ -0,0 +1,29 @@ +#include "SetElevatorSetpoint.h" +#include "Robot.h" +#include + +SetElevatorSetpoint::SetElevatorSetpoint(double setpoint) : Command("SetElevatorSetpoint") { + this->setpoint = setpoint; + Requires(Robot::elevator); +} + +// Called just before this Command runs the first time +void SetElevatorSetpoint::Initialize() { + Robot::elevator->SetSetpoint(setpoint); + Robot::elevator->Enable(); +} + +// Called repeatedly when this Command is scheduled to run +void SetElevatorSetpoint::Execute() {} + +// Make this return true when this Command no longer needs to run execute() +bool SetElevatorSetpoint::IsFinished() { + return Robot::elevator->OnTarget(); +} + +// Called once after isFinished returns true +void SetElevatorSetpoint::End() {} + +// Called when another command which requires one or more of the same +// subsystems is scheduled to run +void SetElevatorSetpoint::Interrupted() {} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/SetElevatorSetpoint.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/SetElevatorSetpoint.h new file mode 100644 index 0000000000..1c8454c7b4 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/SetElevatorSetpoint.h @@ -0,0 +1,23 @@ +#ifndef SetElevatorSetpoint_H +#define SetElevatorSetpoint_H + +#include "Commands/Command.h" + +/** + * Move the elevator to a given location. This command finishes when it is within + * the tolerance, but leaves the PID loop running to maintain the position. Other + * commands using the elevator should make sure they disable PID! + */ +class SetElevatorSetpoint: public Command { +private: + double setpoint; +public: + SetElevatorSetpoint(double setpoint); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +}; + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/SetWristSetpoint.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/SetWristSetpoint.cpp new file mode 100644 index 0000000000..16b231b02a --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/SetWristSetpoint.cpp @@ -0,0 +1,28 @@ +#include "SetWristSetpoint.h" +#include "Robot.h" + +SetWristSetpoint::SetWristSetpoint(double setpoint) : Command("SetWristSetpoint") { + this->setpoint = setpoint; + Requires(Robot::wrist); +} + +// Called just before this Command runs the first time +void SetWristSetpoint::Initialize() { + Robot::wrist->SetSetpoint(setpoint); + Robot::wrist->Enable(); +} + +// Called repeatedly when this Command is scheduled to run +void SetWristSetpoint::Execute() {} + +// Make this return true when this Command no longer needs to run execute() +bool SetWristSetpoint::IsFinished() { + return Robot::wrist->OnTarget(); +} + +// Called once after isFinished returns true +void SetWristSetpoint::End() {} + +// Called when another command which requires one or more of the same +// subsystems is scheduled to run +void SetWristSetpoint::Interrupted() {} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/SetWristSetpoint.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/SetWristSetpoint.h new file mode 100644 index 0000000000..87c9db506c --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/SetWristSetpoint.h @@ -0,0 +1,23 @@ +#ifndef SetWristSetpoint_H +#define SetWristSetpoint_H + +#include "Commands/Command.h" + +/** + * Move the wrist to a given angle. This command finishes when it is within + * the tolerance, but leaves the PID loop running to maintain the position. + * Other commands using the wrist should make sure they disable PID! + */ +class SetWristSetpoint: public Command { +private: + double setpoint; +public: + SetWristSetpoint(double setpoint); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +}; + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/TankDriveWithJoystick.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/TankDriveWithJoystick.cpp new file mode 100644 index 0000000000..b7009eaf28 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/TankDriveWithJoystick.cpp @@ -0,0 +1,30 @@ +#include "TankDriveWithJoystick.h" +#include "Robot.h" + +TankDriveWithJoystick::TankDriveWithJoystick() : Command("TankDriveWithJoystick") { + Requires(Robot::drivetrain); +} + +// Called just before this Command runs the first time +void TankDriveWithJoystick::Initialize() {} + +// Called repeatedly when this Command is scheduled to run +void TankDriveWithJoystick::Execute() { + Robot::drivetrain->Drive(Robot::oi->GetJoystick()); +} + +// Make this return true when this Command no longer needs to run execute() +bool TankDriveWithJoystick::IsFinished() { + return false; +} + +// Called once after isFinished returns true +void TankDriveWithJoystick::End() { + Robot::drivetrain->Drive(0, 0); +} + +// Called when another command which requires one or more of the same +// subsystems is scheduled to run +void TankDriveWithJoystick::Interrupted() { + End(); +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/TankDriveWithJoystick.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/TankDriveWithJoystick.h new file mode 100644 index 0000000000..65cd935628 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Commands/TankDriveWithJoystick.h @@ -0,0 +1,19 @@ +#ifndef TankDriveWithJoystick_H +#define TankDriveWithJoystick_H + +#include "Commands/Command.h" + +/** + * Have the robot drive tank style using the PS3 Joystick until interrupted. + */ +class TankDriveWithJoystick: public Command { +public: + TankDriveWithJoystick(); + void Initialize(); + void Execute(); + bool IsFinished(); + void End(); + void Interrupted(); +}; + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/OI.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/OI.cpp new file mode 100644 index 0000000000..458e909273 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/OI.cpp @@ -0,0 +1,50 @@ +/* + * OI.cpp + * + * Created on: Jun 3, 2014 + * Author: alex + */ + +#include "OI.h" + +#include "Commands/SetElevatorSetpoint.h" +#include "Commands/OpenClaw.h" +#include "Commands/CloseClaw.h" +#include "Commands/PrepareToPickup.h" +#include "Commands/Pickup.h" +#include "Commands/Place.h" +#include "Commands/Autonomous.h" + +OI::OI() { + SmartDashboard::PutData("Open Claw", new OpenClaw()); + SmartDashboard::PutData("Close Claw", new CloseClaw()); + + joy= new Joystick(1); + + + // Create some buttons + JoystickButton* d_up = new JoystickButton(joy, 5); + JoystickButton* d_right= new JoystickButton(joy, 6); + JoystickButton* d_down= new JoystickButton(joy, 7); + JoystickButton* d_left = new JoystickButton(joy, 8); + JoystickButton* l2 = new JoystickButton(joy, 9); + JoystickButton* r2 = new JoystickButton(joy, 10); + JoystickButton* l1 = new JoystickButton(joy, 11); + JoystickButton* r1 = new JoystickButton(joy, 12); + + // Connect the buttons to commands + d_up->WhenPressed(new SetElevatorSetpoint(0.2)); + d_down->WhenPressed(new SetElevatorSetpoint(-0.2)); + d_right->WhenPressed(new CloseClaw()); + d_left->WhenPressed(new OpenClaw()); + + r1->WhenPressed(new PrepareToPickup()); + r2->WhenPressed(new Pickup()); + l1->WhenPressed(new Place()); + l2->WhenPressed(new Autonomous()); +} + + +Joystick* OI::GetJoystick() { + return joy; +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/OI.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/OI.h new file mode 100644 index 0000000000..d5c56469c1 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/OI.h @@ -0,0 +1,22 @@ +/* + * OI.h + * + * Created on: Jun 3, 2014 + * Author: alex + */ + +#ifndef OI_H_ +#define OI_H_ + +#include "WPILib.h" + +class OI { +public: + OI(); + Joystick* GetJoystick(); + +private: + Joystick* joy; +}; + +#endif /* OI_H_ */ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Robot.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Robot.cpp new file mode 100644 index 0000000000..801eb89985 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Robot.cpp @@ -0,0 +1,56 @@ + +#include "Robot.h" +#include "Commands/Autonomous.h" + +DriveTrain* Robot::drivetrain = NULL; +Elevator* Robot::elevator = NULL; +Wrist* Robot::wrist = NULL; +Claw* Robot::claw = NULL; + +OI* Robot::oi = NULL; + +void Robot::RobotInit() { + drivetrain = new DriveTrain(); + elevator = new Elevator(); + wrist = new Wrist(); + claw = new Claw(); + + oi = new OI(); + + autonomousCommand = new Autonomous(); + lw = LiveWindow::GetInstance(); + + // Show what command your subsystem is running on the SmartDashboard + SmartDashboard::PutData(drivetrain); + SmartDashboard::PutData(elevator); + SmartDashboard::PutData(wrist); + SmartDashboard::PutData(claw); +} + +void Robot::AutonomousInit() { + autonomousCommand->Start(); + std::cout << "Starting Auto" << std::endl; +} + +void Robot::AutonomousPeriodic() { + Scheduler::GetInstance()->Run(); +} + +void Robot::TeleopInit() { + // This makes sure that the autonomous stops running when + // teleop starts running. If you want the autonomous to + // continue until interrupted by another command, remove + // this line or comment it out. + autonomousCommand->Cancel(); + std::cout << "Starting Teleop" << std::endl; +} + +void Robot::TeleopPeriodic() { + Scheduler::GetInstance()->Run(); +} + +void Robot::TestPeriodic() { + lw->Run(); +} + +START_ROBOT_CLASS(Robot); diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Robot.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Robot.h new file mode 100644 index 0000000000..49d996c576 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Robot.h @@ -0,0 +1,41 @@ +/* + * Robot.h + * + * Created on: Jun 3, 2014 + * Author: alex + */ + +#ifndef MY_ROBOT_H_ +#define MY_ROBOT_H_ + +#include "WPILib.h" +#include "Commands/Command.h" + +#include "Subsystems/DriveTrain.h" +#include "Subsystems/Elevator.h" +#include "Subsystems/Wrist.h" +#include "Subsystems/Claw.h" +#include "OI.h" + +class Robot: public IterativeRobot { +public: + static DriveTrain* drivetrain; + static Elevator* elevator; + static Wrist* wrist; + static Claw* claw; + static OI* oi; + +private: + Command *autonomousCommand; + LiveWindow *lw; + + void RobotInit(); + void AutonomousInit(); + void AutonomousPeriodic(); + void TeleopInit(); + void TeleopPeriodic(); + void TestPeriodic(); +}; + + +#endif /* ROBOT_H_ */ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/Claw.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/Claw.cpp new file mode 100644 index 0000000000..938badd2ef --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/Claw.cpp @@ -0,0 +1,31 @@ +#include "Subsystems/Claw.h" + +Claw::Claw() : Subsystem("Claw") { + motor = new Victor(7); + contact = new DigitalInput(5); + + // Let's show everything on the LiveWindow + // TODO: LiveWindow::GetInstance()->AddActuator("Claw", "Motor", (Victor) motor); + // TODO: contact +} + +void Claw::Open() +{ + motor->Set(-1); +} + + +void Claw::Close() +{ + motor->Set(1); +} + + +void Claw::Stop() { + motor->Set(0); +} + +bool Claw::IsGripping() { + return contact->Get(); +} + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/Claw.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/Claw.h new file mode 100644 index 0000000000..5a795a8724 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/Claw.h @@ -0,0 +1,45 @@ +#ifndef Claw_H +#define Claw_H + +#include "Commands/Subsystem.h" +#include "WPILib.h" + +/** + * The claw subsystem is a simple system with a motor for opening and closing. + * If using stronger motors, you should probably use a sensor so that the + * motors don't stall. + */ +class Claw: public Subsystem { +private: + SpeedController* motor; + DigitalInput* contact; + +public: + Claw(); + void InitDefaultCommand() {} + + /** + * Set the claw motor to move in the open direction. + */ + void Open(); + + /** + * Set the claw motor to move in the close direction. + */ + void Close(); + + /** + * Stops the claw motor from moving. + */ + void Stop(); + + /** + * Return true when the robot is grabbing an object hard enough + * to trigger the limit switch. + */ + bool IsGripping(); + + void Log() {} +}; + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/DriveTrain.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/DriveTrain.cpp new file mode 100644 index 0000000000..344807da40 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/DriveTrain.cpp @@ -0,0 +1,90 @@ +#include "DriveTrain.h" +#include "Commands/TankDriveWithJoystick.h" + +DriveTrain::DriveTrain() : Subsystem("DriveTrain") { + front_left_motor = new Talon(1); + back_left_motor = new Talon(2); + front_right_motor = new Talon(3); + back_right_motor = new Talon(4); + drive = new RobotDrive(front_left_motor, back_left_motor, + front_right_motor, back_right_motor); + + left_encoder = new Encoder(1, 2); + right_encoder = new Encoder(3, 4); + + // Encoders may measure differently in the real world and in + // simulation. In this example the robot moves 0.042 barleycorns + // per tick in the real world, but the simulated encoders + // simulate 360 tick encoders. This if statement allows for the + // real robot to handle this difference in devices. + #ifdef REAL + left_encoder->SetDistancePerPulse(0.042); + right_encoder->SetDistancePerPulse(0.042); + #else + // Circumference in ft = 4in/12(in/ft)*PI + left_encoder->SetDistancePerPulse((double) (4.0/12.0*M_PI) / 360.0); + right_encoder->SetDistancePerPulse((double) (4.0/12.0*M_PI) / 360.0); + #endif + + left_encoder->Start(); + right_encoder->Start(); + + rangefinder = new AnalogChannel(6); + gyro = new Gyro(1); + + // Let's show everything on the LiveWindow + // TODO: LiveWindow::GetInstance()->AddActuator("Drive Train", "Front_Left Motor", (Talon) front_left_motor); + // TODO: LiveWindow::GetInstance()->AddActuator("Drive Train", "Back Left Motor", (Talon) back_left_motor); + // TODO: LiveWindow::GetInstance()->AddActuator("Drive Train", "Front Right Motor", (Talon) front_right_motor); + // TODO: LiveWindow::GetInstance()->AddActuator("Drive Train", "Back Right Motor", (Talon) back_right_motor); + LiveWindow::GetInstance()->AddSensor("Drive Train", "Left Encoder", left_encoder); + LiveWindow::GetInstance()->AddSensor("Drive Train", "Right Encoder", right_encoder); + LiveWindow::GetInstance()->AddSensor("Drive Train", "Rangefinder", rangefinder); + LiveWindow::GetInstance()->AddSensor("Drive Train", "Gyro", gyro); +} + +/** + * When no other command is running let the operator drive around + * using the PS3 joystick. + */ +void DriveTrain::InitDefaultCommand() { + SetDefaultCommand(new TankDriveWithJoystick()); +} + +/** + * The log method puts interesting information to the SmartDashboard. + */ +void DriveTrain::Log() { + SmartDashboard::PutNumber("Left Distance", left_encoder->GetDistance()); + SmartDashboard::PutNumber("Right Distance", right_encoder->GetDistance()); + SmartDashboard::PutNumber("Left Speed", left_encoder->GetRate()); + SmartDashboard::PutNumber("Right Speed", right_encoder->GetRate()); + SmartDashboard::PutNumber("Gyro", gyro->GetAngle()); +} + +void DriveTrain::Drive(double left, double right) { + drive->TankDrive(left, right); +} + +void DriveTrain::Drive(Joystick* joy) { + Drive(-joy->GetY(), -joy->GetRawAxis(4)); +} + +double DriveTrain::GetHeading() { + return gyro->GetAngle(); +} + +void DriveTrain::Reset() { + gyro->Reset(); + left_encoder->Reset(); + right_encoder->Reset(); +} + +double DriveTrain::GetDistance() { + return (left_encoder->GetDistance() + right_encoder->GetDistance())/2; +} + +double DriveTrain::GetDistanceToObstacle() { + // Really meters in simulation since it's a rangefinder... + return rangefinder->GetAverageVoltage(); +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/DriveTrain.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/DriveTrain.h new file mode 100644 index 0000000000..6bf77e653b --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/DriveTrain.h @@ -0,0 +1,68 @@ +#ifndef DriveTrain_H +#define DriveTrain_H + +#include "Commands/Subsystem.h" +#include "WPILib.h" + +/** + * The DriveTrain subsystem incorporates the sensors and actuators attached to + * the robots chassis. These include four drive motors, a left and right encoder + * and a gyro. + */ +class DriveTrain : public Subsystem { +private: + SpeedController *front_left_motor, *back_left_motor, + *front_right_motor, *back_right_motor; + RobotDrive* drive; + Encoder *left_encoder, *right_encoder; + AnalogChannel* rangefinder; + Gyro* gyro; + +public: + DriveTrain(); + + /** + * When no other command is running let the operator drive around + * using the PS3 joystick. + */ + void InitDefaultCommand(); + + /** + * The log method puts interesting information to the SmartDashboard. + */ + void Log(); + + /** + * Tank style driving for the DriveTrain. + * @param left Speed in range [-1,1] + * @param right Speed in range [-1,1] + */ + void Drive(double left, double right); + + /** + * @param joy The ps3 style joystick to use to drive tank style. + */ + void Drive(Joystick* joy); + + /** + * @return The robots heading in degrees. + */ + double GetHeading(); + + /** + * Reset the robots sensors to the zero states. + */ + void Reset(); + + /** + * @return The distance driven (average of left and right encoders). + */ + double GetDistance(); + + /** + * @return The distance to the obstacle detected by the rangefinder. + */ + double GetDistanceToObstacle(); +}; + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/Elevator.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/Elevator.cpp new file mode 100644 index 0000000000..02c558ffa5 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/Elevator.cpp @@ -0,0 +1,36 @@ +#include "Elevator.h" +#include "SmartDashboard/SmartDashboard.h" +#include "LiveWindow/LiveWindow.h" + +Elevator::Elevator() : PIDSubsystem("Elevator", kP_real, kI_real, 0.0) { + #ifdef SIMULATION // Check for simulation and update PID values + GetPIDController()->SetPID(kP_simulation, kI_simulation, 0, 0); + #endif + SetAbsoluteTolerance(0.005); + + motor = new Victor(5); + + // Conversion value of potentiometer varies between the real world and simulation + #ifdef REAL + pot = new AnalogPotentiometer(2, -2.0/5); + #else + pot = new AnalogPotentiometer(2); // Defaults to meters + #endif + + // Let's show everything on the LiveWindow + // TODO: LiveWindow::GetInstance()->AddActuator("Elevator", "Motor", (Victor) motor); + // TODO: LiveWindow::GetInstance()->AddSensor("Elevator", "Pot", (AnalogPotentiometer) pot); + LiveWindow::GetInstance()->AddActuator("Elevator", "PID", GetPIDController()); +} + +void Elevator::Log() { + // TODO: SmartDashboard::PutData("Wrist Pot", (AnalogPotentiometer) pot); +} + +double Elevator::ReturnPIDInput() { + return pot->Get(); +} + +void Elevator::UsePIDOutput(double d) { + motor->Set(d); +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/Elevator.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/Elevator.h new file mode 100644 index 0000000000..449c158613 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/Elevator.h @@ -0,0 +1,42 @@ +#ifndef Elevator_H +#define Elevator_H + +#include "Commands/PIDSubsystem.h" +#include "WPILib.h" + +/** + * The elevator subsystem uses PID to go to a given height. Unfortunately, in it's current + * state PID values for simulation are different than in the real world do to minor differences. + */ +class Elevator : public PIDSubsystem { +private: + SpeedController* motor; + Potentiometer* pot; + + static const double kP_real = 4, kI_real = 0.07, + kP_simulation = 18, kI_simulation = 0.2; + +public: + Elevator(); + void InitDefaultCommand() {} + + /** + * The log method puts interesting information to the SmartDashboard. + */ + void Log(); + + /** + * Use the potentiometer as the PID sensor. This method is automatically + * called by the subsystem. + */ + double ReturnPIDInput(); + + + /** + * Use the motor as the PID output. This method is automatically called by + * the subsystem. + */ + void UsePIDOutput(double d); +}; + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/Wrist.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/Wrist.cpp new file mode 100644 index 0000000000..f09fdbb790 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/Wrist.cpp @@ -0,0 +1,36 @@ +#include "Wrist.h" +#include "SmartDashboard/SmartDashboard.h" +#include "LiveWindow/LiveWindow.h" + +Wrist::Wrist() : PIDSubsystem("Wrist", kP_real, 0.0, 0.0) { + #ifdef SIMULATION // Check for simulation and update PID values + GetPIDController()->SetPID(kP_simulation, 0, 0, 0); + #endif + SetAbsoluteTolerance(2.5); + + motor = new Victor(6); + + // Conversion value of potentiometer varies between the real world and simulation + #ifdef REAL + pot = new AnalogPotentiometer(3, -270.0/5); + #else + pot = new AnalogPotentiometer(3); // Defaults to degrees + #endif + + // Let's show everything on the LiveWindow + // TODO: LiveWindow::GetInstance()->AddActuator("Wrist", "Motor", (Victor) motor); + // TODO: LiveWindow::GetInstance()->AddSensor("Wrist", "Pot", (AnalogPotentiometer) pot); + LiveWindow::GetInstance()->AddActuator("Wrist", "PID", GetPIDController()); +} + +void Wrist::Log() { + // TODO: SmartDashboard::PutData("Wrist Angle", (AnalogPotentiometer) pot); +} + +double Wrist::ReturnPIDInput() { + return pot->Get(); +} + +void Wrist::UsePIDOutput(double d) { + motor->Set(d); +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/Wrist.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/Wrist.h new file mode 100644 index 0000000000..b8fb28e830 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/GearsBot/src/Subsystems/Wrist.h @@ -0,0 +1,40 @@ +#ifndef Wrist_H +#define Wrist_H + +#include "Commands/PIDSubsystem.h" +#include "WPILib.h" + +/** + * The wrist subsystem is like the elevator, but with a rotational joint instead + * of a linear joint. + */ +class Wrist : public PIDSubsystem { +private: + SpeedController* motor; + Potentiometer* pot; // TODO: Make Potentiometer + + static const double kP_real = 1, kP_simulation = 0.05; + +public: + Wrist(); + void InitDefaultCommand() {} + + /** + * The log method puts interesting information to the SmartDashboard. + */ + void Log(); + + /** + * Use the potentiometer as the PID sensor. This method is automatically + * called by the subsystem. + */ + double ReturnPIDInput(); + + /** + * Use the motor as the PID output. This method is automatically called by + * the subsystem. + */ + void UsePIDOutput(double d); +}; + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/examples.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/examples.xml index 68376777cd..3fffe38ae3 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/examples.xml +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/examples.xml @@ -8,7 +8,15 @@ Network Tables Examples of how to use Network Tables to accomplish a variety of tasks such as sending and receiving values to both - dashboards and co-processors.. + dashboards and co-processors. + + + CommandBased Robot + Examples for CommandBased robot programs. + + + Simulation + Examples that can be run in simulation. @@ -43,5 +51,92 @@ + + + GearsBot + A fully functional example CommandBased program for + WPIs GearsBot robot. This code can run on your computer if it + supports simulation. + + CommandBased Robot + Simulation + + + src + src/Commands + src/Subsystems + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/launching/SimulateLaunchShortcut.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/launching/SimulateLaunchShortcut.java new file mode 100644 index 0000000000..9e7def44b4 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/launching/SimulateLaunchShortcut.java @@ -0,0 +1,137 @@ +package edu.wpi.first.wpilib.plugins.cpp.launching; + +import java.io.File; +import java.lang.reflect.Method; +import java.util.Vector; + +import org.eclipse.core.internal.resources.Resource; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.debug.ui.ILaunchShortcut; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.PlatformUI; + +import edu.wpi.first.wpilib.plugins.core.launching.AntLauncher; + +/** + * Launch shortcut base functionality, common for deploying to the robot. + * Retrieves the project the operation is being called on, and runs the correct + * ant targets based on polymorphically determined data values + * + * @author Ryan O'Meara + * @author Alex Henning + */ +@SuppressWarnings("restriction") +public class SimulateLaunchShortcut implements ILaunchShortcut { + //Class constants - used to delineate types for launch shortcuts + public static final String DEPLOY_TYPE = "edu.wpi.first.wpilib.plugins.core.deploy"; + private static final String ANT_SERVER_THREAD_NAME = "Ant Build Server Connection"; + + private static ILaunch lastDeploy = null; + + /** + * Returns the launch type of the shortcut that was used, one of the constants + * defined in BaseLaunchShortcut + * @return Launch shortcut type + */ + public String getLaunchType() {return DEPLOY_TYPE;} + + @Override + public void launch(ISelection selection, String mode) { + //Extract resource from selection + StructuredSelection sel = (StructuredSelection)selection; + IProject activeProject = null; + if (sel.getFirstElement() instanceof IProject) { + activeProject = (IProject) sel.getFirstElement(); + } else { + return; + } + + //Run config using project found in extracted resource, with indicated mode + runConfig(activeProject, mode); + } + + @Override + public void launch(IEditorPart editor, String mode) { + //Extract resource from editor + if(editor != null){ + IFileEditorInput input = (IFileEditorInput)editor.getEditorInput(); + IFile file = input.getFile(); + IProject activeProject = file.getProject(); + + //If editor existed, run config using extracted resource in indicated mode + runConfig(activeProject, mode); + }else{ + System.err.println("editor was null"); + } + + } + + /** + * Runs the ant script using the correct target for the indicated mode (deploy to cRIO or just compile) + * @param activeProj The project that the script will be run on/from + * @param mode The mode it will be run in (ILaunchManager.RUN_MODE or ILaunchManager.DEBUG_MODE) + */ + public void runConfig(IProject activeProj, String mode){ + String targets = "simulate"; + + if(mode.equals(ILaunchManager.RUN_MODE)){ + if(getLaunchType().equals(DEPLOY_TYPE)){ + targets = "simulate"; + } + } else if ((mode.equals(ILaunchManager.DEBUG_MODE))&&(getLaunchType().equals(DEPLOY_TYPE))) { + targets = "debug-simulate"; + try{ + PlatformUI.getWorkbench().showPerspective(IDebugUIConstants.ID_DEBUG_PERSPECTIVE, + PlatformUI.getWorkbench().getActiveWorkbenchWindow()); + + }catch(Exception e){} + } + + if((lastDeploy != null)&&(!lastDeploy.isTerminated())){ + System.out.println("Last deploy running"); + //Find the server connection thread and kill it + Vector threadGroups = new Vector(); + ThreadGroup root = Thread.currentThread().getThreadGroup().getParent(); + while (root.getParent() != null) {root = root.getParent();} + threadGroups.add(root); + ThreadGroup threadGroup = threadGroups.remove(0); + int numThreads = threadGroup.activeCount(); + Thread[] threads = new Thread[numThreads*100]; + numThreads = threadGroup.enumerate(threads, true); + + for(Thread current: threads){ + if(current != null){ + if(current.getName().equals(ANT_SERVER_THREAD_NAME)){ + try{ + //Manually end thread and then try terminating launch + Method stopMethod = current.getClass().getMethod("stop"); + stopMethod.invoke(current); + lastDeploy.terminate(); + break; + }catch(Exception e){e.printStackTrace();} + } + } + } + + System.out.println("Waiting"); + try{wait(1000);}catch(Exception e){} + + } + + System.out.println("Running ant file: " + activeProj.getLocation().toOSString() + File.separator + "build.xml"); + System.out.println("Targets: " + targets + ", Mode: " + mode); + lastDeploy = AntLauncher.runAntFile(new File (activeProj.getLocation().toOSString() + File.separator + "build.xml"), targets, null, mode); + + try { + activeProj.refreshLocal(Resource.DEPTH_INFINITE, null); + } catch (Exception e) {} + } +} + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/examples/ExampleCPPWizard.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/examples/ExampleCPPWizard.java index 1ecdfed307..4d0bb67488 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/examples/ExampleCPPWizard.java +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/examples/ExampleCPPWizard.java @@ -34,7 +34,7 @@ public class ExampleCPPWizard extends ExampleWizard { WPILibCore.getDefault().saveGlobalProperties(props); final String projectName = detailsPage.getProjectName(); - ProjectCreationUtils.createProject(new WPIRobotCPPProjectCreator(projectName, ex)); + ProjectCreationUtils.createProject(new WPIRobotCPPProjectCreator(projectName, ex, detailsPage.getWorld())); } @Override diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/newproject/NewCPPWizard.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/newproject/NewCPPWizard.java index b4a07bfb50..011b0d433a 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/newproject/NewCPPWizard.java +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/newproject/NewCPPWizard.java @@ -72,11 +72,12 @@ public class NewCPPWizard extends Wizard implements INewWizard { final String projectName = page.getProjectName(); final String teamNumber = TeamNumberPage.getTeamNumberFromPage(teamNumberPage); final ProjectType projectType = page.getProjectType(); + final String worldName = page.getWorld(); System.out.println("Project: "+projectName+" Project Type: "+projectType); IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { try { - doFinish(projectName, teamNumber, projectType, monitor); + doFinish(projectName, teamNumber, projectType, worldName, monitor); } catch (CoreException e) { throw new InvocationTargetException(e); } finally { @@ -102,11 +103,11 @@ public class NewCPPWizard extends Wizard implements INewWizard { * the editor on the newly created file. */ - private void doFinish(String projectName, String teamNumber, ProjectType projectType, IProgressMonitor monitor) throws CoreException { + private void doFinish(String projectName, String teamNumber, ProjectType projectType, String worldName, IProgressMonitor monitor) throws CoreException { Properties props = WPILibCore.getDefault().getProjectProperties(null); props.setProperty("team-number", teamNumber); WPILibCore.getDefault().saveGlobalProperties(props); - ProjectCreationUtils.createProject(new WPIRobotCPPProjectCreator(projectName, projectType)); + ProjectCreationUtils.createProject(new WPIRobotCPPProjectCreator(projectName, projectType, worldName)); } /** diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/newproject/WPIRobotCPPProjectCreator.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/newproject/WPIRobotCPPProjectCreator.java index 53748cf625..dc17b4ed06 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/newproject/WPIRobotCPPProjectCreator.java +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/newproject/WPIRobotCPPProjectCreator.java @@ -22,10 +22,12 @@ import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin; public class WPIRobotCPPProjectCreator implements IProjectCreator { String projectName; ProjectType projectType; + private String worldName; - public WPIRobotCPPProjectCreator(String projectName, ProjectType projectType) { + public WPIRobotCPPProjectCreator(String projectName, ProjectType projectType, String worldName) { this.projectName = projectName; this.projectType = projectType; + this.worldName = worldName; } @Override @@ -44,6 +46,7 @@ public class WPIRobotCPPProjectCreator implements IProjectCreator { vals.put("$project", projectName); vals.put("$toolchain", WPILibCPPPlugin.getDefault().getToolchain()); vals.put("$cpp-location", WPILibCPPPlugin.getDefault().getCPPDir()); + vals.put("$world", worldName); return vals; } diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/build.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/build.xml index 8c46cf2257..ce352e51b8 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/build.xml +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/build.xml @@ -147,4 +147,28 @@ ${md5.hal} usr/local/frc/lib/libHALAthena.so trust="true" command="chmod a+x debug*program; ${deploy.debug.command}"/> + + + + + + [simulate] Running Gazebo. + + + + + + + [simulate] Running DriverStation. + + + + + + + [simulate] Running Code. + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/plugin.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/plugin.xml index e9166311f8..c292e09d7a 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/plugin.xml +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/plugin.xml @@ -179,6 +179,41 @@ mode="debug"> + + + + + + + + + + + + + + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/pom.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/pom.xml index 3567cdbb0a..333692821d 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/pom.xml +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/pom.xml @@ -16,19 +16,6 @@ DEVELOPMENT ${project.build.directory}/java-zip - - - - - - @@ -88,27 +75,12 @@ edu.wpi.first.wpilibj - wpilibJavaFinal + wpilibJava 0.1.0-SNAPSHOT jar WPILib.jar ${java-zip}/lib - - edu.wpi.first.wpilib.networktables.java @@ -136,10 +108,76 @@ ${java-zip}/javadoc-jar + false true + + + + fetch-sim-jar-zip-dependencies + compile + + copy + + + ${java-zip}/sim/lib + false + true + + + + org.gazebosim + JavaGazebo + 0.1.0-SNAPSHOT + + + edu.wpi.first.wpilibj + wpilibJavaSim + 0.1.0-SNAPSHOT + jar + + + edu.wpi.first.wpilib.networktables.java + NetworkTables + 0.1.0-SNAPSHOT + + + + net.java.jinput + jinput + 2.0.5 + + + net.java.jinput + jinput-platform + 2.0.5 + natives-linux + jar + + + net.java.jutils + jutils + 1.0.0 + + + + com.google.protobuf + protobuf-java + 2.5.0 + + + + edu.wpi.first.wpilibj.simulation + SimDS + 0.1.0-SNAPSHOT + SimDS.jar + ${java-zip}/sim/tools + + + + @@ -187,7 +225,23 @@ - + + + + unzip-jinput-libs + compile + + run + + + + + + + + generate-jar-zip @@ -259,7 +313,13 @@ edu.wpi.first.wpilibj - wpilibJavaFinal + wpilibJava + 0.1.0-SNAPSHOT + jar + + + edu.wpi.first.wpilibj + wpilibJavaSim 0.1.0-SNAPSHOT jar @@ -287,7 +347,6 @@ edu.wpi.first.wpilibj wpilibJava 0.1.0-SNAPSHOT - sources diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/Gazebo.png b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/Gazebo.png new file mode 100644 index 0000000000..3ad1d74440 Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/Gazebo.png differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/build.properties index e29b4d35d5..2a2ec518f6 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/build.properties +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/build.properties @@ -1,3 +1,4 @@ # Project specific information package=$package -main=${package}.Robot \ No newline at end of file +robot.class=${package}.Robot +simulation.world.file=$world \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/OI.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/OI.java new file mode 100644 index 0000000000..ec443a0b50 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/OI.java @@ -0,0 +1,57 @@ + +package $package; + +import edu.wpi.first.wpilibj.Joystick; +import edu.wpi.first.wpilibj.buttons.JoystickButton; +import $package.commands.*; + +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; + +/** + * This class is the glue that binds the controls on the physical operator + * interface to the commands and command groups that allow control of the robot. + */ +public class OI { + private Joystick joy = new Joystick(1); + + public OI() { + // Put Some buttons on the SmartDashboard + SmartDashboard.putData("Elevator Bottom", new SetElevatorSetpoint(0)); + SmartDashboard.putData("Elevator Platform", new SetElevatorSetpoint(0.2)); + SmartDashboard.putData("Elevator Top", new SetElevatorSetpoint(0.3)); + + SmartDashboard.putData("Wrist Horizontal", new SetWristSetpoint(0)); + SmartDashboard.putData("Raise Wrist", new SetWristSetpoint(-45)); + + SmartDashboard.putData("Open Claw", new OpenClaw()); + SmartDashboard.putData("Close Claw", new CloseClaw()); + + SmartDashboard.putData("Deliver Soda", new Autonomous()); + + // Create some buttons + JoystickButton d_up = new JoystickButton(joy, 5); + JoystickButton d_right= new JoystickButton(joy, 6); + JoystickButton d_down= new JoystickButton(joy, 7); + JoystickButton d_left = new JoystickButton(joy, 8); + JoystickButton l2 = new JoystickButton(joy, 9); + JoystickButton r2 = new JoystickButton(joy, 10); + JoystickButton l1 = new JoystickButton(joy, 11); + JoystickButton r1 = new JoystickButton(joy, 12); + + // Connect the buttons to commands + d_up.whenPressed(new SetElevatorSetpoint(0.2)); + d_down.whenPressed(new SetElevatorSetpoint(-0.2)); + d_right.whenPressed(new CloseClaw()); + d_left.whenPressed(new OpenClaw()); + + r1.whenPressed(new PrepareToPickup()); + r2.whenPressed(new Pickup()); + l1.whenPressed(new Place()); + l2.whenPressed(new Autonomous()); + } + + public Joystick getJoystick() { + return joy; + } +} + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/Robot.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/Robot.java new file mode 100644 index 0000000000..4fe9902f3e --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/Robot.java @@ -0,0 +1,103 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2008. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package $package; + +import edu.wpi.first.wpilibj.IterativeRobot; +import edu.wpi.first.wpilibj.command.Command; +import edu.wpi.first.wpilibj.command.Scheduler; +import edu.wpi.first.wpilibj.livewindow.LiveWindow; +import $package.commands.Autonomous; +import $package.subsystems.Claw; +import $package.subsystems.DriveTrain; +import $package.subsystems.Elevator; +import $package.subsystems.Wrist; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; + +/** + * The VM is configured to automatically run this class, and to call the + * functions corresponding to each mode, as described in the IterativeRobot + * documentation. If you change the name of this class or the package after + * creating this project, you must also update the manifest file in the resource + * directory. + */ +public class Robot extends IterativeRobot { + Command autonomousCommand; + + public static DriveTrain drivetrain; + public static Elevator elevator; + public static Wrist wrist; + public static Claw claw; + public static OI oi; + + /** + * This function is run when the robot is first started up and should be + * used for any initialization code. + */ + public void robotInit() { + // Initialize all subsystems + drivetrain = new DriveTrain(); + elevator = new Elevator(); + wrist = new Wrist(); + claw = new Claw(); + oi = new OI(); + + // instantiate the command used for the autonomous period + autonomousCommand = new Autonomous(); + + // Show what command your subsystem is running on the SmartDashboard + SmartDashboard.putData(drivetrain); + SmartDashboard.putData(elevator); + SmartDashboard.putData(wrist); + SmartDashboard.putData(claw); + } + + public void autonomousInit() { + autonomousCommand.start(); // schedule the autonomous command (example) + } + + /** + * This function is called periodically during autonomous + */ + public void autonomousPeriodic() { + Scheduler.getInstance().run(); + log(); + } + + public void teleopInit() { + // This makes sure that the autonomous stops running when + // teleop starts running. If you want the autonomous to + // continue until interrupted by another command, remove + // this line or comment it out. + autonomousCommand.cancel(); + } + + /** + * This function is called periodically during operator control + */ + public void teleopPeriodic() { + Scheduler.getInstance().run(); + log(); + } + + /** + * This function is called periodically during test mode + */ + public void testPeriodic() { + LiveWindow.run(); + } + + /** + * The log method puts interesting information to the SmartDashboard. + */ + private void log() { + wrist.log(); + elevator.log(); + drivetrain.log(); + claw.log(); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/Autonomous.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/Autonomous.java new file mode 100644 index 0000000000..e2cfbe8f12 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/Autonomous.java @@ -0,0 +1,22 @@ + +package $package.commands; + +import edu.wpi.first.wpilibj.command.CommandGroup; + +/** + * The main autonomous command to pickup and deliver the + * soda to the box. + */ +public class Autonomous extends CommandGroup { + public Autonomous() { + addSequential(new PrepareToPickup()); + addSequential(new Pickup()); + addSequential(new SetDistanceToBox(0.10)); + // addSequential(new DriveStraight(4)); // Use Encoders if ultrasonic is broken + addSequential(new Place()); + addSequential(new SetDistanceToBox(0.60)); + // addSequential(new DriveStraight(-2)); // Use Encoders if ultrasonic is broken + addParallel(new SetWristSetpoint(-45)); + addSequential(new CloseClaw()); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/CloseClaw.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/CloseClaw.java new file mode 100644 index 0000000000..4a4cdfdde4 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/CloseClaw.java @@ -0,0 +1,47 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package $package.commands; + +import edu.wpi.first.wpilibj.command.Command; +import $package.Robot; + +/** + * Closes the claw for one second. Real robots should use sensors, stalling + * motors is BAD! + */ +public class CloseClaw extends Command { + + public CloseClaw() { + requires(Robot.claw); + } + + // Called just before this Command runs the first time + protected void initialize() { + Robot.claw.close(); + } + + // Called repeatedly when this Command is scheduled to run + protected void execute() { + } + + // Make this return true when this Command no longer needs to run execute() + protected boolean isFinished() { + return Robot.claw.isGrabbing(); + } + + // Called once after isFinished returns true + protected void end() { + // NOTE: Doesn't stop in simulation due to lower friction causing the can to fall out + // + there is no need to worry about stalling the motor or crushing the can. + if (!Robot.isSimulation()) + Robot.claw.stop(); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + protected void interrupted() { + end(); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/DriveStraight.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/DriveStraight.java new file mode 100644 index 0000000000..352856f038 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/DriveStraight.java @@ -0,0 +1,63 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package $package.commands; + +import edu.wpi.first.wpilibj.PIDController; +import edu.wpi.first.wpilibj.PIDOutput; +import edu.wpi.first.wpilibj.PIDSource; +import edu.wpi.first.wpilibj.command.Command; +import $package.Robot; + +/** + * Drive the given distance straight (negative values go backwards). + * Uses a local PID controller to run a simple PID loop that is only + * enabled while this command is running. The input is the averaged + * values of the left and right encoders. + */ +public class DriveStraight extends Command { + private PIDController pid; + + public DriveStraight(double distance) { + requires(Robot.drivetrain); + pid = new PIDController(4, 0, 0, + new PIDSource() { public double pidGet() { + return Robot.drivetrain.getDistance(); + }}, + new PIDOutput() { public void pidWrite(double d) { + Robot.drivetrain.drive(d, d); + }}); + pid.setAbsoluteTolerance(0.01); + pid.setSetpoint(distance); + } + + // Called just before this Command runs the first time + protected void initialize() { + // Get everything in a safe starting state. + Robot.drivetrain.reset(); + pid.reset(); + pid.enable(); + } + + // Called repeatedly when this Command is scheduled to run + protected void execute() {} + + // Make this return true when this Command no longer needs to run execute() + protected boolean isFinished() { + return pid.onTarget(); + } + + // Called once after isFinished returns true + protected void end() { + // Stop PID and the wheels + pid.disable(); + Robot.drivetrain.drive(0, 0); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + protected void interrupted() { + end(); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/OpenClaw.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/OpenClaw.java new file mode 100644 index 0000000000..ca8bfd1ce1 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/OpenClaw.java @@ -0,0 +1,45 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package $package.commands; + +import edu.wpi.first.wpilibj.command.Command; +import $package.Robot; + +/** + * Opens the claw for one second. Real robots should use sensors, stalling + * motors is BAD! + */ +public class OpenClaw extends Command { + + public OpenClaw() { + requires(Robot.claw); + setTimeout(1); + } + + // Called just before this Command runs the first time + protected void initialize() { + Robot.claw.open(); + } + + // Called repeatedly when this Command is scheduled to run + protected void execute() { + } + + // Make this return true when this Command no longer needs to run execute() + protected boolean isFinished() { + return isTimedOut(); + } + + // Called once after isFinished returns true + protected void end() { + Robot.claw.stop(); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + protected void interrupted() { + end(); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/Pickup.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/Pickup.java new file mode 100644 index 0000000000..940d2015c4 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/Pickup.java @@ -0,0 +1,15 @@ +package $package.commands; + +import edu.wpi.first.wpilibj.command.CommandGroup; + +/** + * Pickup a soda can (if one is between the open claws) and + * get it in a safe state to drive around. + */ +public class Pickup extends CommandGroup { + public Pickup() { + addSequential(new CloseClaw()); + addParallel(new SetWristSetpoint(-45)); + addSequential(new SetElevatorSetpoint(0.25)); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/Place.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/Place.java new file mode 100644 index 0000000000..ca060b8ff5 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/Place.java @@ -0,0 +1,14 @@ +package $package.commands; + +import edu.wpi.first.wpilibj.command.CommandGroup; + +/** + * Place a held soda can onto the platform. + */ +public class Place extends CommandGroup { + public Place() { + addSequential(new SetElevatorSetpoint(0.25)); + addSequential(new SetWristSetpoint(0)); + addSequential(new OpenClaw()); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/PrepareToPickup.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/PrepareToPickup.java new file mode 100644 index 0000000000..47c1f9e2d9 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/PrepareToPickup.java @@ -0,0 +1,14 @@ +package $package.commands; + +import edu.wpi.first.wpilibj.command.CommandGroup; + +/** + * Make sure the robot is in a state to pickup soda cans. + */ +public class PrepareToPickup extends CommandGroup { + public PrepareToPickup() { + addParallel(new OpenClaw()); + addParallel(new SetWristSetpoint(0)); + addSequential(new SetElevatorSetpoint(0)); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/SetDistanceToBox.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/SetDistanceToBox.java new file mode 100644 index 0000000000..c56e6c23d3 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/SetDistanceToBox.java @@ -0,0 +1,66 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package $package.commands; + +import edu.wpi.first.wpilibj.PIDController; +import edu.wpi.first.wpilibj.PIDOutput; +import edu.wpi.first.wpilibj.PIDSource; +import edu.wpi.first.wpilibj.command.Command; +import $package.Robot; + +/** + * Drive until the robot is the given distance away from the box. Uses a local + * PID controller to run a simple PID loop that is only enabled while this + * command is running. The input is the averaged values of the left and right + * encoders. + */ +public class SetDistanceToBox extends Command { + private PIDController pid; + + public SetDistanceToBox(double distance) { + requires(Robot.drivetrain); + pid = new PIDController(-2, 0, 0, new PIDSource() { + public double pidGet() { + return Robot.drivetrain.getDistanceToObstacle(); + } + }, new PIDOutput() { + public void pidWrite(double d) { + Robot.drivetrain.drive(d, d); + } + }); + pid.setAbsoluteTolerance(0.01); + pid.setSetpoint(distance); + } + + // Called just before this Command runs the first time + protected void initialize() { + // Get everything in a safe starting state. + Robot.drivetrain.reset(); + pid.reset(); + pid.enable(); + } + + // Called repeatedly when this Command is scheduled to run + protected void execute() { + } + + // Make this return true when this Command no longer needs to run execute() + protected boolean isFinished() { + return pid.onTarget(); + } + + // Called once after isFinished returns true + protected void end() { + // Stop PID and the wheels + pid.disable(); + Robot.drivetrain.drive(0, 0); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + protected void interrupted() { + end(); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/SetElevatorSetpoint.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/SetElevatorSetpoint.java new file mode 100644 index 0000000000..e4f9763e63 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/SetElevatorSetpoint.java @@ -0,0 +1,46 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package $package.commands; + +import edu.wpi.first.wpilibj.command.Command; +import $package.Robot; + +/** + * Move the elevator to a given location. This command finishes when it is within + * the tolerance, but leaves the PID loop running to maintain the position. Other + * commands using the elevator should make sure they disable PID! + */ +public class SetElevatorSetpoint extends Command { + private double setpoint; + + public SetElevatorSetpoint(double setpoint) { + this.setpoint = setpoint; + requires(Robot.elevator); + } + + // Called just before this Command runs the first time + protected void initialize() { + Robot.elevator.enable(); + Robot.elevator.setSetpoint(setpoint); + } + + // Called repeatedly when this Command is scheduled to run + protected void execute() { + } + + // Make this return true when this Command no longer needs to run execute() + protected boolean isFinished() { + return Robot.elevator.onTarget(); + } + + // Called once after isFinished returns true + protected void end() { + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + protected void interrupted() { + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/SetWristSetpoint.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/SetWristSetpoint.java new file mode 100644 index 0000000000..e2c95e6a84 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/SetWristSetpoint.java @@ -0,0 +1,46 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package $package.commands; + +import edu.wpi.first.wpilibj.command.Command; +import $package.Robot; + +/** + * Move the wrist to a given angle. This command finishes when it is within + * the tolerance, but leaves the PID loop running to maintain the position. + * Other commands using the wrist should make sure they disable PID! + */ +public class SetWristSetpoint extends Command { + private double setpoint; + + public SetWristSetpoint(double setpoint) { + this.setpoint = setpoint; + requires(Robot.wrist); + } + + // Called just before this Command runs the first time + protected void initialize() { + Robot.wrist.enable(); + Robot.wrist.setSetpoint(setpoint); + } + + // Called repeatedly when this Command is scheduled to run + protected void execute() { + } + + // Make this return true when this Command no longer needs to run execute() + protected boolean isFinished() { + return Robot.wrist.onTarget(); + } + + // Called once after isFinished returns true + protected void end() { + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + protected void interrupted() { + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/TankDriveWithJoystick.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/TankDriveWithJoystick.java new file mode 100644 index 0000000000..8296c4fd78 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/commands/TankDriveWithJoystick.java @@ -0,0 +1,42 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package $package.commands; + +import $package.Robot; +import edu.wpi.first.wpilibj.command.Command; + +/** + * Have the robot drive tank style using the PS3 Joystick until interrupted. + */ +public class TankDriveWithJoystick extends Command { + + public TankDriveWithJoystick() { + requires(Robot.drivetrain); + } + + // Called just before this Command runs the f iirst time + protected void initialize() {} + + // Called repeatedly when this Command is scheduled to run + protected void execute() { + Robot.drivetrain.drive(Robot.oi.getJoystick()); + } + + // Make this return true when this Command no longer needs to run execute() + protected boolean isFinished() { + return false; // Runs until interrupted + } + + // Called once after isFinished returns true + protected void end() { + Robot.drivetrain.drive(0, 0); + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + protected void interrupted() { + end(); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/subsystems/Claw.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/subsystems/Claw.java new file mode 100644 index 0000000000..f199317440 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/subsystems/Claw.java @@ -0,0 +1,63 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package $package.subsystems; + +import edu.wpi.first.wpilibj.DigitalInput; +import edu.wpi.first.wpilibj.SpeedController; +import edu.wpi.first.wpilibj.Victor; +import edu.wpi.first.wpilibj.command.Subsystem; +import edu.wpi.first.wpilibj.livewindow.LiveWindow; + +/** + * The claw subsystem is a simple system with a motor for opening and closing. + * If using stronger motors, you should probably use a sensor so that the + * motors don't stall. + */ +public class Claw extends Subsystem { + private SpeedController motor; + private DigitalInput contact; + + public Claw() { + super(); + motor = new Victor(7); + contact = new DigitalInput(5); + + // Let's show everything on the LiveWindow + LiveWindow.addActuator("Claw", "Motor", (Victor) motor); + LiveWindow.addActuator("Claw", "Limit Switch", contact); + } + + public void initDefaultCommand() {} + public void log() {} + + /** + * Set the claw motor to move in the open direction. + */ + public void open() { + motor.set(-1); + } + + /** + * Set the claw motor to move in the close direction. + */ + public void close() { + motor.set(1); + } + + /** + * Stops the claw motor from moving. + */ + public void stop() { + motor.set(0); + } + + /** + * Return true when the robot is grabbing an object hard enough + * to trigger the limit switch. + */ + public boolean isGrabbing() { + return contact.get(); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/subsystems/DriveTrain.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/subsystems/DriveTrain.java new file mode 100644 index 0000000000..c6c749e480 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/subsystems/DriveTrain.java @@ -0,0 +1,137 @@ +package $package.subsystems; + +import edu.wpi.first.wpilibj.AnalogChannel; +import edu.wpi.first.wpilibj.Encoder; +import edu.wpi.first.wpilibj.Joystick.AxisType; +import edu.wpi.first.wpilibj.Gyro; +import edu.wpi.first.wpilibj.Joystick; +import edu.wpi.first.wpilibj.RobotDrive; +import edu.wpi.first.wpilibj.SpeedController; +import edu.wpi.first.wpilibj.Talon; +import edu.wpi.first.wpilibj.command.Subsystem; +import edu.wpi.first.wpilibj.livewindow.LiveWindow; +import $package.Robot; +import $package.commands.TankDriveWithJoystick; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; + +/** + * The DriveTrain subsystem incorporates the sensors and actuators attached to + * the robots chassis. These include four drive motors, a left and right encoder + * and a gyro. + */ +public class DriveTrain extends Subsystem { + private SpeedController front_left_motor, back_left_motor, + front_right_motor, back_right_motor; + private RobotDrive drive; + private Encoder left_encoder, right_encoder; + private AnalogChannel rangefinder; + private Gyro gyro; + + public DriveTrain() { + super(); + front_left_motor = new Talon(1); + back_left_motor = new Talon(2); + front_right_motor = new Talon(3); + back_right_motor = new Talon(4); + drive = new RobotDrive(front_left_motor, back_left_motor, + front_right_motor, back_right_motor); + left_encoder = new Encoder(1, 2); + right_encoder = new Encoder(3, 4); + + // Encoders may measure differently in the real world and in + // simulation. In this example the robot moves 0.042 barleycorns + // per tick in the real world, but the simulated encoders + // simulate 360 tick encoders. This if statement allows for the + // real robot to handle this difference in devices. + if (Robot.isReal()) { + left_encoder.setDistancePerPulse(0.042); + right_encoder.setDistancePerPulse(0.042); + } else { + // Circumference in ft = 4in/12(in/ft)*PI + left_encoder.setDistancePerPulse((4.0/12.0*Math.PI) / 360.0); + right_encoder.setDistancePerPulse((4.0/12.0*Math.PI) / 360.0); + } + + left_encoder.start(); + right_encoder.start(); + + rangefinder = new AnalogChannel(6); + gyro = new Gyro(1); + + // Let's show everything on the LiveWindow + LiveWindow.addActuator("Drive Train", "Front_Left Motor", (Talon) front_left_motor); + LiveWindow.addActuator("Drive Train", "Back Left Motor", (Talon) back_left_motor); + LiveWindow.addActuator("Drive Train", "Front Right Motor", (Talon) front_right_motor); + LiveWindow.addActuator("Drive Train", "Back Right Motor", (Talon) back_right_motor); + LiveWindow.addSensor("Drive Train", "Left Encoder", left_encoder); + LiveWindow.addSensor("Drive Train", "Right Encoder", right_encoder); + LiveWindow.addSensor("Drive Train", "Rangefinder", rangefinder); + LiveWindow.addSensor("Drive Train", "Gyro", gyro); + } + + /** + * When no other command is running let the operator drive around + * using the PS3 joystick. + */ + public void initDefaultCommand() { + setDefaultCommand(new TankDriveWithJoystick()); + } + + /** + * The log method puts interesting information to the SmartDashboard. + */ + public void log() { + SmartDashboard.putNumber("Left Distance", left_encoder.getDistance()); + SmartDashboard.putNumber("Right Distance", right_encoder.getDistance()); + SmartDashboard.putNumber("Left Speed", left_encoder.getRate()); + SmartDashboard.putNumber("Right Speed", right_encoder.getRate()); + SmartDashboard.putNumber("Gyro", gyro.getAngle()); + } + + /** + * Tank style driving for the DriveTrain. + * @param left Speed in range [-1,1] + * @param right Speed in range [-1,1] + */ + public void drive(double left, double right) { + drive.tankDrive(left, right); + } + + /** + * @param joy The ps3 style joystick to use to drive tank style. + */ + public void drive(Joystick joy) { + drive(-joy.getY(), -joy.getAxis(AxisType.kThrottle)); + } + + /** + * @return The robots heading in degrees. + */ + public double getHeading() { + return gyro.getAngle(); + } + + /** + * Reset the robots sensors to the zero states. + */ + public void reset() { + gyro.reset(); + left_encoder.reset(); + right_encoder.reset(); + } + + /** + * @return The distance driven (average of left and right encoders). + */ + public double getDistance() { + return (left_encoder.getDistance() + right_encoder.getDistance())/2; + } + + /** + * @return The distance to the obstacle detected by the rangefinder. + */ + public double getDistanceToObstacle() { + // Really meters in simulation since it's a rangefinder... + return rangefinder.getAverageVoltage(); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/subsystems/Elevator.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/subsystems/Elevator.java new file mode 100644 index 0000000000..c14308f00a --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/subsystems/Elevator.java @@ -0,0 +1,75 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package $package.subsystems; + +import edu.wpi.first.wpilibj.AnalogPotentiometer; +import edu.wpi.first.wpilibj.SpeedController; +import edu.wpi.first.wpilibj.Victor; +import edu.wpi.first.wpilibj.command.PIDSubsystem; +import edu.wpi.first.wpilibj.interfaces.Potentiometer; +import edu.wpi.first.wpilibj.livewindow.LiveWindow; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; + +import $package.Robot; + +/** + * The elevator subsystem uses PID to go to a given height. Unfortunately, in it's current + * state PID values for simulation are different than in the real world do to minor differences. + */ +public class Elevator extends PIDSubsystem { + private SpeedController motor; + private Potentiometer pot; + + private static final double kP_real = 4, kI_real = 0.07, + kP_simulation = 18, kI_simulation = 0.2; + + public Elevator() { + super(kP_real, kI_real, 0); + if (Robot.isSimulation()) { // Check for simulation and update PID values + getPIDController().setPID(kP_simulation, kI_simulation, 0, 0); + } + setAbsoluteTolerance(0.005); + + motor = new Victor(5); + + // Conversion value of potentiometer varies between the real world and simulation + if (Robot.isReal()) { + pot = new AnalogPotentiometer(2, -2.0/5); + } else { + pot = new AnalogPotentiometer(2); // Defaults to meters + } + + // Let's show everything on the LiveWindow + LiveWindow.addActuator("Elevator", "Motor", (Victor) motor); + LiveWindow.addSensor("Elevator", "Pot", (AnalogPotentiometer) pot); + LiveWindow.addActuator("Elevator", "PID", getPIDController()); + } + + public void initDefaultCommand() {} + + /** + * The log method puts interesting information to the SmartDashboard. + */ + public void log() { + SmartDashboard.putData("Wrist Pot", (AnalogPotentiometer) pot); + } + + /** + * Use the potentiometer as the PID sensor. This method is automatically + * called by the subsystem. + */ + protected double returnPIDInput() { + return pot.get(); + } + + + /** + * Use the motor as the PID output. This method is automatically called by + * the subsystem. + */ + protected void usePIDOutput(double d) { + motor.set(d); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/subsystems/Wrist.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/subsystems/Wrist.java new file mode 100644 index 0000000000..b5ab894d30 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/GearsBot/src/org/usfirst/frc/team190/robot/subsystems/Wrist.java @@ -0,0 +1,74 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package $package.subsystems; + +import edu.wpi.first.wpilibj.AnalogPotentiometer; +import edu.wpi.first.wpilibj.SpeedController; +import edu.wpi.first.wpilibj.Victor; +import edu.wpi.first.wpilibj.command.PIDSubsystem; +import edu.wpi.first.wpilibj.interfaces.Potentiometer; +import edu.wpi.first.wpilibj.livewindow.LiveWindow; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; + +import $package.Robot; + +/** + * The wrist subsystem is like the elevator, but with a rotational joint instead + * of a linear joint. + */ +public class Wrist extends PIDSubsystem { + private SpeedController motor; + private Potentiometer pot; + + private static final double kP_real = 1, + kP_simulation = 0.05; + + public Wrist() { + super(kP_real, 0, 0); + if (Robot.isSimulation()) { // Check for simulation and update PID values + getPIDController().setPID(kP_simulation, 0, 0, 0); + } + setAbsoluteTolerance(2.5); + + motor = new Victor(6); + + // Conversion value of potentiometer varies between the real world and simulation + if (Robot.isReal()) { + pot = new AnalogPotentiometer(3, -270.0/5); + } else { + pot = new AnalogPotentiometer(3); // Defaults to degrees + } + + // Let's show everything on the LiveWindow + LiveWindow.addActuator("Wrist", "Motor", (Victor) motor); + LiveWindow.addSensor("Wrist", "Pot", (AnalogPotentiometer) pot); + LiveWindow.addActuator("Wrist", "PID", getPIDController()); + } + + public void initDefaultCommand() {} + + /** + * The log method puts interesting information to the SmartDashboard. + */ + public void log() { + SmartDashboard.putData("Wrist Angle", (AnalogPotentiometer) pot); + } + + /** + * Use the potentiometer as the PID sensor. This method is automatically + * called by the subsystem. + */ + protected double returnPIDInput() { + return pot.get(); + } + + /** + * Use the motor as the PID output. This method is automatically called by + * the subsystem. + */ + protected void usePIDOutput(double d) { + motor.set(d); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/examples.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/examples.xml index fbde882752..54be5d3453 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/examples.xml +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/examples.xml @@ -4,11 +4,19 @@ Simple Robot Examples for simple robot programs. + + CommandBased Robot + Examples for CommandBased robot programs. + + + Simulation + Examples that can be run in simulation. + Network Tables Examples of how to use Network Tables to accomplish a variety of tasks such as sending and receiving values to both - dashboards and co-processors.. + dashboards and co-processors. @@ -43,5 +51,37 @@ - + + + GearsBot + A fully functional example CommandBased program for WPIs GearsBot robot. This code can run on your computer if it supports simulation. + + CommandBased Robot + Simulation + + + src/$package-dir + src/$package-dir/commands + src/$package-dir/subsystems + + + + + + + + + + + + + + + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/WPILibJavaPlugin.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/WPILibJavaPlugin.java index 4b7143a6c6..af2c28cc91 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/WPILibJavaPlugin.java +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/WPILibJavaPlugin.java @@ -73,6 +73,7 @@ public class WPILibJavaPlugin extends AbstractUIPlugin implements IStartup { return props.getProperty("version"); } } catch (CoreException e) { + e.printStackTrace(System.err); return "DEVELOPMENT"; } } diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/launching/DeployLaunchShortcut.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/launching/DeployLaunchShortcut.java index c0305b8a18..f107d763fc 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/launching/DeployLaunchShortcut.java +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/launching/DeployLaunchShortcut.java @@ -1,39 +1,6 @@ package edu.wpi.first.wpilib.plugins.java.launching; -import java.io.File; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; -import java.util.Vector; - -import org.eclipse.core.internal.resources.Resource; -import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.ILaunchConfigurationType; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.debug.core.IStreamListener; -import org.eclipse.debug.core.model.IStreamMonitor; -import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.debug.ui.ILaunchShortcut; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; -import org.eclipse.jdt.launching.IVMConnector; -import org.eclipse.jdt.launching.JavaRuntime; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.PlatformUI; - -import com.sun.jdi.connect.Connector.Argument; - -import edu.wpi.first.wpilib.plugins.core.WPILibCore; -import edu.wpi.first.wpilib.plugins.core.launching.AntLauncher; /** * Launch shortcut base functionality, common for deploying to the robot. @@ -43,58 +10,7 @@ import edu.wpi.first.wpilib.plugins.core.launching.AntLauncher; * @author Ryan O'Meara * @author Alex Henning */ -@SuppressWarnings("restriction") -public class DeployLaunchShortcut implements ILaunchShortcut { - //Class constants - used to delineate types for launch shortcuts - public static final String DEPLOY_TYPE = "edu.wpi.first.wpilib.plugins.core.deploy"; - private static final String ANT_SERVER_THREAD_NAME = "Ant Build Server Connection"; - - // NOTE: This string must be changed if the port is changed. - private static final String DEBUG_START_TEXT = "Listening for transport dt_socket at address: 8348"; - - private static ILaunch lastDeploy = null; - - /** - * Returns the launch type of the shortcut that was used, one of the constants - * defined in BaseLaunchShortcut - * @return Launch shortcut type - */ - public String getLaunchType() {return DEPLOY_TYPE;} - - @Override - public void launch(ISelection selection, String mode) { - //Extract resource from selection - StructuredSelection sel = (StructuredSelection)selection; - IProject activeProject = null; - //NOTE: This caused issues earlier, as the sel return was treated as a workspace, instead of a project - //When it is a valid FIRST project, the selection is always a JavaProject - if(sel.getFirstElement() instanceof IJavaProject){ - activeProject = ((IJavaProject)sel.getFirstElement()).getProject(); - }else if(sel.getFirstElement() instanceof IJavaElement){ - activeProject = ((IJavaElement)sel.getFirstElement()).getJavaProject().getProject(); - }else{ - return; - } - - //Run config using project found in extracted resource, with indicated mode - runConfig(activeProject, mode); - } - - @Override - public void launch(IEditorPart editor, String mode) { - //Extract resource from editor - if(editor != null){ - IFileEditorInput input = (IFileEditorInput)editor.getEditorInput(); - IFile file = input.getFile(); - IProject activeProject = file.getProject(); - - //If editor existed, run config using extracted resource in indicated mode - runConfig(activeProject, mode); - }else{ - System.err.println("editor was null"); - } - - } +public class DeployLaunchShortcut extends JavaLaunchShortcut { /** * Runs the ant script using the correct target for the indicated mode (deploy to cRIO or just compile) @@ -102,106 +18,7 @@ public class DeployLaunchShortcut implements ILaunchShortcut { * @param mode The mode it will be run in (ILaunchManager.RUN_MODE or ILaunchManager.DEBUG_MODE) */ public void runConfig(IProject activeProj, String mode){ - String targets = "deploy"; - - if(mode.equals(ILaunchManager.RUN_MODE)){ - if(getLaunchType().equals(DEPLOY_TYPE)){ - targets = "deploy"; - } - } else if ((mode.equals(ILaunchManager.DEBUG_MODE))&&(getLaunchType().equals(DEPLOY_TYPE))) { - targets = "debug-deploy"; - try{ - PlatformUI.getWorkbench().showPerspective(IDebugUIConstants.ID_DEBUG_PERSPECTIVE, - PlatformUI.getWorkbench().getActiveWorkbenchWindow()); - - }catch(Exception e){} - } - - if((lastDeploy != null)&&(!lastDeploy.isTerminated())){ - System.out.println("Last deploy running"); - //Find the server connection thread and kill it - Vector threadGroups = new Vector(); - ThreadGroup root = Thread.currentThread().getThreadGroup().getParent(); - while (root.getParent() != null) {root = root.getParent();} - threadGroups.add(root); - ThreadGroup threadGroup = threadGroups.remove(0); - int numThreads = threadGroup.activeCount(); - Thread[] threads = new Thread[numThreads*100]; - numThreads = threadGroup.enumerate(threads, true); - - for(Thread current: threads){ - if(current != null){ - if(current.getName().equals(ANT_SERVER_THREAD_NAME)){ - try{ - //Manually end thread and then try terminating launch - Method stopMethod = current.getClass().getMethod("stop"); - stopMethod.invoke(current); - lastDeploy.terminate(); - break; - }catch(Exception e){e.printStackTrace();} - } - } - } - - System.out.println("Waiting"); - try{wait(1000);}catch(Exception e){} - - } - - System.out.println("Running ant file: " + activeProj.getLocation().toOSString() + File.separator + "build.xml"); - System.out.println("Targets: " + targets + ", Mode: " + mode); - lastDeploy = AntLauncher.runAntFile(new File (activeProj.getLocation().toOSString() + File.separator + "build.xml"), targets, null, mode); - - if((mode.equals(ILaunchManager.DEBUG_MODE))&&(getLaunchType().equals(DEPLOY_TYPE))) { - ILaunchConfigurationWorkingCopy config; - try { - config = getRemoteDebugConfig(activeProj); - startDebugConfig(config, lastDeploy); - } catch (CoreException e) { - System.err.println("Debug attach failed."); - e.printStackTrace(); - } - } - - try { - activeProj.refreshLocal(Resource.DEPTH_INFINITE, null); - } catch (Exception e) {} - } - - private ILaunchConfigurationWorkingCopy getRemoteDebugConfig(IProject activeProj) throws CoreException { - ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); - ILaunchConfigurationType type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_REMOTE_JAVA_APPLICATION); - ILaunchConfigurationWorkingCopy config = type.newInstance(null, "Debug "+activeProj.getName()); - config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, activeProj.getName()); - config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_ALLOW_TERMINATE, true); - config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_CONNECTOR, IJavaLaunchConfigurationConstants.ID_SOCKET_ATTACH_VM_CONNECTOR); - IVMConnector connector = JavaRuntime.getVMConnector(IJavaLaunchConfigurationConstants.ID_SOCKET_ATTACH_VM_CONNECTOR); - Map def = connector.getDefaultArguments(); - Map argMap = new HashMap(def.size()); - argMap.put("hostname", WPILibCore.getDefault().getTargetIP(activeProj)); - argMap.put("port", "8348"); - System.out.println(argMap); - config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, argMap); - return config; - } - - private void startDebugConfig(final ILaunchConfigurationWorkingCopy config, ILaunch deploy) throws CoreException { - IStreamListener listener = new IStreamListener() { - @Override - public void streamAppended(String text, IStreamMonitor monitor) { - if (text.contains(DEBUG_START_TEXT)) { - try { - config.launch(ILaunchManager.DEBUG_MODE, null); - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - monitor.removeListener(this); - } - } - }; - deploy.getProcesses()[0].getStreamsProxy().getOutputStreamMonitor().addListener(listener); - + runConfigHelper(activeProj, mode, "deploy", "debug-deploy"); } } diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/launching/JavaLaunchShortcut.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/launching/JavaLaunchShortcut.java new file mode 100644 index 0000000000..9518907175 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/launching/JavaLaunchShortcut.java @@ -0,0 +1,208 @@ +package edu.wpi.first.wpilib.plugins.java.launching; + +import java.io.File; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; +import java.util.Vector; + +import org.eclipse.core.internal.resources.Resource; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.debug.core.IStreamListener; +import org.eclipse.debug.core.model.IStreamMonitor; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.debug.ui.ILaunchShortcut; +import org.eclipse.jdt.core.IJavaElement; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; +import org.eclipse.jdt.launching.IVMConnector; +import org.eclipse.jdt.launching.JavaRuntime; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.PlatformUI; + +import com.sun.jdi.connect.Connector.Argument; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; +import edu.wpi.first.wpilib.plugins.core.launching.AntLauncher; + +@SuppressWarnings("restriction") +public abstract class JavaLaunchShortcut implements ILaunchShortcut { + //Class constants - used to delineate types for launch shortcuts + public static final String DEPLOY_TYPE = "edu.wpi.first.wpilib.plugins.core.deploy"; + private static final String ANT_SERVER_THREAD_NAME = "Ant Build Server Connection"; + + // NOTE: This string must be changed if the port is changed. + private static final String DEBUG_START_TEXT = "Listening for transport dt_socket at address: 8348"; + + private static ILaunch lastDeploy = null; + + /** + * Returns the launch type of the shortcut that was used, one of the constants + * defined in BaseLaunchShortcut + * @return Launch shortcut type + */ + public String getLaunchType() {return DEPLOY_TYPE;} + + public void launch(ISelection selection, String mode) { + //Extract resource from selection + StructuredSelection sel = (StructuredSelection)selection; + IProject activeProject = null; + //NOTE: This caused issues earlier, as the sel return was treated as a workspace, instead of a project + //When it is a valid FIRST project, the selection is always a JavaProject + if(sel.getFirstElement() instanceof IJavaProject){ + activeProject = ((IJavaProject)sel.getFirstElement()).getProject(); + }else if(sel.getFirstElement() instanceof IJavaElement){ + activeProject = ((IJavaElement)sel.getFirstElement()).getJavaProject().getProject(); + }else{ + return; + } + + //Run config using project found in extracted resource, with indicated mode + runConfig(activeProject, mode); + } + + @Override + public void launch(IEditorPart editor, String mode) { + //Extract resource from editor + if(editor != null){ + IFileEditorInput input = (IFileEditorInput)editor.getEditorInput(); + IFile file = input.getFile(); + IProject activeProject = file.getProject(); + + //If editor existed, run config using extracted resource in indicated mode + runConfig(activeProject, mode); + }else{ + System.err.println("editor was null"); + } + + } + + /** + * Runs the ant script using the correct target for the indicated mode (deploy to cRIO or just compile) + * @param activeProj The project that the script will be run on/from + * @param mode The mode it will be run in (ILaunchManager.RUN_MODE or ILaunchManager.DEBUG_MODE) + * @return + */ + public abstract void runConfig(IProject activeProj, String mode); + + /** + * Runs the ant script using the correct target for the indicated mode (deploy to cRIO or just compile) + * @param activeProj The project that the script will be run on/from + * @param mode The mode it will be run in (ILaunchManager.RUN_MODE or ILaunchManager.DEBUG_MODE) + */ + protected void runConfigHelper(IProject activeProj, String mode, String runTarget, String debugTarget){ + String targets = runTarget; + + if(mode.equals(ILaunchManager.RUN_MODE)){ + if(getLaunchType().equals(DEPLOY_TYPE)){ + targets = runTarget; + } + } else if ((mode.equals(ILaunchManager.DEBUG_MODE))&&(getLaunchType().equals(DEPLOY_TYPE))) { + targets = debugTarget; + try{ + PlatformUI.getWorkbench().showPerspective(IDebugUIConstants.ID_DEBUG_PERSPECTIVE, + PlatformUI.getWorkbench().getActiveWorkbenchWindow()); + + }catch(Exception e){} + } + + if((lastDeploy != null)&&(!lastDeploy.isTerminated())){ + System.out.println("Last deploy running"); + //Find the server connection thread and kill it + Vector threadGroups = new Vector(); + ThreadGroup root = Thread.currentThread().getThreadGroup().getParent(); + while (root.getParent() != null) {root = root.getParent();} + threadGroups.add(root); + ThreadGroup threadGroup = threadGroups.remove(0); + int numThreads = threadGroup.activeCount(); + Thread[] threads = new Thread[numThreads*100]; + numThreads = threadGroup.enumerate(threads, true); + + for(Thread current: threads){ + if(current != null){ + if(current.getName().equals(ANT_SERVER_THREAD_NAME)){ + try{ + //Manually end thread and then try terminating launch + Method stopMethod = current.getClass().getMethod("stop"); + stopMethod.invoke(current); + lastDeploy.terminate(); + break; + }catch(Exception e){e.printStackTrace();} + } + } + } + + System.out.println("Waiting"); + try{wait(1000);}catch(Exception e){} + + } + + System.out.println("Running ant file: " + activeProj.getLocation().toOSString() + File.separator + "build.xml"); + System.out.println("Targets: " + targets + ", Mode: " + mode); + lastDeploy = AntLauncher.runAntFile(new File (activeProj.getLocation().toOSString() + File.separator + "build.xml"), targets, null, mode); + + if((mode.equals(ILaunchManager.DEBUG_MODE))&&(getLaunchType().equals(DEPLOY_TYPE))) { + ILaunchConfigurationWorkingCopy config; + try { + config = getRemoteDebugConfig(activeProj); + startDebugConfig(config, lastDeploy); + } catch (CoreException e) { + System.err.println("Debug attach failed."); + e.printStackTrace(); + } + } + + try { + activeProj.refreshLocal(Resource.DEPTH_INFINITE, null); + } catch (Exception e) {} + } + + private ILaunchConfigurationWorkingCopy getRemoteDebugConfig(IProject activeProj) throws CoreException { + ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); + ILaunchConfigurationType type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_REMOTE_JAVA_APPLICATION); + ILaunchConfigurationWorkingCopy config = type.newInstance(null, "Debug "+activeProj.getName()); + config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, activeProj.getName()); + config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_ALLOW_TERMINATE, true); + config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_CONNECTOR, IJavaLaunchConfigurationConstants.ID_SOCKET_ATTACH_VM_CONNECTOR); + IVMConnector connector = JavaRuntime.getVMConnector(IJavaLaunchConfigurationConstants.ID_SOCKET_ATTACH_VM_CONNECTOR); + Map def = connector.getDefaultArguments(); + Map argMap = new HashMap(def.size()); + argMap.put("hostname", getHostname(activeProj)); + argMap.put("port", "8348"); + System.out.println(argMap); + config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, argMap); + return config; + } + + protected String getHostname(IProject proj) { + return WPILibCore.getDefault().getTargetIP(proj); + } + + private void startDebugConfig(final ILaunchConfigurationWorkingCopy config, ILaunch deploy) throws CoreException { + IStreamListener listener = new IStreamListener() { + @Override + public void streamAppended(String text, IStreamMonitor monitor) { + if (text.contains(DEBUG_START_TEXT)) { + try { + config.launch(ILaunchManager.DEBUG_MODE, null); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + monitor.removeListener(this); + } + } + }; + deploy.getProcesses()[0].getStreamsProxy().getOutputStreamMonitor().addListener(listener); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/launching/SimulateLaunchShortcut.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/launching/SimulateLaunchShortcut.java new file mode 100644 index 0000000000..7d5763db0d --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/launching/SimulateLaunchShortcut.java @@ -0,0 +1,20 @@ +package edu.wpi.first.wpilib.plugins.java.launching; + +import org.eclipse.core.resources.IProject; + +public class SimulateLaunchShortcut extends JavaLaunchShortcut { + + + /** + * Runs the ant script using the correct target for the indicated mode (deploy to cRIO or just compile) + * @param activeProj The project that the script will be run on/from + * @param mode The mode it will be run in (ILaunchManager.RUN_MODE or ILaunchManager.DEBUG_MODE) + */ + public void runConfig(IProject activeProj, String mode){ + runConfigHelper(activeProj, mode, "simulate", "debug-simulate"); + } + + protected String getHostname(IProject proj) { + return "localhost"; + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/examples/ExampleJavaWizard.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/examples/ExampleJavaWizard.java index 9f59ae3eaf..d403194e76 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/examples/ExampleJavaWizard.java +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/examples/ExampleJavaWizard.java @@ -35,7 +35,8 @@ public class ExampleJavaWizard extends ExampleWizard { final String projectName = detailsPage.getProjectName(); final String packageName = detailsPage.getPackage(); - ProjectCreationUtils.createProject(new WPIRobotJavaProjectCreator(projectName, packageName, ex)); + final String worldName = detailsPage.getWorld(); + ProjectCreationUtils.createProject(new WPIRobotJavaProjectCreator(projectName, packageName, ex, worldName)); } @Override diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/newproject/NewJavaWizard.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/newproject/NewJavaWizard.java index 58ab10265b..348f70542a 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/newproject/NewJavaWizard.java +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/newproject/NewJavaWizard.java @@ -72,11 +72,12 @@ public class NewJavaWizard extends Wizard implements INewWizard { final String teamNumber = TeamNumberPage.getTeamNumberFromPage(teamNumberPage); final String packageName = page.getPackage(); final ProjectType projectType = page.getProjectType(); + final String worldName = page.getWorld(); System.out.println("Project: "+projectName+" Package: "+packageName+" Project Type: "+projectType); IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { try { - doFinish(projectName, teamNumber, packageName, projectType, monitor); + doFinish(projectName, teamNumber, packageName, projectType, worldName, monitor); } catch (CoreException e) { throw new InvocationTargetException(e); } finally { @@ -102,11 +103,11 @@ public class NewJavaWizard extends Wizard implements INewWizard { * the editor on the newly created file. */ - private void doFinish(String projectName, String teamNumber, String packageName, ProjectType projectType, IProgressMonitor monitor) throws CoreException { + private void doFinish(String projectName, String teamNumber, String packageName, ProjectType projectType, String worldName, IProgressMonitor monitor) throws CoreException { Properties props = WPILibCore.getDefault().getProjectProperties(null); props.setProperty("team-number", teamNumber); WPILibCore.getDefault().saveGlobalProperties(props); - ProjectCreationUtils.createProject(new WPIRobotJavaProjectCreator(projectName, packageName, projectType)); + ProjectCreationUtils.createProject(new WPIRobotJavaProjectCreator(projectName, packageName, projectType, worldName)); } /** diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/newproject/WPIRobotJavaProjectCreator.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/newproject/WPIRobotJavaProjectCreator.java index 4a47f9fb98..458b561293 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/newproject/WPIRobotJavaProjectCreator.java +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/newproject/WPIRobotJavaProjectCreator.java @@ -15,13 +15,14 @@ import edu.wpi.first.wpilib.plugins.core.wizards.ProjectType; import edu.wpi.first.wpilib.plugins.java.WPILibJavaPlugin; public class WPIRobotJavaProjectCreator implements IProjectCreator { - String projectName, packageName; + String projectName, packageName, worldName; ProjectType projectType; - public WPIRobotJavaProjectCreator(String projectName, String packageName, ProjectType projectType) { + public WPIRobotJavaProjectCreator(String projectName, String packageName, ProjectType projectType, String worldName) { this.projectName = projectName; this.packageName = packageName; this.projectType = projectType; + this.worldName = worldName; } @Override @@ -39,6 +40,7 @@ public class WPIRobotJavaProjectCreator implements IProjectCreator { Map vals = new HashMap(); vals.put("$project", projectName); vals.put("$package", packageName); + vals.put("$world", worldName); return vals; } diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/build.properties index e1ad10d1c7..b26e18a6f9 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/build.properties +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/build.properties @@ -28,4 +28,10 @@ src.dir=src build.dir=build build.jars=${build.dir}/jars dist.dir=dist -dist.jar=${dist.dir}/${jar} \ No newline at end of file +dist.jar=${dist.dir}/${jar} + +# Simulation Information +simulation.dist.jar=${dist.dir}/FRCUserProgramSim.jar +wpilib.sim=${wpilib}/sim +wpilib.sim.lib=${wpilib.sim}/lib +wpilib.sim.tools=${wpilib.sim}/tools \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/build.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/build.xml index 7be9de61c1..d9e0878e60 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/build.xml +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/build.xml @@ -55,9 +55,9 @@ - - - + + + @@ -96,4 +96,73 @@ trust="true" command="chmod a+x debug*program; ${deploy.debug.command}"/> + + + + [jar-for-simulation] Building jar. + + + + + + + + + + + + + + + + + + [simulate] Running Gazebo. + + + + + + + [simulate] Running DriverStation. + + + + + + + [simulate] Running Code. + + + + + + + + + + + [debug-simulate] Running Gazebo. + + + + + + + [debug-simulate] Running DriverStation. + + + + + + + [debug-simulate] Running Code. + + + + + + + + diff --git a/hal/include/HAL/cpp/Synchronized.hpp b/hal/include/HAL/cpp/Synchronized.hpp index da631d2522..351d6b1653 100644 --- a/hal/include/HAL/cpp/Synchronized.hpp +++ b/hal/include/HAL/cpp/Synchronized.hpp @@ -5,7 +5,7 @@ /*----------------------------------------------------------------------------*/ #pragma once -#include "HAL/HAL.hpp" +#include "HAL/Semaphore.hpp" // A macro to disallow the copy constructor and operator= functions // This should be used in the private: declarations for a class diff --git a/hal/lib/Athena/Analog.cpp b/hal/lib/Athena/Analog.cpp index ee439ce579..7bf5e00724 100644 --- a/hal/lib/Athena/Analog.cpp +++ b/hal/lib/Athena/Analog.cpp @@ -2,8 +2,7 @@ #include "HAL/Analog.hpp" #include "Port.h" -#include "HAL/Errors.hpp" -#include "HAL/Semaphore.hpp" +#include "HAL/HAL.hpp" #include "ChipObject.h" #include "HAL/cpp/Synchronized.hpp" #include "HAL/cpp/Resource.hpp" diff --git a/hal/lib/Athena/Semaphore.cpp b/hal/lib/Athena/Semaphore.cpp index df24bf16f9..e76b8ad139 100644 --- a/hal/lib/Athena/Semaphore.cpp +++ b/hal/lib/Athena/Semaphore.cpp @@ -1,7 +1,6 @@ #include "HAL/Semaphore.hpp" -#include "ChipObject.h" #include "Log.hpp" // set the logging level diff --git a/hal/lib/Athena/Task.cpp b/hal/lib/Athena/Task.cpp index ebf92b83f4..f509c28e77 100644 --- a/hal/lib/Athena/Task.cpp +++ b/hal/lib/Athena/Task.cpp @@ -1,9 +1,6 @@ #include "HAL/Task.hpp" -#include "HAL/HAL.hpp" -#include "ChipObject.h" - #include #include diff --git a/hal/lib/Athena/cpp/StackTrace.cpp b/hal/lib/Athena/cpp/StackTrace.cpp index 72c0733111..aaedbb7672 100644 --- a/hal/lib/Athena/cpp/StackTrace.cpp +++ b/hal/lib/Athena/cpp/StackTrace.cpp @@ -1,8 +1,6 @@ #include "HAL/cpp/StackTrace.hpp" -#include "HAL/HAL.hpp" -#include "../ChipObject.h" #include diff --git a/networktables/cpp/include/networktables2/connection/DataIOStream.h b/networktables/cpp/include/networktables2/connection/DataIOStream.h index a653892137..4db3d7b528 100644 --- a/networktables/cpp/include/networktables2/connection/DataIOStream.h +++ b/networktables/cpp/include/networktables2/connection/DataIOStream.h @@ -25,8 +25,6 @@ + ((n & 0x01000000LU) ? 64 : 0) \ + ((n & 0x10000000LU) ? 128 : 0)) -#define b(n) ((unsigned char)BINARY_LITERAL_VIA_HEX__(TO_HEX__(n))) - class DataIOStream{ public: DataIOStream(IOStream* stream); @@ -49,3 +47,4 @@ public: #endif + diff --git a/pom.xml b/pom.xml index 1c682ddbb1..2dd479337b 100644 --- a/pom.xml +++ b/pom.xml @@ -11,6 +11,7 @@ networktables wpilibj driver-station + simulation @@ -23,6 +24,7 @@ + wpilibc/wpilibC++Sim eclipse-plugins diff --git a/simulation/JavaGazebo/pom.xml b/simulation/JavaGazebo/pom.xml new file mode 100644 index 0000000000..60e4f2f687 --- /dev/null +++ b/simulation/JavaGazebo/pom.xml @@ -0,0 +1,62 @@ + + + 4.0.0 + org.gazebosim + JavaGazebo + jar + 0.1.0-SNAPSHOT + + + + docline-java8-disable + + [1.8, + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + -Xdoclint:none + + + + + + + + + + com.google.protobuf + protobuf-java + 2.5.0 + + + + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + + org.apache.maven.plugins + maven-source-plugin + + + + diff --git a/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzBool.java b/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzBool.java new file mode 100644 index 0000000000..dd3abd15ed --- /dev/null +++ b/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzBool.java @@ -0,0 +1,453 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: frc_gazebo_plugin/msgs/bool.proto + +package gazebo.msgs; + +public final class GzBool { + private GzBool() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + public interface BoolOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required bool data = 1; + /** + * required bool data = 1; + */ + boolean hasData(); + /** + * required bool data = 1; + */ + boolean getData(); + } + /** + * Protobuf type {@code gazebo.msgs.Bool} + */ + public static final class Bool extends + com.google.protobuf.GeneratedMessage + implements BoolOrBuilder { + // Use Bool.newBuilder() to construct. + private Bool(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private Bool(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final Bool defaultInstance; + public static Bool getDefaultInstance() { + return defaultInstance; + } + + public Bool getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Bool( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + bitField0_ |= 0x00000001; + data_ = input.readBool(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return gazebo.msgs.GzBool.internal_static_gazebo_msgs_Bool_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return gazebo.msgs.GzBool.internal_static_gazebo_msgs_Bool_fieldAccessorTable + .ensureFieldAccessorsInitialized( + gazebo.msgs.GzBool.Bool.class, gazebo.msgs.GzBool.Bool.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public Bool parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Bool(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required bool data = 1; + public static final int DATA_FIELD_NUMBER = 1; + private boolean data_; + /** + * required bool data = 1; + */ + public boolean hasData() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required bool data = 1; + */ + public boolean getData() { + return data_; + } + + private void initFields() { + data_ = false; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasData()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBool(1, data_); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(1, data_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static gazebo.msgs.GzBool.Bool parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static gazebo.msgs.GzBool.Bool parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static gazebo.msgs.GzBool.Bool parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static gazebo.msgs.GzBool.Bool parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static gazebo.msgs.GzBool.Bool parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static gazebo.msgs.GzBool.Bool parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static gazebo.msgs.GzBool.Bool parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static gazebo.msgs.GzBool.Bool parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static gazebo.msgs.GzBool.Bool parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static gazebo.msgs.GzBool.Bool parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(gazebo.msgs.GzBool.Bool prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code gazebo.msgs.Bool} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements gazebo.msgs.GzBool.BoolOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return gazebo.msgs.GzBool.internal_static_gazebo_msgs_Bool_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return gazebo.msgs.GzBool.internal_static_gazebo_msgs_Bool_fieldAccessorTable + .ensureFieldAccessorsInitialized( + gazebo.msgs.GzBool.Bool.class, gazebo.msgs.GzBool.Bool.Builder.class); + } + + // Construct using gazebo.msgs.GzBool.Bool.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + data_ = false; + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return gazebo.msgs.GzBool.internal_static_gazebo_msgs_Bool_descriptor; + } + + public gazebo.msgs.GzBool.Bool getDefaultInstanceForType() { + return gazebo.msgs.GzBool.Bool.getDefaultInstance(); + } + + public gazebo.msgs.GzBool.Bool build() { + gazebo.msgs.GzBool.Bool result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public gazebo.msgs.GzBool.Bool buildPartial() { + gazebo.msgs.GzBool.Bool result = new gazebo.msgs.GzBool.Bool(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.data_ = data_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof gazebo.msgs.GzBool.Bool) { + return mergeFrom((gazebo.msgs.GzBool.Bool)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(gazebo.msgs.GzBool.Bool other) { + if (other == gazebo.msgs.GzBool.Bool.getDefaultInstance()) return this; + if (other.hasData()) { + setData(other.getData()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasData()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + gazebo.msgs.GzBool.Bool parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (gazebo.msgs.GzBool.Bool) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required bool data = 1; + private boolean data_ ; + /** + * required bool data = 1; + */ + public boolean hasData() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required bool data = 1; + */ + public boolean getData() { + return data_; + } + /** + * required bool data = 1; + */ + public Builder setData(boolean value) { + bitField0_ |= 0x00000001; + data_ = value; + onChanged(); + return this; + } + /** + * required bool data = 1; + */ + public Builder clearData() { + bitField0_ = (bitField0_ & ~0x00000001); + data_ = false; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:gazebo.msgs.Bool) + } + + static { + defaultInstance = new Bool(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:gazebo.msgs.Bool) + } + + private static com.google.protobuf.Descriptors.Descriptor + internal_static_gazebo_msgs_Bool_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_gazebo_msgs_Bool_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n!frc_gazebo_plugin/msgs/bool.proto\022\013gaz" + + "ebo.msgs\"\024\n\004Bool\022\014\n\004data\030\001 \002(\010B\010B\006GzBool" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + internal_static_gazebo_msgs_Bool_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_gazebo_msgs_Bool_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_gazebo_msgs_Bool_descriptor, + new java.lang.String[] { "Data", }); + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzDriverStation.java b/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzDriverStation.java new file mode 100644 index 0000000000..c3e967db5d --- /dev/null +++ b/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzDriverStation.java @@ -0,0 +1,645 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: frc_gazebo_plugin/msgs/driver-station.proto + +package gazebo.msgs; + +public final class GzDriverStation { + private GzDriverStation() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + public interface DriverStationOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required bool enabled = 1; + /** + * required bool enabled = 1; + */ + boolean hasEnabled(); + /** + * required bool enabled = 1; + */ + boolean getEnabled(); + + // required .gazebo.msgs.DriverStation.State state = 2; + /** + * required .gazebo.msgs.DriverStation.State state = 2; + */ + boolean hasState(); + /** + * required .gazebo.msgs.DriverStation.State state = 2; + */ + gazebo.msgs.GzDriverStation.DriverStation.State getState(); + } + /** + * Protobuf type {@code gazebo.msgs.DriverStation} + */ + public static final class DriverStation extends + com.google.protobuf.GeneratedMessage + implements DriverStationOrBuilder { + // Use DriverStation.newBuilder() to construct. + private DriverStation(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private DriverStation(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final DriverStation defaultInstance; + public static DriverStation getDefaultInstance() { + return defaultInstance; + } + + public DriverStation getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private DriverStation( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + bitField0_ |= 0x00000001; + enabled_ = input.readBool(); + break; + } + case 16: { + int rawValue = input.readEnum(); + gazebo.msgs.GzDriverStation.DriverStation.State value = gazebo.msgs.GzDriverStation.DriverStation.State.valueOf(rawValue); + if (value == null) { + unknownFields.mergeVarintField(2, rawValue); + } else { + bitField0_ |= 0x00000002; + state_ = value; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return gazebo.msgs.GzDriverStation.internal_static_gazebo_msgs_DriverStation_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return gazebo.msgs.GzDriverStation.internal_static_gazebo_msgs_DriverStation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + gazebo.msgs.GzDriverStation.DriverStation.class, gazebo.msgs.GzDriverStation.DriverStation.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public DriverStation parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new DriverStation(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + /** + * Protobuf enum {@code gazebo.msgs.DriverStation.State} + */ + public enum State + implements com.google.protobuf.ProtocolMessageEnum { + /** + * AUTO = 0; + */ + AUTO(0, 0), + /** + * TELEOP = 1; + */ + TELEOP(1, 1), + /** + * TEST = 2; + */ + TEST(2, 2), + ; + + /** + * AUTO = 0; + */ + public static final int AUTO_VALUE = 0; + /** + * TELEOP = 1; + */ + public static final int TELEOP_VALUE = 1; + /** + * TEST = 2; + */ + public static final int TEST_VALUE = 2; + + + public final int getNumber() { return value; } + + public static State valueOf(int value) { + switch (value) { + case 0: return AUTO; + case 1: return TELEOP; + case 2: return TEST; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static com.google.protobuf.Internal.EnumLiteMap + internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public State findValueByNumber(int number) { + return State.valueOf(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(index); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return gazebo.msgs.GzDriverStation.DriverStation.getDescriptor().getEnumTypes().get(0); + } + + private static final State[] VALUES = values(); + + public static State valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + return VALUES[desc.getIndex()]; + } + + private final int index; + private final int value; + + private State(int index, int value) { + this.index = index; + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:gazebo.msgs.DriverStation.State) + } + + private int bitField0_; + // required bool enabled = 1; + public static final int ENABLED_FIELD_NUMBER = 1; + private boolean enabled_; + /** + * required bool enabled = 1; + */ + public boolean hasEnabled() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required bool enabled = 1; + */ + public boolean getEnabled() { + return enabled_; + } + + // required .gazebo.msgs.DriverStation.State state = 2; + public static final int STATE_FIELD_NUMBER = 2; + private gazebo.msgs.GzDriverStation.DriverStation.State state_; + /** + * required .gazebo.msgs.DriverStation.State state = 2; + */ + public boolean hasState() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required .gazebo.msgs.DriverStation.State state = 2; + */ + public gazebo.msgs.GzDriverStation.DriverStation.State getState() { + return state_; + } + + private void initFields() { + enabled_ = false; + state_ = gazebo.msgs.GzDriverStation.DriverStation.State.AUTO; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasEnabled()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasState()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBool(1, enabled_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeEnum(2, state_.getNumber()); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(1, enabled_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(2, state_.getNumber()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static gazebo.msgs.GzDriverStation.DriverStation parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static gazebo.msgs.GzDriverStation.DriverStation parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static gazebo.msgs.GzDriverStation.DriverStation parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static gazebo.msgs.GzDriverStation.DriverStation parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static gazebo.msgs.GzDriverStation.DriverStation parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static gazebo.msgs.GzDriverStation.DriverStation parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static gazebo.msgs.GzDriverStation.DriverStation parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static gazebo.msgs.GzDriverStation.DriverStation parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static gazebo.msgs.GzDriverStation.DriverStation parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static gazebo.msgs.GzDriverStation.DriverStation parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(gazebo.msgs.GzDriverStation.DriverStation prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code gazebo.msgs.DriverStation} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements gazebo.msgs.GzDriverStation.DriverStationOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return gazebo.msgs.GzDriverStation.internal_static_gazebo_msgs_DriverStation_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return gazebo.msgs.GzDriverStation.internal_static_gazebo_msgs_DriverStation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + gazebo.msgs.GzDriverStation.DriverStation.class, gazebo.msgs.GzDriverStation.DriverStation.Builder.class); + } + + // Construct using gazebo.msgs.GzDriveStation.DriverStation.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + enabled_ = false; + bitField0_ = (bitField0_ & ~0x00000001); + state_ = gazebo.msgs.GzDriverStation.DriverStation.State.AUTO; + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return gazebo.msgs.GzDriverStation.internal_static_gazebo_msgs_DriverStation_descriptor; + } + + public gazebo.msgs.GzDriverStation.DriverStation getDefaultInstanceForType() { + return gazebo.msgs.GzDriverStation.DriverStation.getDefaultInstance(); + } + + public gazebo.msgs.GzDriverStation.DriverStation build() { + gazebo.msgs.GzDriverStation.DriverStation result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public gazebo.msgs.GzDriverStation.DriverStation buildPartial() { + gazebo.msgs.GzDriverStation.DriverStation result = new gazebo.msgs.GzDriverStation.DriverStation(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.enabled_ = enabled_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.state_ = state_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof gazebo.msgs.GzDriverStation.DriverStation) { + return mergeFrom((gazebo.msgs.GzDriverStation.DriverStation)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(gazebo.msgs.GzDriverStation.DriverStation other) { + if (other == gazebo.msgs.GzDriverStation.DriverStation.getDefaultInstance()) return this; + if (other.hasEnabled()) { + setEnabled(other.getEnabled()); + } + if (other.hasState()) { + setState(other.getState()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasEnabled()) { + + return false; + } + if (!hasState()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + gazebo.msgs.GzDriverStation.DriverStation parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (gazebo.msgs.GzDriverStation.DriverStation) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required bool enabled = 1; + private boolean enabled_ ; + /** + * required bool enabled = 1; + */ + public boolean hasEnabled() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required bool enabled = 1; + */ + public boolean getEnabled() { + return enabled_; + } + /** + * required bool enabled = 1; + */ + public Builder setEnabled(boolean value) { + bitField0_ |= 0x00000001; + enabled_ = value; + onChanged(); + return this; + } + /** + * required bool enabled = 1; + */ + public Builder clearEnabled() { + bitField0_ = (bitField0_ & ~0x00000001); + enabled_ = false; + onChanged(); + return this; + } + + // required .gazebo.msgs.DriverStation.State state = 2; + private gazebo.msgs.GzDriverStation.DriverStation.State state_ = gazebo.msgs.GzDriverStation.DriverStation.State.AUTO; + /** + * required .gazebo.msgs.DriverStation.State state = 2; + */ + public boolean hasState() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required .gazebo.msgs.DriverStation.State state = 2; + */ + public gazebo.msgs.GzDriverStation.DriverStation.State getState() { + return state_; + } + /** + * required .gazebo.msgs.DriverStation.State state = 2; + */ + public Builder setState(gazebo.msgs.GzDriverStation.DriverStation.State value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + state_ = value; + onChanged(); + return this; + } + /** + * required .gazebo.msgs.DriverStation.State state = 2; + */ + public Builder clearState() { + bitField0_ = (bitField0_ & ~0x00000002); + state_ = gazebo.msgs.GzDriverStation.DriverStation.State.AUTO; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:gazebo.msgs.DriverStation) + } + + static { + defaultInstance = new DriverStation(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:gazebo.msgs.DriverStation) + } + + private static com.google.protobuf.Descriptors.Descriptor + internal_static_gazebo_msgs_DriverStation_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_gazebo_msgs_DriverStation_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n+frc_gazebo_plugin/msgs/driver-station." + + "proto\022\013gazebo.msgs\"z\n\rDriverStation\022\017\n\007e" + + "nabled\030\001 \002(\010\022/\n\005state\030\002 \002(\0162 .gazebo.msg" + + "s.DriverStation.State\"\'\n\005State\022\010\n\004AUTO\020\000" + + "\022\n\n\006TELEOP\020\001\022\010\n\004TEST\020\002B\020B\016GzDriveStation" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + internal_static_gazebo_msgs_DriverStation_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_gazebo_msgs_DriverStation_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_gazebo_msgs_DriverStation_descriptor, + new java.lang.String[] { "Enabled", "State", }); + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzFloat64.java b/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzFloat64.java new file mode 100644 index 0000000000..ac5a0855f2 --- /dev/null +++ b/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzFloat64.java @@ -0,0 +1,453 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: msgs/float64.proto + +package gazebo.msgs; + +public final class GzFloat64 { + private GzFloat64() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + public interface Float64OrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required double data = 1; + /** + * required double data = 1; + */ + boolean hasData(); + /** + * required double data = 1; + */ + double getData(); + } + /** + * Protobuf type {@code gazebo.msgs.Float64} + */ + public static final class Float64 extends + com.google.protobuf.GeneratedMessage + implements Float64OrBuilder { + // Use Float64.newBuilder() to construct. + private Float64(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private Float64(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final Float64 defaultInstance; + public static Float64 getDefaultInstance() { + return defaultInstance; + } + + public Float64 getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Float64( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 9: { + bitField0_ |= 0x00000001; + data_ = input.readDouble(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return gazebo.msgs.GzFloat64.internal_static_gazebo_msgs_Float64_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return gazebo.msgs.GzFloat64.internal_static_gazebo_msgs_Float64_fieldAccessorTable + .ensureFieldAccessorsInitialized( + gazebo.msgs.GzFloat64.Float64.class, gazebo.msgs.GzFloat64.Float64.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public Float64 parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Float64(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required double data = 1; + public static final int DATA_FIELD_NUMBER = 1; + private double data_; + /** + * required double data = 1; + */ + public boolean hasData() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required double data = 1; + */ + public double getData() { + return data_; + } + + private void initFields() { + data_ = 0D; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasData()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeDouble(1, data_); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(1, data_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static gazebo.msgs.GzFloat64.Float64 parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static gazebo.msgs.GzFloat64.Float64 parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static gazebo.msgs.GzFloat64.Float64 parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static gazebo.msgs.GzFloat64.Float64 parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static gazebo.msgs.GzFloat64.Float64 parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static gazebo.msgs.GzFloat64.Float64 parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static gazebo.msgs.GzFloat64.Float64 parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static gazebo.msgs.GzFloat64.Float64 parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static gazebo.msgs.GzFloat64.Float64 parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static gazebo.msgs.GzFloat64.Float64 parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(gazebo.msgs.GzFloat64.Float64 prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code gazebo.msgs.Float64} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements gazebo.msgs.GzFloat64.Float64OrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return gazebo.msgs.GzFloat64.internal_static_gazebo_msgs_Float64_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return gazebo.msgs.GzFloat64.internal_static_gazebo_msgs_Float64_fieldAccessorTable + .ensureFieldAccessorsInitialized( + gazebo.msgs.GzFloat64.Float64.class, gazebo.msgs.GzFloat64.Float64.Builder.class); + } + + // Construct using gazebo.msgs.GzFloat64.Float64.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + data_ = 0D; + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return gazebo.msgs.GzFloat64.internal_static_gazebo_msgs_Float64_descriptor; + } + + public gazebo.msgs.GzFloat64.Float64 getDefaultInstanceForType() { + return gazebo.msgs.GzFloat64.Float64.getDefaultInstance(); + } + + public gazebo.msgs.GzFloat64.Float64 build() { + gazebo.msgs.GzFloat64.Float64 result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public gazebo.msgs.GzFloat64.Float64 buildPartial() { + gazebo.msgs.GzFloat64.Float64 result = new gazebo.msgs.GzFloat64.Float64(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.data_ = data_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof gazebo.msgs.GzFloat64.Float64) { + return mergeFrom((gazebo.msgs.GzFloat64.Float64)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(gazebo.msgs.GzFloat64.Float64 other) { + if (other == gazebo.msgs.GzFloat64.Float64.getDefaultInstance()) return this; + if (other.hasData()) { + setData(other.getData()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasData()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + gazebo.msgs.GzFloat64.Float64 parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (gazebo.msgs.GzFloat64.Float64) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required double data = 1; + private double data_ ; + /** + * required double data = 1; + */ + public boolean hasData() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required double data = 1; + */ + public double getData() { + return data_; + } + /** + * required double data = 1; + */ + public Builder setData(double value) { + bitField0_ |= 0x00000001; + data_ = value; + onChanged(); + return this; + } + /** + * required double data = 1; + */ + public Builder clearData() { + bitField0_ = (bitField0_ & ~0x00000001); + data_ = 0D; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:gazebo.msgs.Float64) + } + + static { + defaultInstance = new Float64(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:gazebo.msgs.Float64) + } + + private static com.google.protobuf.Descriptors.Descriptor + internal_static_gazebo_msgs_Float64_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_gazebo_msgs_Float64_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\022msgs/float64.proto\022\013gazebo.msgs\"\027\n\007Flo" + + "at64\022\014\n\004data\030\001 \002(\001B\013B\tGzFloat64" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + internal_static_gazebo_msgs_Float64_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_gazebo_msgs_Float64_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_gazebo_msgs_Float64_descriptor, + new java.lang.String[] { "Data", }); + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzJoystick.java b/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzJoystick.java new file mode 100644 index 0000000000..9f1d1a6ea6 --- /dev/null +++ b/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzJoystick.java @@ -0,0 +1,670 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: frc_gazebo_plugin/msgs/joystick.proto + +package gazebo.msgs; + +public final class GzJoystick { + private GzJoystick() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + public interface JoystickOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // repeated double axes = 1; + /** + * repeated double axes = 1; + */ + java.util.List getAxesList(); + /** + * repeated double axes = 1; + */ + int getAxesCount(); + /** + * repeated double axes = 1; + */ + double getAxes(int index); + + // repeated bool buttons = 2; + /** + * repeated bool buttons = 2; + */ + java.util.List getButtonsList(); + /** + * repeated bool buttons = 2; + */ + int getButtonsCount(); + /** + * repeated bool buttons = 2; + */ + boolean getButtons(int index); + } + /** + * Protobuf type {@code gazebo.msgs.Joystick} + */ + public static final class Joystick extends + com.google.protobuf.GeneratedMessage + implements JoystickOrBuilder { + // Use Joystick.newBuilder() to construct. + private Joystick(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private Joystick(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final Joystick defaultInstance; + public static Joystick getDefaultInstance() { + return defaultInstance; + } + + public Joystick getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Joystick( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 9: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + axes_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + axes_.add(input.readDouble()); + break; + } + case 10: { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001) && input.getBytesUntilLimit() > 0) { + axes_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + while (input.getBytesUntilLimit() > 0) { + axes_.add(input.readDouble()); + } + input.popLimit(limit); + break; + } + case 16: { + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + buttons_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + buttons_.add(input.readBool()); + break; + } + case 18: { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + if (!((mutable_bitField0_ & 0x00000002) == 0x00000002) && input.getBytesUntilLimit() > 0) { + buttons_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000002; + } + while (input.getBytesUntilLimit() > 0) { + buttons_.add(input.readBool()); + } + input.popLimit(limit); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + axes_ = java.util.Collections.unmodifiableList(axes_); + } + if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { + buttons_ = java.util.Collections.unmodifiableList(buttons_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return gazebo.msgs.GzJoystick.internal_static_gazebo_msgs_Joystick_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return gazebo.msgs.GzJoystick.internal_static_gazebo_msgs_Joystick_fieldAccessorTable + .ensureFieldAccessorsInitialized( + gazebo.msgs.GzJoystick.Joystick.class, gazebo.msgs.GzJoystick.Joystick.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public Joystick parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Joystick(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + // repeated double axes = 1; + public static final int AXES_FIELD_NUMBER = 1; + private java.util.List axes_; + /** + * repeated double axes = 1; + */ + public java.util.List + getAxesList() { + return axes_; + } + /** + * repeated double axes = 1; + */ + public int getAxesCount() { + return axes_.size(); + } + /** + * repeated double axes = 1; + */ + public double getAxes(int index) { + return axes_.get(index); + } + + // repeated bool buttons = 2; + public static final int BUTTONS_FIELD_NUMBER = 2; + private java.util.List buttons_; + /** + * repeated bool buttons = 2; + */ + public java.util.List + getButtonsList() { + return buttons_; + } + /** + * repeated bool buttons = 2; + */ + public int getButtonsCount() { + return buttons_.size(); + } + /** + * repeated bool buttons = 2; + */ + public boolean getButtons(int index) { + return buttons_.get(index); + } + + private void initFields() { + axes_ = java.util.Collections.emptyList(); + buttons_ = java.util.Collections.emptyList(); + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + for (int i = 0; i < axes_.size(); i++) { + output.writeDouble(1, axes_.get(i)); + } + for (int i = 0; i < buttons_.size(); i++) { + output.writeBool(2, buttons_.get(i)); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + dataSize = 8 * getAxesList().size(); + size += dataSize; + size += 1 * getAxesList().size(); + } + { + int dataSize = 0; + dataSize = 1 * getButtonsList().size(); + size += dataSize; + size += 1 * getButtonsList().size(); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static gazebo.msgs.GzJoystick.Joystick parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static gazebo.msgs.GzJoystick.Joystick parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static gazebo.msgs.GzJoystick.Joystick parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static gazebo.msgs.GzJoystick.Joystick parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static gazebo.msgs.GzJoystick.Joystick parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static gazebo.msgs.GzJoystick.Joystick parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static gazebo.msgs.GzJoystick.Joystick parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static gazebo.msgs.GzJoystick.Joystick parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static gazebo.msgs.GzJoystick.Joystick parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static gazebo.msgs.GzJoystick.Joystick parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(gazebo.msgs.GzJoystick.Joystick prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code gazebo.msgs.Joystick} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements gazebo.msgs.GzJoystick.JoystickOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return gazebo.msgs.GzJoystick.internal_static_gazebo_msgs_Joystick_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return gazebo.msgs.GzJoystick.internal_static_gazebo_msgs_Joystick_fieldAccessorTable + .ensureFieldAccessorsInitialized( + gazebo.msgs.GzJoystick.Joystick.class, gazebo.msgs.GzJoystick.Joystick.Builder.class); + } + + // Construct using gazebo.msgs.GzJoystick.Joystick.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + axes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + buttons_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return gazebo.msgs.GzJoystick.internal_static_gazebo_msgs_Joystick_descriptor; + } + + public gazebo.msgs.GzJoystick.Joystick getDefaultInstanceForType() { + return gazebo.msgs.GzJoystick.Joystick.getDefaultInstance(); + } + + public gazebo.msgs.GzJoystick.Joystick build() { + gazebo.msgs.GzJoystick.Joystick result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public gazebo.msgs.GzJoystick.Joystick buildPartial() { + gazebo.msgs.GzJoystick.Joystick result = new gazebo.msgs.GzJoystick.Joystick(this); + int from_bitField0_ = bitField0_; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + axes_ = java.util.Collections.unmodifiableList(axes_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.axes_ = axes_; + if (((bitField0_ & 0x00000002) == 0x00000002)) { + buttons_ = java.util.Collections.unmodifiableList(buttons_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.buttons_ = buttons_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof gazebo.msgs.GzJoystick.Joystick) { + return mergeFrom((gazebo.msgs.GzJoystick.Joystick)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(gazebo.msgs.GzJoystick.Joystick other) { + if (other == gazebo.msgs.GzJoystick.Joystick.getDefaultInstance()) return this; + if (!other.axes_.isEmpty()) { + if (axes_.isEmpty()) { + axes_ = other.axes_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureAxesIsMutable(); + axes_.addAll(other.axes_); + } + onChanged(); + } + if (!other.buttons_.isEmpty()) { + if (buttons_.isEmpty()) { + buttons_ = other.buttons_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureButtonsIsMutable(); + buttons_.addAll(other.buttons_); + } + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + gazebo.msgs.GzJoystick.Joystick parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (gazebo.msgs.GzJoystick.Joystick) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // repeated double axes = 1; + private java.util.List axes_ = java.util.Collections.emptyList(); + private void ensureAxesIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + axes_ = new java.util.ArrayList(axes_); + bitField0_ |= 0x00000001; + } + } + /** + * repeated double axes = 1; + */ + public java.util.List + getAxesList() { + return java.util.Collections.unmodifiableList(axes_); + } + /** + * repeated double axes = 1; + */ + public int getAxesCount() { + return axes_.size(); + } + /** + * repeated double axes = 1; + */ + public double getAxes(int index) { + return axes_.get(index); + } + /** + * repeated double axes = 1; + */ + public Builder setAxes( + int index, double value) { + ensureAxesIsMutable(); + axes_.set(index, value); + onChanged(); + return this; + } + /** + * repeated double axes = 1; + */ + public Builder addAxes(double value) { + ensureAxesIsMutable(); + axes_.add(value); + onChanged(); + return this; + } + /** + * repeated double axes = 1; + */ + public Builder addAllAxes( + java.lang.Iterable values) { + ensureAxesIsMutable(); + super.addAll(values, axes_); + onChanged(); + return this; + } + /** + * repeated double axes = 1; + */ + public Builder clearAxes() { + axes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + // repeated bool buttons = 2; + private java.util.List buttons_ = java.util.Collections.emptyList(); + private void ensureButtonsIsMutable() { + if (!((bitField0_ & 0x00000002) == 0x00000002)) { + buttons_ = new java.util.ArrayList(buttons_); + bitField0_ |= 0x00000002; + } + } + /** + * repeated bool buttons = 2; + */ + public java.util.List + getButtonsList() { + return java.util.Collections.unmodifiableList(buttons_); + } + /** + * repeated bool buttons = 2; + */ + public int getButtonsCount() { + return buttons_.size(); + } + /** + * repeated bool buttons = 2; + */ + public boolean getButtons(int index) { + return buttons_.get(index); + } + /** + * repeated bool buttons = 2; + */ + public Builder setButtons( + int index, boolean value) { + ensureButtonsIsMutable(); + buttons_.set(index, value); + onChanged(); + return this; + } + /** + * repeated bool buttons = 2; + */ + public Builder addButtons(boolean value) { + ensureButtonsIsMutable(); + buttons_.add(value); + onChanged(); + return this; + } + /** + * repeated bool buttons = 2; + */ + public Builder addAllButtons( + java.lang.Iterable values) { + ensureButtonsIsMutable(); + super.addAll(values, buttons_); + onChanged(); + return this; + } + /** + * repeated bool buttons = 2; + */ + public Builder clearButtons() { + buttons_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:gazebo.msgs.Joystick) + } + + static { + defaultInstance = new Joystick(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:gazebo.msgs.Joystick) + } + + private static com.google.protobuf.Descriptors.Descriptor + internal_static_gazebo_msgs_Joystick_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_gazebo_msgs_Joystick_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n%frc_gazebo_plugin/msgs/joystick.proto\022" + + "\013gazebo.msgs\")\n\010Joystick\022\014\n\004axes\030\001 \003(\001\022\017" + + "\n\007buttons\030\002 \003(\010B\014B\nGzJoystick" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + internal_static_gazebo_msgs_Joystick_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_gazebo_msgs_Joystick_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_gazebo_msgs_Joystick_descriptor, + new java.lang.String[] { "Axes", "Buttons", }); + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzPacket.java b/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzPacket.java new file mode 100644 index 0000000000..6294811be6 --- /dev/null +++ b/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzPacket.java @@ -0,0 +1,831 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: packet.proto + +package gazebo.msgs; + +public final class GzPacket { + private GzPacket() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + public interface PacketOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required .gazebo.msgs.Time stamp = 1; + /** + * required .gazebo.msgs.Time stamp = 1; + */ + boolean hasStamp(); + /** + * required .gazebo.msgs.Time stamp = 1; + */ + gazebo.msgs.GzTime.Time getStamp(); + /** + * required .gazebo.msgs.Time stamp = 1; + */ + gazebo.msgs.GzTime.TimeOrBuilder getStampOrBuilder(); + + // required string type = 2; + /** + * required string type = 2; + */ + boolean hasType(); + /** + * required string type = 2; + */ + java.lang.String getType(); + /** + * required string type = 2; + */ + com.google.protobuf.ByteString + getTypeBytes(); + + // required bytes serialized_data = 3; + /** + * required bytes serialized_data = 3; + */ + boolean hasSerializedData(); + /** + * required bytes serialized_data = 3; + */ + com.google.protobuf.ByteString getSerializedData(); + } + /** + * Protobuf type {@code gazebo.msgs.Packet} + */ + public static final class Packet extends + com.google.protobuf.GeneratedMessage + implements PacketOrBuilder { + // Use Packet.newBuilder() to construct. + private Packet(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private Packet(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final Packet defaultInstance; + public static Packet getDefaultInstance() { + return defaultInstance; + } + + public Packet getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Packet( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + gazebo.msgs.GzTime.Time.Builder subBuilder = null; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + subBuilder = stamp_.toBuilder(); + } + stamp_ = input.readMessage(gazebo.msgs.GzTime.Time.PARSER, extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(stamp_); + stamp_ = subBuilder.buildPartial(); + } + bitField0_ |= 0x00000001; + break; + } + case 18: { + bitField0_ |= 0x00000002; + type_ = input.readBytes(); + break; + } + case 26: { + bitField0_ |= 0x00000004; + serializedData_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return gazebo.msgs.GzPacket.internal_static_gazebo_msgs_Packet_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return gazebo.msgs.GzPacket.internal_static_gazebo_msgs_Packet_fieldAccessorTable + .ensureFieldAccessorsInitialized( + gazebo.msgs.GzPacket.Packet.class, gazebo.msgs.GzPacket.Packet.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public Packet parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Packet(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required .gazebo.msgs.Time stamp = 1; + public static final int STAMP_FIELD_NUMBER = 1; + private gazebo.msgs.GzTime.Time stamp_; + /** + * required .gazebo.msgs.Time stamp = 1; + */ + public boolean hasStamp() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required .gazebo.msgs.Time stamp = 1; + */ + public gazebo.msgs.GzTime.Time getStamp() { + return stamp_; + } + /** + * required .gazebo.msgs.Time stamp = 1; + */ + public gazebo.msgs.GzTime.TimeOrBuilder getStampOrBuilder() { + return stamp_; + } + + // required string type = 2; + public static final int TYPE_FIELD_NUMBER = 2; + private java.lang.Object type_; + /** + * required string type = 2; + */ + public boolean hasType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required string type = 2; + */ + public java.lang.String getType() { + java.lang.Object ref = type_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + type_ = s; + } + return s; + } + } + /** + * required string type = 2; + */ + public com.google.protobuf.ByteString + getTypeBytes() { + java.lang.Object ref = type_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + type_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // required bytes serialized_data = 3; + public static final int SERIALIZED_DATA_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString serializedData_; + /** + * required bytes serialized_data = 3; + */ + public boolean hasSerializedData() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * required bytes serialized_data = 3; + */ + public com.google.protobuf.ByteString getSerializedData() { + return serializedData_; + } + + private void initFields() { + stamp_ = gazebo.msgs.GzTime.Time.getDefaultInstance(); + type_ = ""; + serializedData_ = com.google.protobuf.ByteString.EMPTY; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasStamp()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasType()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasSerializedData()) { + memoizedIsInitialized = 0; + return false; + } + if (!getStamp().isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeMessage(1, stamp_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeBytes(2, getTypeBytes()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeBytes(3, serializedData_); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, stamp_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, getTypeBytes()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, serializedData_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static gazebo.msgs.GzPacket.Packet parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static gazebo.msgs.GzPacket.Packet parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static gazebo.msgs.GzPacket.Packet parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static gazebo.msgs.GzPacket.Packet parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static gazebo.msgs.GzPacket.Packet parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static gazebo.msgs.GzPacket.Packet parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static gazebo.msgs.GzPacket.Packet parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static gazebo.msgs.GzPacket.Packet parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static gazebo.msgs.GzPacket.Packet parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static gazebo.msgs.GzPacket.Packet parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(gazebo.msgs.GzPacket.Packet prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code gazebo.msgs.Packet} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements gazebo.msgs.GzPacket.PacketOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return gazebo.msgs.GzPacket.internal_static_gazebo_msgs_Packet_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return gazebo.msgs.GzPacket.internal_static_gazebo_msgs_Packet_fieldAccessorTable + .ensureFieldAccessorsInitialized( + gazebo.msgs.GzPacket.Packet.class, gazebo.msgs.GzPacket.Packet.Builder.class); + } + + // Construct using gazebo.msgs.GzPacket.Packet.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getStampFieldBuilder(); + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + if (stampBuilder_ == null) { + stamp_ = gazebo.msgs.GzTime.Time.getDefaultInstance(); + } else { + stampBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + type_ = ""; + bitField0_ = (bitField0_ & ~0x00000002); + serializedData_ = com.google.protobuf.ByteString.EMPTY; + bitField0_ = (bitField0_ & ~0x00000004); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return gazebo.msgs.GzPacket.internal_static_gazebo_msgs_Packet_descriptor; + } + + public gazebo.msgs.GzPacket.Packet getDefaultInstanceForType() { + return gazebo.msgs.GzPacket.Packet.getDefaultInstance(); + } + + public gazebo.msgs.GzPacket.Packet build() { + gazebo.msgs.GzPacket.Packet result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public gazebo.msgs.GzPacket.Packet buildPartial() { + gazebo.msgs.GzPacket.Packet result = new gazebo.msgs.GzPacket.Packet(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + if (stampBuilder_ == null) { + result.stamp_ = stamp_; + } else { + result.stamp_ = stampBuilder_.build(); + } + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.type_ = type_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + result.serializedData_ = serializedData_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof gazebo.msgs.GzPacket.Packet) { + return mergeFrom((gazebo.msgs.GzPacket.Packet)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(gazebo.msgs.GzPacket.Packet other) { + if (other == gazebo.msgs.GzPacket.Packet.getDefaultInstance()) return this; + if (other.hasStamp()) { + mergeStamp(other.getStamp()); + } + if (other.hasType()) { + bitField0_ |= 0x00000002; + type_ = other.type_; + onChanged(); + } + if (other.hasSerializedData()) { + setSerializedData(other.getSerializedData()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasStamp()) { + + return false; + } + if (!hasType()) { + + return false; + } + if (!hasSerializedData()) { + + return false; + } + if (!getStamp().isInitialized()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + gazebo.msgs.GzPacket.Packet parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (gazebo.msgs.GzPacket.Packet) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required .gazebo.msgs.Time stamp = 1; + private gazebo.msgs.GzTime.Time stamp_ = gazebo.msgs.GzTime.Time.getDefaultInstance(); + private com.google.protobuf.SingleFieldBuilder< + gazebo.msgs.GzTime.Time, gazebo.msgs.GzTime.Time.Builder, gazebo.msgs.GzTime.TimeOrBuilder> stampBuilder_; + /** + * required .gazebo.msgs.Time stamp = 1; + */ + public boolean hasStamp() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required .gazebo.msgs.Time stamp = 1; + */ + public gazebo.msgs.GzTime.Time getStamp() { + if (stampBuilder_ == null) { + return stamp_; + } else { + return stampBuilder_.getMessage(); + } + } + /** + * required .gazebo.msgs.Time stamp = 1; + */ + public Builder setStamp(gazebo.msgs.GzTime.Time value) { + if (stampBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + stamp_ = value; + onChanged(); + } else { + stampBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + return this; + } + /** + * required .gazebo.msgs.Time stamp = 1; + */ + public Builder setStamp( + gazebo.msgs.GzTime.Time.Builder builderForValue) { + if (stampBuilder_ == null) { + stamp_ = builderForValue.build(); + onChanged(); + } else { + stampBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + return this; + } + /** + * required .gazebo.msgs.Time stamp = 1; + */ + public Builder mergeStamp(gazebo.msgs.GzTime.Time value) { + if (stampBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001) && + stamp_ != gazebo.msgs.GzTime.Time.getDefaultInstance()) { + stamp_ = + gazebo.msgs.GzTime.Time.newBuilder(stamp_).mergeFrom(value).buildPartial(); + } else { + stamp_ = value; + } + onChanged(); + } else { + stampBuilder_.mergeFrom(value); + } + bitField0_ |= 0x00000001; + return this; + } + /** + * required .gazebo.msgs.Time stamp = 1; + */ + public Builder clearStamp() { + if (stampBuilder_ == null) { + stamp_ = gazebo.msgs.GzTime.Time.getDefaultInstance(); + onChanged(); + } else { + stampBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + /** + * required .gazebo.msgs.Time stamp = 1; + */ + public gazebo.msgs.GzTime.Time.Builder getStampBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getStampFieldBuilder().getBuilder(); + } + /** + * required .gazebo.msgs.Time stamp = 1; + */ + public gazebo.msgs.GzTime.TimeOrBuilder getStampOrBuilder() { + if (stampBuilder_ != null) { + return stampBuilder_.getMessageOrBuilder(); + } else { + return stamp_; + } + } + /** + * required .gazebo.msgs.Time stamp = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + gazebo.msgs.GzTime.Time, gazebo.msgs.GzTime.Time.Builder, gazebo.msgs.GzTime.TimeOrBuilder> + getStampFieldBuilder() { + if (stampBuilder_ == null) { + stampBuilder_ = new com.google.protobuf.SingleFieldBuilder< + gazebo.msgs.GzTime.Time, gazebo.msgs.GzTime.Time.Builder, gazebo.msgs.GzTime.TimeOrBuilder>( + stamp_, + getParentForChildren(), + isClean()); + stamp_ = null; + } + return stampBuilder_; + } + + // required string type = 2; + private java.lang.Object type_ = ""; + /** + * required string type = 2; + */ + public boolean hasType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required string type = 2; + */ + public java.lang.String getType() { + java.lang.Object ref = type_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + type_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string type = 2; + */ + public com.google.protobuf.ByteString + getTypeBytes() { + java.lang.Object ref = type_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + type_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string type = 2; + */ + public Builder setType( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + type_ = value; + onChanged(); + return this; + } + /** + * required string type = 2; + */ + public Builder clearType() { + bitField0_ = (bitField0_ & ~0x00000002); + type_ = getDefaultInstance().getType(); + onChanged(); + return this; + } + /** + * required string type = 2; + */ + public Builder setTypeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + type_ = value; + onChanged(); + return this; + } + + // required bytes serialized_data = 3; + private com.google.protobuf.ByteString serializedData_ = com.google.protobuf.ByteString.EMPTY; + /** + * required bytes serialized_data = 3; + */ + public boolean hasSerializedData() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * required bytes serialized_data = 3; + */ + public com.google.protobuf.ByteString getSerializedData() { + return serializedData_; + } + /** + * required bytes serialized_data = 3; + */ + public Builder setSerializedData(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + serializedData_ = value; + onChanged(); + return this; + } + /** + * required bytes serialized_data = 3; + */ + public Builder clearSerializedData() { + bitField0_ = (bitField0_ & ~0x00000004); + serializedData_ = getDefaultInstance().getSerializedData(); + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:gazebo.msgs.Packet) + } + + static { + defaultInstance = new Packet(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:gazebo.msgs.Packet) + } + + private static com.google.protobuf.Descriptors.Descriptor + internal_static_gazebo_msgs_Packet_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_gazebo_msgs_Packet_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\014packet.proto\022\013gazebo.msgs\032\ntime.proto\"" + + "Q\n\006Packet\022 \n\005stamp\030\001 \002(\0132\021.gazebo.msgs.T" + + "ime\022\014\n\004type\030\002 \002(\t\022\027\n\017serialized_data\030\003 \002" + + "(\014B\nB\010GzPacket" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + internal_static_gazebo_msgs_Packet_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_gazebo_msgs_Packet_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_gazebo_msgs_Packet_descriptor, + new java.lang.String[] { "Stamp", "Type", "SerializedData", }); + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + gazebo.msgs.GzTime.getDescriptor(), + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzPublish.java b/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzPublish.java new file mode 100644 index 0000000000..4e1fea2d42 --- /dev/null +++ b/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzPublish.java @@ -0,0 +1,947 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: gazebo/src/msgs/publish.proto + +package gazebo.msgs; + +public final class GzPublish { + private GzPublish() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + public interface PublishOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required string topic = 1; + /** + * required string topic = 1; + */ + boolean hasTopic(); + /** + * required string topic = 1; + */ + java.lang.String getTopic(); + /** + * required string topic = 1; + */ + com.google.protobuf.ByteString + getTopicBytes(); + + // required string msg_type = 2; + /** + * required string msg_type = 2; + */ + boolean hasMsgType(); + /** + * required string msg_type = 2; + */ + java.lang.String getMsgType(); + /** + * required string msg_type = 2; + */ + com.google.protobuf.ByteString + getMsgTypeBytes(); + + // required string host = 3; + /** + * required string host = 3; + */ + boolean hasHost(); + /** + * required string host = 3; + */ + java.lang.String getHost(); + /** + * required string host = 3; + */ + com.google.protobuf.ByteString + getHostBytes(); + + // required uint32 port = 4; + /** + * required uint32 port = 4; + */ + boolean hasPort(); + /** + * required uint32 port = 4; + */ + int getPort(); + } + /** + * Protobuf type {@code gazebo.msgs.Publish} + */ + public static final class Publish extends + com.google.protobuf.GeneratedMessage + implements PublishOrBuilder { + // Use Publish.newBuilder() to construct. + private Publish(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private Publish(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final Publish defaultInstance; + public static Publish getDefaultInstance() { + return defaultInstance; + } + + public Publish getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Publish( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + bitField0_ |= 0x00000001; + topic_ = input.readBytes(); + break; + } + case 18: { + bitField0_ |= 0x00000002; + msgType_ = input.readBytes(); + break; + } + case 26: { + bitField0_ |= 0x00000004; + host_ = input.readBytes(); + break; + } + case 32: { + bitField0_ |= 0x00000008; + port_ = input.readUInt32(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return gazebo.msgs.GzPublish.internal_static_gazebo_msgs_Publish_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return gazebo.msgs.GzPublish.internal_static_gazebo_msgs_Publish_fieldAccessorTable + .ensureFieldAccessorsInitialized( + gazebo.msgs.GzPublish.Publish.class, gazebo.msgs.GzPublish.Publish.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public Publish parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Publish(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required string topic = 1; + public static final int TOPIC_FIELD_NUMBER = 1; + private java.lang.Object topic_; + /** + * required string topic = 1; + */ + public boolean hasTopic() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string topic = 1; + */ + public java.lang.String getTopic() { + java.lang.Object ref = topic_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + topic_ = s; + } + return s; + } + } + /** + * required string topic = 1; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + java.lang.Object ref = topic_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // required string msg_type = 2; + public static final int MSG_TYPE_FIELD_NUMBER = 2; + private java.lang.Object msgType_; + /** + * required string msg_type = 2; + */ + public boolean hasMsgType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required string msg_type = 2; + */ + public java.lang.String getMsgType() { + java.lang.Object ref = msgType_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + msgType_ = s; + } + return s; + } + } + /** + * required string msg_type = 2; + */ + public com.google.protobuf.ByteString + getMsgTypeBytes() { + java.lang.Object ref = msgType_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + msgType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // required string host = 3; + public static final int HOST_FIELD_NUMBER = 3; + private java.lang.Object host_; + /** + * required string host = 3; + */ + public boolean hasHost() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * required string host = 3; + */ + public java.lang.String getHost() { + java.lang.Object ref = host_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + host_ = s; + } + return s; + } + } + /** + * required string host = 3; + */ + public com.google.protobuf.ByteString + getHostBytes() { + java.lang.Object ref = host_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + host_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // required uint32 port = 4; + public static final int PORT_FIELD_NUMBER = 4; + private int port_; + /** + * required uint32 port = 4; + */ + public boolean hasPort() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * required uint32 port = 4; + */ + public int getPort() { + return port_; + } + + private void initFields() { + topic_ = ""; + msgType_ = ""; + host_ = ""; + port_ = 0; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasTopic()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasMsgType()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasHost()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasPort()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getTopicBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeBytes(2, getMsgTypeBytes()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeBytes(3, getHostBytes()); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + output.writeUInt32(4, port_); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getTopicBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, getMsgTypeBytes()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(3, getHostBytes()); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + size += com.google.protobuf.CodedOutputStream + .computeUInt32Size(4, port_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static gazebo.msgs.GzPublish.Publish parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static gazebo.msgs.GzPublish.Publish parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static gazebo.msgs.GzPublish.Publish parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static gazebo.msgs.GzPublish.Publish parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static gazebo.msgs.GzPublish.Publish parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static gazebo.msgs.GzPublish.Publish parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static gazebo.msgs.GzPublish.Publish parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static gazebo.msgs.GzPublish.Publish parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static gazebo.msgs.GzPublish.Publish parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static gazebo.msgs.GzPublish.Publish parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(gazebo.msgs.GzPublish.Publish prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code gazebo.msgs.Publish} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements gazebo.msgs.GzPublish.PublishOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return gazebo.msgs.GzPublish.internal_static_gazebo_msgs_Publish_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return gazebo.msgs.GzPublish.internal_static_gazebo_msgs_Publish_fieldAccessorTable + .ensureFieldAccessorsInitialized( + gazebo.msgs.GzPublish.Publish.class, gazebo.msgs.GzPublish.Publish.Builder.class); + } + + // Construct using gazebo.msgs.GzPublish.Publish.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + topic_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + msgType_ = ""; + bitField0_ = (bitField0_ & ~0x00000002); + host_ = ""; + bitField0_ = (bitField0_ & ~0x00000004); + port_ = 0; + bitField0_ = (bitField0_ & ~0x00000008); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return gazebo.msgs.GzPublish.internal_static_gazebo_msgs_Publish_descriptor; + } + + public gazebo.msgs.GzPublish.Publish getDefaultInstanceForType() { + return gazebo.msgs.GzPublish.Publish.getDefaultInstance(); + } + + public gazebo.msgs.GzPublish.Publish build() { + gazebo.msgs.GzPublish.Publish result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public gazebo.msgs.GzPublish.Publish buildPartial() { + gazebo.msgs.GzPublish.Publish result = new gazebo.msgs.GzPublish.Publish(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.topic_ = topic_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.msgType_ = msgType_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + result.host_ = host_; + if (((from_bitField0_ & 0x00000008) == 0x00000008)) { + to_bitField0_ |= 0x00000008; + } + result.port_ = port_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof gazebo.msgs.GzPublish.Publish) { + return mergeFrom((gazebo.msgs.GzPublish.Publish)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(gazebo.msgs.GzPublish.Publish other) { + if (other == gazebo.msgs.GzPublish.Publish.getDefaultInstance()) return this; + if (other.hasTopic()) { + bitField0_ |= 0x00000001; + topic_ = other.topic_; + onChanged(); + } + if (other.hasMsgType()) { + bitField0_ |= 0x00000002; + msgType_ = other.msgType_; + onChanged(); + } + if (other.hasHost()) { + bitField0_ |= 0x00000004; + host_ = other.host_; + onChanged(); + } + if (other.hasPort()) { + setPort(other.getPort()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasTopic()) { + + return false; + } + if (!hasMsgType()) { + + return false; + } + if (!hasHost()) { + + return false; + } + if (!hasPort()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + gazebo.msgs.GzPublish.Publish parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (gazebo.msgs.GzPublish.Publish) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required string topic = 1; + private java.lang.Object topic_ = ""; + /** + * required string topic = 1; + */ + public boolean hasTopic() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string topic = 1; + */ + public java.lang.String getTopic() { + java.lang.Object ref = topic_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + topic_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string topic = 1; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + java.lang.Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string topic = 1; + */ + public Builder setTopic( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + topic_ = value; + onChanged(); + return this; + } + /** + * required string topic = 1; + */ + public Builder clearTopic() { + bitField0_ = (bitField0_ & ~0x00000001); + topic_ = getDefaultInstance().getTopic(); + onChanged(); + return this; + } + /** + * required string topic = 1; + */ + public Builder setTopicBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + topic_ = value; + onChanged(); + return this; + } + + // required string msg_type = 2; + private java.lang.Object msgType_ = ""; + /** + * required string msg_type = 2; + */ + public boolean hasMsgType() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required string msg_type = 2; + */ + public java.lang.String getMsgType() { + java.lang.Object ref = msgType_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + msgType_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string msg_type = 2; + */ + public com.google.protobuf.ByteString + getMsgTypeBytes() { + java.lang.Object ref = msgType_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + msgType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string msg_type = 2; + */ + public Builder setMsgType( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + msgType_ = value; + onChanged(); + return this; + } + /** + * required string msg_type = 2; + */ + public Builder clearMsgType() { + bitField0_ = (bitField0_ & ~0x00000002); + msgType_ = getDefaultInstance().getMsgType(); + onChanged(); + return this; + } + /** + * required string msg_type = 2; + */ + public Builder setMsgTypeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + msgType_ = value; + onChanged(); + return this; + } + + // required string host = 3; + private java.lang.Object host_ = ""; + /** + * required string host = 3; + */ + public boolean hasHost() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * required string host = 3; + */ + public java.lang.String getHost() { + java.lang.Object ref = host_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + host_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string host = 3; + */ + public com.google.protobuf.ByteString + getHostBytes() { + java.lang.Object ref = host_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + host_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string host = 3; + */ + public Builder setHost( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + host_ = value; + onChanged(); + return this; + } + /** + * required string host = 3; + */ + public Builder clearHost() { + bitField0_ = (bitField0_ & ~0x00000004); + host_ = getDefaultInstance().getHost(); + onChanged(); + return this; + } + /** + * required string host = 3; + */ + public Builder setHostBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + host_ = value; + onChanged(); + return this; + } + + // required uint32 port = 4; + private int port_ ; + /** + * required uint32 port = 4; + */ + public boolean hasPort() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * required uint32 port = 4; + */ + public int getPort() { + return port_; + } + /** + * required uint32 port = 4; + */ + public Builder setPort(int value) { + bitField0_ |= 0x00000008; + port_ = value; + onChanged(); + return this; + } + /** + * required uint32 port = 4; + */ + public Builder clearPort() { + bitField0_ = (bitField0_ & ~0x00000008); + port_ = 0; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:gazebo.msgs.Publish) + } + + static { + defaultInstance = new Publish(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:gazebo.msgs.Publish) + } + + private static com.google.protobuf.Descriptors.Descriptor + internal_static_gazebo_msgs_Publish_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_gazebo_msgs_Publish_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\035gazebo/src/msgs/publish.proto\022\013gazebo." + + "msgs\"F\n\007Publish\022\r\n\005topic\030\001 \002(\t\022\020\n\010msg_ty" + + "pe\030\002 \002(\t\022\014\n\004host\030\003 \002(\t\022\014\n\004port\030\004 \002(\rB\013B\t" + + "GzPublish" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + internal_static_gazebo_msgs_Publish_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_gazebo_msgs_Publish_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_gazebo_msgs_Publish_descriptor, + new java.lang.String[] { "Topic", "MsgType", "Host", "Port", }); + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzPublishers.java b/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzPublishers.java new file mode 100644 index 0000000000..a3bed6e3a6 --- /dev/null +++ b/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzPublishers.java @@ -0,0 +1,737 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: publishers.proto + +package gazebo.msgs; + +public final class GzPublishers { + private GzPublishers() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + public interface PublishersOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // repeated .gazebo.msgs.Publish publisher = 1; + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + java.util.List + getPublisherList(); + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + gazebo.msgs.GzPublish.Publish getPublisher(int index); + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + int getPublisherCount(); + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + java.util.List + getPublisherOrBuilderList(); + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + gazebo.msgs.GzPublish.PublishOrBuilder getPublisherOrBuilder( + int index); + } + /** + * Protobuf type {@code gazebo.msgs.Publishers} + */ + public static final class Publishers extends + com.google.protobuf.GeneratedMessage + implements PublishersOrBuilder { + // Use Publishers.newBuilder() to construct. + private Publishers(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private Publishers(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final Publishers defaultInstance; + public static Publishers getDefaultInstance() { + return defaultInstance; + } + + public Publishers getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Publishers( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + publisher_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + publisher_.add(input.readMessage(gazebo.msgs.GzPublish.Publish.PARSER, extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + publisher_ = java.util.Collections.unmodifiableList(publisher_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return gazebo.msgs.GzPublishers.internal_static_gazebo_msgs_Publishers_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return gazebo.msgs.GzPublishers.internal_static_gazebo_msgs_Publishers_fieldAccessorTable + .ensureFieldAccessorsInitialized( + gazebo.msgs.GzPublishers.Publishers.class, gazebo.msgs.GzPublishers.Publishers.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public Publishers parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Publishers(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + // repeated .gazebo.msgs.Publish publisher = 1; + public static final int PUBLISHER_FIELD_NUMBER = 1; + private java.util.List publisher_; + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + public java.util.List getPublisherList() { + return publisher_; + } + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + public java.util.List + getPublisherOrBuilderList() { + return publisher_; + } + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + public int getPublisherCount() { + return publisher_.size(); + } + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + public gazebo.msgs.GzPublish.Publish getPublisher(int index) { + return publisher_.get(index); + } + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + public gazebo.msgs.GzPublish.PublishOrBuilder getPublisherOrBuilder( + int index) { + return publisher_.get(index); + } + + private void initFields() { + publisher_ = java.util.Collections.emptyList(); + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + for (int i = 0; i < getPublisherCount(); i++) { + if (!getPublisher(i).isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + for (int i = 0; i < publisher_.size(); i++) { + output.writeMessage(1, publisher_.get(i)); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < publisher_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, publisher_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static gazebo.msgs.GzPublishers.Publishers parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static gazebo.msgs.GzPublishers.Publishers parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static gazebo.msgs.GzPublishers.Publishers parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static gazebo.msgs.GzPublishers.Publishers parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static gazebo.msgs.GzPublishers.Publishers parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static gazebo.msgs.GzPublishers.Publishers parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static gazebo.msgs.GzPublishers.Publishers parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static gazebo.msgs.GzPublishers.Publishers parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static gazebo.msgs.GzPublishers.Publishers parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static gazebo.msgs.GzPublishers.Publishers parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(gazebo.msgs.GzPublishers.Publishers prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code gazebo.msgs.Publishers} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements gazebo.msgs.GzPublishers.PublishersOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return gazebo.msgs.GzPublishers.internal_static_gazebo_msgs_Publishers_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return gazebo.msgs.GzPublishers.internal_static_gazebo_msgs_Publishers_fieldAccessorTable + .ensureFieldAccessorsInitialized( + gazebo.msgs.GzPublishers.Publishers.class, gazebo.msgs.GzPublishers.Publishers.Builder.class); + } + + // Construct using gazebo.msgs.GzPublishers.Publishers.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getPublisherFieldBuilder(); + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + if (publisherBuilder_ == null) { + publisher_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + publisherBuilder_.clear(); + } + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return gazebo.msgs.GzPublishers.internal_static_gazebo_msgs_Publishers_descriptor; + } + + public gazebo.msgs.GzPublishers.Publishers getDefaultInstanceForType() { + return gazebo.msgs.GzPublishers.Publishers.getDefaultInstance(); + } + + public gazebo.msgs.GzPublishers.Publishers build() { + gazebo.msgs.GzPublishers.Publishers result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public gazebo.msgs.GzPublishers.Publishers buildPartial() { + gazebo.msgs.GzPublishers.Publishers result = new gazebo.msgs.GzPublishers.Publishers(this); + int from_bitField0_ = bitField0_; + if (publisherBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + publisher_ = java.util.Collections.unmodifiableList(publisher_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.publisher_ = publisher_; + } else { + result.publisher_ = publisherBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof gazebo.msgs.GzPublishers.Publishers) { + return mergeFrom((gazebo.msgs.GzPublishers.Publishers)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(gazebo.msgs.GzPublishers.Publishers other) { + if (other == gazebo.msgs.GzPublishers.Publishers.getDefaultInstance()) return this; + if (publisherBuilder_ == null) { + if (!other.publisher_.isEmpty()) { + if (publisher_.isEmpty()) { + publisher_ = other.publisher_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensurePublisherIsMutable(); + publisher_.addAll(other.publisher_); + } + onChanged(); + } + } else { + if (!other.publisher_.isEmpty()) { + if (publisherBuilder_.isEmpty()) { + publisherBuilder_.dispose(); + publisherBuilder_ = null; + publisher_ = other.publisher_; + bitField0_ = (bitField0_ & ~0x00000001); + publisherBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getPublisherFieldBuilder() : null; + } else { + publisherBuilder_.addAllMessages(other.publisher_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + for (int i = 0; i < getPublisherCount(); i++) { + if (!getPublisher(i).isInitialized()) { + + return false; + } + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + gazebo.msgs.GzPublishers.Publishers parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (gazebo.msgs.GzPublishers.Publishers) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // repeated .gazebo.msgs.Publish publisher = 1; + private java.util.List publisher_ = + java.util.Collections.emptyList(); + private void ensurePublisherIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + publisher_ = new java.util.ArrayList(publisher_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + gazebo.msgs.GzPublish.Publish, gazebo.msgs.GzPublish.Publish.Builder, gazebo.msgs.GzPublish.PublishOrBuilder> publisherBuilder_; + + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + public java.util.List getPublisherList() { + if (publisherBuilder_ == null) { + return java.util.Collections.unmodifiableList(publisher_); + } else { + return publisherBuilder_.getMessageList(); + } + } + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + public int getPublisherCount() { + if (publisherBuilder_ == null) { + return publisher_.size(); + } else { + return publisherBuilder_.getCount(); + } + } + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + public gazebo.msgs.GzPublish.Publish getPublisher(int index) { + if (publisherBuilder_ == null) { + return publisher_.get(index); + } else { + return publisherBuilder_.getMessage(index); + } + } + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + public Builder setPublisher( + int index, gazebo.msgs.GzPublish.Publish value) { + if (publisherBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePublisherIsMutable(); + publisher_.set(index, value); + onChanged(); + } else { + publisherBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + public Builder setPublisher( + int index, gazebo.msgs.GzPublish.Publish.Builder builderForValue) { + if (publisherBuilder_ == null) { + ensurePublisherIsMutable(); + publisher_.set(index, builderForValue.build()); + onChanged(); + } else { + publisherBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + public Builder addPublisher(gazebo.msgs.GzPublish.Publish value) { + if (publisherBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePublisherIsMutable(); + publisher_.add(value); + onChanged(); + } else { + publisherBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + public Builder addPublisher( + int index, gazebo.msgs.GzPublish.Publish value) { + if (publisherBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePublisherIsMutable(); + publisher_.add(index, value); + onChanged(); + } else { + publisherBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + public Builder addPublisher( + gazebo.msgs.GzPublish.Publish.Builder builderForValue) { + if (publisherBuilder_ == null) { + ensurePublisherIsMutable(); + publisher_.add(builderForValue.build()); + onChanged(); + } else { + publisherBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + public Builder addPublisher( + int index, gazebo.msgs.GzPublish.Publish.Builder builderForValue) { + if (publisherBuilder_ == null) { + ensurePublisherIsMutable(); + publisher_.add(index, builderForValue.build()); + onChanged(); + } else { + publisherBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + public Builder addAllPublisher( + java.lang.Iterable values) { + if (publisherBuilder_ == null) { + ensurePublisherIsMutable(); + super.addAll(values, publisher_); + onChanged(); + } else { + publisherBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + public Builder clearPublisher() { + if (publisherBuilder_ == null) { + publisher_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + publisherBuilder_.clear(); + } + return this; + } + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + public Builder removePublisher(int index) { + if (publisherBuilder_ == null) { + ensurePublisherIsMutable(); + publisher_.remove(index); + onChanged(); + } else { + publisherBuilder_.remove(index); + } + return this; + } + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + public gazebo.msgs.GzPublish.Publish.Builder getPublisherBuilder( + int index) { + return getPublisherFieldBuilder().getBuilder(index); + } + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + public gazebo.msgs.GzPublish.PublishOrBuilder getPublisherOrBuilder( + int index) { + if (publisherBuilder_ == null) { + return publisher_.get(index); } else { + return publisherBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + public java.util.List + getPublisherOrBuilderList() { + if (publisherBuilder_ != null) { + return publisherBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(publisher_); + } + } + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + public gazebo.msgs.GzPublish.Publish.Builder addPublisherBuilder() { + return getPublisherFieldBuilder().addBuilder( + gazebo.msgs.GzPublish.Publish.getDefaultInstance()); + } + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + public gazebo.msgs.GzPublish.Publish.Builder addPublisherBuilder( + int index) { + return getPublisherFieldBuilder().addBuilder( + index, gazebo.msgs.GzPublish.Publish.getDefaultInstance()); + } + /** + * repeated .gazebo.msgs.Publish publisher = 1; + */ + public java.util.List + getPublisherBuilderList() { + return getPublisherFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + gazebo.msgs.GzPublish.Publish, gazebo.msgs.GzPublish.Publish.Builder, gazebo.msgs.GzPublish.PublishOrBuilder> + getPublisherFieldBuilder() { + if (publisherBuilder_ == null) { + publisherBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + gazebo.msgs.GzPublish.Publish, gazebo.msgs.GzPublish.Publish.Builder, gazebo.msgs.GzPublish.PublishOrBuilder>( + publisher_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + publisher_ = null; + } + return publisherBuilder_; + } + + // @@protoc_insertion_point(builder_scope:gazebo.msgs.Publishers) + } + + static { + defaultInstance = new Publishers(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:gazebo.msgs.Publishers) + } + + private static com.google.protobuf.Descriptors.Descriptor + internal_static_gazebo_msgs_Publishers_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_gazebo_msgs_Publishers_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\020publishers.proto\022\013gazebo.msgs\032\rpublish" + + ".proto\"5\n\nPublishers\022\'\n\tpublisher\030\001 \003(\0132" + + "\024.gazebo.msgs.PublishB\016B\014GzPublishers" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + internal_static_gazebo_msgs_Publishers_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_gazebo_msgs_Publishers_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_gazebo_msgs_Publishers_descriptor, + new java.lang.String[] { "Publisher", }); + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + gazebo.msgs.GzPublish.getDescriptor(), + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzString.java b/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzString.java new file mode 100644 index 0000000000..54b575241d --- /dev/null +++ b/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzString.java @@ -0,0 +1,528 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: gz_string.proto + +package gazebo.msgs; + +public final class GzString { + private GzString() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + public interface StringOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required string data = 1; + /** + * required string data = 1; + */ + boolean hasData(); + /** + * required string data = 1; + */ + java.lang.String getData(); + /** + * required string data = 1; + */ + com.google.protobuf.ByteString + getDataBytes(); + } + /** + * Protobuf type {@code gazebo.msgs.String} + */ + public static final class String extends + com.google.protobuf.GeneratedMessage + implements StringOrBuilder { + // Use String.newBuilder() to construct. + private String(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private String(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final String defaultInstance; + public static String getDefaultInstance() { + return defaultInstance; + } + + public String getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private String( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + bitField0_ |= 0x00000001; + data_ = input.readBytes(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return gazebo.msgs.GzString.internal_static_gazebo_msgs_String_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return gazebo.msgs.GzString.internal_static_gazebo_msgs_String_fieldAccessorTable + .ensureFieldAccessorsInitialized( + gazebo.msgs.GzString.String.class, gazebo.msgs.GzString.String.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public String parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new String(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required string data = 1; + public static final int DATA_FIELD_NUMBER = 1; + private java.lang.Object data_; + /** + * required string data = 1; + */ + public boolean hasData() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string data = 1; + */ + public java.lang.String getData() { + java.lang.Object ref = data_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + data_ = s; + } + return s; + } + } + /** + * required string data = 1; + */ + public com.google.protobuf.ByteString + getDataBytes() { + java.lang.Object ref = data_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + data_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private void initFields() { + data_ = ""; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasData()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getDataBytes()); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getDataBytes()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static gazebo.msgs.GzString.String parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static gazebo.msgs.GzString.String parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static gazebo.msgs.GzString.String parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static gazebo.msgs.GzString.String parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static gazebo.msgs.GzString.String parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static gazebo.msgs.GzString.String parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static gazebo.msgs.GzString.String parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static gazebo.msgs.GzString.String parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static gazebo.msgs.GzString.String parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static gazebo.msgs.GzString.String parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(gazebo.msgs.GzString.String prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code gazebo.msgs.String} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements gazebo.msgs.GzString.StringOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return gazebo.msgs.GzString.internal_static_gazebo_msgs_String_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return gazebo.msgs.GzString.internal_static_gazebo_msgs_String_fieldAccessorTable + .ensureFieldAccessorsInitialized( + gazebo.msgs.GzString.String.class, gazebo.msgs.GzString.String.Builder.class); + } + + // Construct using gazebo.msgs.GzString.String.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + data_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return gazebo.msgs.GzString.internal_static_gazebo_msgs_String_descriptor; + } + + public gazebo.msgs.GzString.String getDefaultInstanceForType() { + return gazebo.msgs.GzString.String.getDefaultInstance(); + } + + public gazebo.msgs.GzString.String build() { + gazebo.msgs.GzString.String result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public gazebo.msgs.GzString.String buildPartial() { + gazebo.msgs.GzString.String result = new gazebo.msgs.GzString.String(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.data_ = data_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof gazebo.msgs.GzString.String) { + return mergeFrom((gazebo.msgs.GzString.String)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(gazebo.msgs.GzString.String other) { + if (other == gazebo.msgs.GzString.String.getDefaultInstance()) return this; + if (other.hasData()) { + bitField0_ |= 0x00000001; + data_ = other.data_; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasData()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + gazebo.msgs.GzString.String parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (gazebo.msgs.GzString.String) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required string data = 1; + private java.lang.Object data_ = ""; + /** + * required string data = 1; + */ + public boolean hasData() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string data = 1; + */ + public java.lang.String getData() { + java.lang.Object ref = data_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + data_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string data = 1; + */ + public com.google.protobuf.ByteString + getDataBytes() { + java.lang.Object ref = data_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + data_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string data = 1; + */ + public Builder setData( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + data_ = value; + onChanged(); + return this; + } + /** + * required string data = 1; + */ + public Builder clearData() { + bitField0_ = (bitField0_ & ~0x00000001); + data_ = getDefaultInstance().getData(); + onChanged(); + return this; + } + /** + * required string data = 1; + */ + public Builder setDataBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + data_ = value; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:gazebo.msgs.String) + } + + static { + defaultInstance = new String(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:gazebo.msgs.String) + } + + private static com.google.protobuf.Descriptors.Descriptor + internal_static_gazebo_msgs_String_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_gazebo_msgs_String_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\017gz_string.proto\022\013gazebo.msgs\"\026\n\006String" + + "\022\014\n\004data\030\001 \002(\t" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + internal_static_gazebo_msgs_String_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_gazebo_msgs_String_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_gazebo_msgs_String_descriptor, + new java.lang.String[] { "Data", }); + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzSubscribe.java b/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzSubscribe.java new file mode 100644 index 0000000000..b29c447abc --- /dev/null +++ b/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzSubscribe.java @@ -0,0 +1,1028 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: subscribe.proto + +package gazebo.msgs; + +public final class GzSubscribe { + private GzSubscribe() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + public interface SubscribeOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required string topic = 1; + /** + * required string topic = 1; + */ + boolean hasTopic(); + /** + * required string topic = 1; + */ + java.lang.String getTopic(); + /** + * required string topic = 1; + */ + com.google.protobuf.ByteString + getTopicBytes(); + + // required string host = 2; + /** + * required string host = 2; + */ + boolean hasHost(); + /** + * required string host = 2; + */ + java.lang.String getHost(); + /** + * required string host = 2; + */ + com.google.protobuf.ByteString + getHostBytes(); + + // required uint32 port = 3; + /** + * required uint32 port = 3; + */ + boolean hasPort(); + /** + * required uint32 port = 3; + */ + int getPort(); + + // required string msg_type = 4; + /** + * required string msg_type = 4; + */ + boolean hasMsgType(); + /** + * required string msg_type = 4; + */ + java.lang.String getMsgType(); + /** + * required string msg_type = 4; + */ + com.google.protobuf.ByteString + getMsgTypeBytes(); + + // optional bool latching = 5 [default = true]; + /** + * optional bool latching = 5 [default = true]; + */ + boolean hasLatching(); + /** + * optional bool latching = 5 [default = true]; + */ + boolean getLatching(); + } + /** + * Protobuf type {@code gazebo.msgs.Subscribe} + */ + public static final class Subscribe extends + com.google.protobuf.GeneratedMessage + implements SubscribeOrBuilder { + // Use Subscribe.newBuilder() to construct. + private Subscribe(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private Subscribe(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final Subscribe defaultInstance; + public static Subscribe getDefaultInstance() { + return defaultInstance; + } + + public Subscribe getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Subscribe( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + bitField0_ |= 0x00000001; + topic_ = input.readBytes(); + break; + } + case 18: { + bitField0_ |= 0x00000002; + host_ = input.readBytes(); + break; + } + case 24: { + bitField0_ |= 0x00000004; + port_ = input.readUInt32(); + break; + } + case 34: { + bitField0_ |= 0x00000008; + msgType_ = input.readBytes(); + break; + } + case 40: { + bitField0_ |= 0x00000010; + latching_ = input.readBool(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return gazebo.msgs.GzSubscribe.internal_static_gazebo_msgs_Subscribe_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return gazebo.msgs.GzSubscribe.internal_static_gazebo_msgs_Subscribe_fieldAccessorTable + .ensureFieldAccessorsInitialized( + gazebo.msgs.GzSubscribe.Subscribe.class, gazebo.msgs.GzSubscribe.Subscribe.Builder.class); + } + + public static com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + public Subscribe parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Subscribe(input, extensionRegistry); + } + }; + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + private int bitField0_; + // required string topic = 1; + public static final int TOPIC_FIELD_NUMBER = 1; + private java.lang.Object topic_; + /** + * required string topic = 1; + */ + public boolean hasTopic() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string topic = 1; + */ + public java.lang.String getTopic() { + java.lang.Object ref = topic_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + topic_ = s; + } + return s; + } + } + /** + * required string topic = 1; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + java.lang.Object ref = topic_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // required string host = 2; + public static final int HOST_FIELD_NUMBER = 2; + private java.lang.Object host_; + /** + * required string host = 2; + */ + public boolean hasHost() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required string host = 2; + */ + public java.lang.String getHost() { + java.lang.Object ref = host_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + host_ = s; + } + return s; + } + } + /** + * required string host = 2; + */ + public com.google.protobuf.ByteString + getHostBytes() { + java.lang.Object ref = host_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + host_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // required uint32 port = 3; + public static final int PORT_FIELD_NUMBER = 3; + private int port_; + /** + * required uint32 port = 3; + */ + public boolean hasPort() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * required uint32 port = 3; + */ + public int getPort() { + return port_; + } + + // required string msg_type = 4; + public static final int MSG_TYPE_FIELD_NUMBER = 4; + private java.lang.Object msgType_; + /** + * required string msg_type = 4; + */ + public boolean hasMsgType() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * required string msg_type = 4; + */ + public java.lang.String getMsgType() { + java.lang.Object ref = msgType_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + msgType_ = s; + } + return s; + } + } + /** + * required string msg_type = 4; + */ + public com.google.protobuf.ByteString + getMsgTypeBytes() { + java.lang.Object ref = msgType_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + msgType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + // optional bool latching = 5 [default = true]; + public static final int LATCHING_FIELD_NUMBER = 5; + private boolean latching_; + /** + * optional bool latching = 5 [default = true]; + */ + public boolean hasLatching() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + /** + * optional bool latching = 5 [default = true]; + */ + public boolean getLatching() { + return latching_; + } + + private void initFields() { + topic_ = ""; + host_ = ""; + port_ = 0; + msgType_ = ""; + latching_ = true; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasTopic()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasHost()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasPort()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasMsgType()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) == 0x00000001)) { + output.writeBytes(1, getTopicBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeBytes(2, getHostBytes()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeUInt32(3, port_); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + output.writeBytes(4, getMsgTypeBytes()); + } + if (((bitField0_ & 0x00000010) == 0x00000010)) { + output.writeBool(5, latching_); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) == 0x00000001)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, getTopicBytes()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, getHostBytes()); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream + .computeUInt32Size(3, port_); + } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(4, getMsgTypeBytes()); + } + if (((bitField0_ & 0x00000010) == 0x00000010)) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(5, latching_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @java.lang.Override + protected java.lang.Object writeReplace() + throws java.io.ObjectStreamException { + return super.writeReplace(); + } + + public static gazebo.msgs.GzSubscribe.Subscribe parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static gazebo.msgs.GzSubscribe.Subscribe parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static gazebo.msgs.GzSubscribe.Subscribe parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static gazebo.msgs.GzSubscribe.Subscribe parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static gazebo.msgs.GzSubscribe.Subscribe parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static gazebo.msgs.GzSubscribe.Subscribe parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static gazebo.msgs.GzSubscribe.Subscribe parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static gazebo.msgs.GzSubscribe.Subscribe parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static gazebo.msgs.GzSubscribe.Subscribe parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static gazebo.msgs.GzSubscribe.Subscribe parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(gazebo.msgs.GzSubscribe.Subscribe prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code gazebo.msgs.Subscribe} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder + implements gazebo.msgs.GzSubscribe.SubscribeOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return gazebo.msgs.GzSubscribe.internal_static_gazebo_msgs_Subscribe_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return gazebo.msgs.GzSubscribe.internal_static_gazebo_msgs_Subscribe_fieldAccessorTable + .ensureFieldAccessorsInitialized( + gazebo.msgs.GzSubscribe.Subscribe.class, gazebo.msgs.GzSubscribe.Subscribe.Builder.class); + } + + // Construct using gazebo.msgs.GzSubscribe.Subscribe.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + topic_ = ""; + bitField0_ = (bitField0_ & ~0x00000001); + host_ = ""; + bitField0_ = (bitField0_ & ~0x00000002); + port_ = 0; + bitField0_ = (bitField0_ & ~0x00000004); + msgType_ = ""; + bitField0_ = (bitField0_ & ~0x00000008); + latching_ = true; + bitField0_ = (bitField0_ & ~0x00000010); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return gazebo.msgs.GzSubscribe.internal_static_gazebo_msgs_Subscribe_descriptor; + } + + public gazebo.msgs.GzSubscribe.Subscribe getDefaultInstanceForType() { + return gazebo.msgs.GzSubscribe.Subscribe.getDefaultInstance(); + } + + public gazebo.msgs.GzSubscribe.Subscribe build() { + gazebo.msgs.GzSubscribe.Subscribe result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public gazebo.msgs.GzSubscribe.Subscribe buildPartial() { + gazebo.msgs.GzSubscribe.Subscribe result = new gazebo.msgs.GzSubscribe.Subscribe(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.topic_ = topic_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.host_ = host_; + if (((from_bitField0_ & 0x00000004) == 0x00000004)) { + to_bitField0_ |= 0x00000004; + } + result.port_ = port_; + if (((from_bitField0_ & 0x00000008) == 0x00000008)) { + to_bitField0_ |= 0x00000008; + } + result.msgType_ = msgType_; + if (((from_bitField0_ & 0x00000010) == 0x00000010)) { + to_bitField0_ |= 0x00000010; + } + result.latching_ = latching_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof gazebo.msgs.GzSubscribe.Subscribe) { + return mergeFrom((gazebo.msgs.GzSubscribe.Subscribe)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(gazebo.msgs.GzSubscribe.Subscribe other) { + if (other == gazebo.msgs.GzSubscribe.Subscribe.getDefaultInstance()) return this; + if (other.hasTopic()) { + bitField0_ |= 0x00000001; + topic_ = other.topic_; + onChanged(); + } + if (other.hasHost()) { + bitField0_ |= 0x00000002; + host_ = other.host_; + onChanged(); + } + if (other.hasPort()) { + setPort(other.getPort()); + } + if (other.hasMsgType()) { + bitField0_ |= 0x00000008; + msgType_ = other.msgType_; + onChanged(); + } + if (other.hasLatching()) { + setLatching(other.getLatching()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasTopic()) { + + return false; + } + if (!hasHost()) { + + return false; + } + if (!hasPort()) { + + return false; + } + if (!hasMsgType()) { + + return false; + } + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + gazebo.msgs.GzSubscribe.Subscribe parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (gazebo.msgs.GzSubscribe.Subscribe) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + // required string topic = 1; + private java.lang.Object topic_ = ""; + /** + * required string topic = 1; + */ + public boolean hasTopic() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + /** + * required string topic = 1; + */ + public java.lang.String getTopic() { + java.lang.Object ref = topic_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + topic_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string topic = 1; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + java.lang.Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string topic = 1; + */ + public Builder setTopic( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + topic_ = value; + onChanged(); + return this; + } + /** + * required string topic = 1; + */ + public Builder clearTopic() { + bitField0_ = (bitField0_ & ~0x00000001); + topic_ = getDefaultInstance().getTopic(); + onChanged(); + return this; + } + /** + * required string topic = 1; + */ + public Builder setTopicBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + topic_ = value; + onChanged(); + return this; + } + + // required string host = 2; + private java.lang.Object host_ = ""; + /** + * required string host = 2; + */ + public boolean hasHost() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + /** + * required string host = 2; + */ + public java.lang.String getHost() { + java.lang.Object ref = host_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + host_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string host = 2; + */ + public com.google.protobuf.ByteString + getHostBytes() { + java.lang.Object ref = host_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + host_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string host = 2; + */ + public Builder setHost( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + host_ = value; + onChanged(); + return this; + } + /** + * required string host = 2; + */ + public Builder clearHost() { + bitField0_ = (bitField0_ & ~0x00000002); + host_ = getDefaultInstance().getHost(); + onChanged(); + return this; + } + /** + * required string host = 2; + */ + public Builder setHostBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + host_ = value; + onChanged(); + return this; + } + + // required uint32 port = 3; + private int port_ ; + /** + * required uint32 port = 3; + */ + public boolean hasPort() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + /** + * required uint32 port = 3; + */ + public int getPort() { + return port_; + } + /** + * required uint32 port = 3; + */ + public Builder setPort(int value) { + bitField0_ |= 0x00000004; + port_ = value; + onChanged(); + return this; + } + /** + * required uint32 port = 3; + */ + public Builder clearPort() { + bitField0_ = (bitField0_ & ~0x00000004); + port_ = 0; + onChanged(); + return this; + } + + // required string msg_type = 4; + private java.lang.Object msgType_ = ""; + /** + * required string msg_type = 4; + */ + public boolean hasMsgType() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * required string msg_type = 4; + */ + public java.lang.String getMsgType() { + java.lang.Object ref = msgType_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + msgType_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string msg_type = 4; + */ + public com.google.protobuf.ByteString + getMsgTypeBytes() { + java.lang.Object ref = msgType_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + msgType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string msg_type = 4; + */ + public Builder setMsgType( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000008; + msgType_ = value; + onChanged(); + return this; + } + /** + * required string msg_type = 4; + */ + public Builder clearMsgType() { + bitField0_ = (bitField0_ & ~0x00000008); + msgType_ = getDefaultInstance().getMsgType(); + onChanged(); + return this; + } + /** + * required string msg_type = 4; + */ + public Builder setMsgTypeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000008; + msgType_ = value; + onChanged(); + return this; + } + + // optional bool latching = 5 [default = true]; + private boolean latching_ = true; + /** + * optional bool latching = 5 [default = true]; + */ + public boolean hasLatching() { + return ((bitField0_ & 0x00000010) == 0x00000010); + } + /** + * optional bool latching = 5 [default = true]; + */ + public boolean getLatching() { + return latching_; + } + /** + * optional bool latching = 5 [default = true]; + */ + public Builder setLatching(boolean value) { + bitField0_ |= 0x00000010; + latching_ = value; + onChanged(); + return this; + } + /** + * optional bool latching = 5 [default = true]; + */ + public Builder clearLatching() { + bitField0_ = (bitField0_ & ~0x00000010); + latching_ = true; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:gazebo.msgs.Subscribe) + } + + static { + defaultInstance = new Subscribe(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:gazebo.msgs.Subscribe) + } + + private static com.google.protobuf.Descriptors.Descriptor + internal_static_gazebo_msgs_Subscribe_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_gazebo_msgs_Subscribe_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\017subscribe.proto\022\013gazebo.msgs\"`\n\tSubscr" + + "ibe\022\r\n\005topic\030\001 \002(\t\022\014\n\004host\030\002 \002(\t\022\014\n\004port" + + "\030\003 \002(\r\022\020\n\010msg_type\030\004 \002(\t\022\026\n\010latching\030\005 \001" + + "(\010:\004trueB\rB\013GzSubscribe" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + internal_static_gazebo_msgs_Subscribe_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_gazebo_msgs_Subscribe_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_gazebo_msgs_Subscribe_descriptor, + new java.lang.String[] { "Topic", "Host", "Port", "MsgType", "Latching", }); + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzTime.java b/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzTime.java new file mode 100644 index 0000000000..faa0a46ce8 --- /dev/null +++ b/simulation/JavaGazebo/src/main/java/gazebo/msgs/GzTime.java @@ -0,0 +1,542 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: time.proto + +package gazebo.msgs; + +public final class GzTime { + private GzTime() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + public interface TimeOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required int32 sec = 1; + /** + * required int32 sec = 1; + */ + boolean hasSec(); + /** + * required int32 sec = 1; + */ + int getSec(); + + // required int32 nsec = 2; + /** + * required int32 nsec = 2; + */ + boolean hasNsec(); + /** + * required int32 nsec = 2; + */ + int getNsec(); + } + /** + * Protobuf type {@code gazebo.msgs.Time} + */ + public static final class Time extends + com.google.protobuf.GeneratedMessage + implements TimeOrBuilder { + // Use Time.newBuilder() to construct. + private Time(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + this.unknownFields = builder.getUnknownFields(); + } + private Time(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } + + private static final Time defaultInstance; + public static Time getDefaultInstance() { + return defaultInstance; + } + + public Time getDefaultInstanceForType() { + return defaultInstance; + } + + private final com.google.protobuf.UnknownFieldSet unknownFields; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Time( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + initFields(); + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + bitField0_ |= 0x00000001; + sec_ = input.readInt32(); + break; + } + case 16: { + bitField0_ |= 0x00000002; + nsec_ = input.readInt32(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return gazebo.msgs.GzTime.internal_static_gazebo_msgs_Time_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return gazebo.msgs.GzTime.internal_static_gazebo_msgs_Time_fieldAccessorTable + .ensureFieldAccessorsInitialized( + gazebo.msgs.GzTime.Time.class, gazebo.msgs.GzTime.Time.Builder.class); + } + + public static com.google.protobuf.Parser