GithubHelp home page GithubHelp logo

wpilibsuite / robotbuilder Goto Github PK

View Code? Open in Web Editor NEW
36.0 14.0 28.0 12.4 MB

Generate C++ or Java FRC programs

License: Other

Java 76.31% C 1.02% C++ 6.12% HTML 16.44% CSS 0.11%
wpilib robotics first-robotics-competition first-frc

robotbuilder's Introduction

RobotBuilder Project

Build Status

Welcome to the WPILib project. This repository contains the RobotBuilder project. This program can be used to automatically generate Java and C++ FRC programs using the New Command Framework.

WPILib Mission

The WPILib Mission is to enable FIRST teams to focus on writing game-specific software rather than on hardware details - "raise the floor, don't lower the ceiling". We try to enable teams with limited programming knowledge and/or mentor experience to do as much as possible, while not hampering the abilities of teams with more advanced programming capabilities. We support Kit of Parts control system components directly in the library. We also strive to keep parity between major features of each language (Java, C++, and NI's LabVIEW), so that teams aren't at a disadvantage for choosing a specific programming language. WPILib is an open-source project, licensed under the BSD 3-clause license. You can find a copy of the license here.

Building RobotBuilder

Building RobotBuilder is very straightforward. WPILib uses Gradle to compile.

Requirements

  • JDK 17
  • A c++ Compiler (for c++ compile test). Any one of:
    • On Linux, install GCC 11+
    • On Windows, install Visual Studio Community 2022 and select the C++ programming language during installation
    • On macOS, install the Xcode command-line build tools via xcode-select --install
    • ARM compiler toolchain
      • Run ./gradlew installRoboRioToolchain from a robot project
      • If the WPILib installer was used, this toolchain is already installed

Running

To run RobotBuilder use the command ./gradlew run.

Building

To build RobotBuilder use the command ./gradlew shadowjar. The runnable jar is build\libs\RobotBuilder-all.jar.

Contributing to WPILib

See CONTRIBUTING.md.

robotbuilder's People

Contributors

333fred avatar alexhenning avatar austinshalit avatar bradamiller avatar calcmogul avatar cbennet avatar cpapplefamily avatar devmanso avatar evinugur avatar jcaporuscio avatar jkuszmaul avatar jlleitschuh avatar nxmq avatar oblarg avatar peterjohnson avatar phurley avatar samcarlberg avatar sciencewhiz avatar spacey-sooty avatar spencergreene avatar thadhouse avatar wpiroboticsprojects-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

robotbuilder's Issues

Generated java has two returns in returnPIDInput()

Generated Java file has two lines:
return sensorName.get();
return sensorName.get();

Also, many of the generated lines (including these two) are not indented correctly.

This is the version in master immediately after the "eclipse" references were removed,

Remove C++ smart pointers in favor of uniform initialization syntax in header

Allocating variables on the stack and passing them around as references is a lot less verbose and still correct from an ownership perspective. It also reduces code duplication as the declaration and initialization are done in one place. This can't be done for the OI and subsystem instances, but we can at least use normal statics there. We already do both of these things for the allwpilib C++ examples.

Comment error in Robot.java generated by RobotBuilder

From @jee7s on May 19, 2017 3:20

In the referenced file, there is a comment that reads, in part:

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.

We found the location of the package and class definitions to be in the project's build.properties file, not the manifest file. Could this comment be updated for clarity?

Copied from original issue: wpilibsuite/allwpilib#541

Build fails with JDK 11

When using JDK 11, build fails with the following errors. The cause appears to be described here: https://bugs.openjdk.java.net/browse/JDK-8186648 and robot builder needs to be updated.

C:\Users\Joe\Documents\GitHub\RobotBuilder\src\main\java\robotbuilder\data\RobotComponent.java:160: error: incompatible types: Vector<TreeNode> cannot be converted to Vector<RobotComponent>
            return children;
                   ^
C:\Users\Joe\Documents\GitHub\RobotBuilder\src\main\java\robotbuilder\data\RobotComponent.java:167: error: incompatible types: Vector<DefaultMutableTreeNode> cannot be converted to Vector<TreeNode>
        this.children = children;
                        ^
C:\Users\Joe\Documents\GitHub\RobotBuilder\src\main\java\robotbuilder\ConstantsAdderDialog.java:90: error: incompatible types: Vector<Vector> cannot be converted to Vector<Vector<Object>>
        Vector<Vector<Object>> dataVector = getTableModel().getDataVector();
                                                                         ^
C:\Users\Joe\Documents\GitHub\RobotBuilder\src\main\java\robotbuilder\graph\CommandCellEditorDialog.java:71: error: incompatible types: Vector<Vector> cannot be converted to Vector<Vector<Object>>
        Vector<Vector<Object>> dataVector = parameterTable.getModel().getDataVector();
                                                                                   ^
C:\Users\Joe\Documents\GitHub\RobotBuilder\src\main\java\robotbuilder\ParameterAdderDialog.java:88: error: incompatible types: Vector<Vector> cannot be converted to Vector<Vector<Object>>
        Vector<Vector<Object>> dataVector = getTableModel().getDataVector();
                                                                         ^
C:\Users\Joe\Documents\GitHub\RobotBuilder\src\main\java\robotbuilder\ParameterEditorDialog.java:98: error: incompatible types: Vector<Vector> cannot be converted to Vector<Vector<Object>>
        Vector<Vector<Object>> dataVector = getTableModel().getDataVector();
                                                                         ^
C:\Users\Joe\Documents\GitHub\RobotBuilder\src\main\java\robotbuilder\ParameterSetsEditorDialog.java:46: error: incompatible types: Vector<Vector> cannot be converted to Vector<Vector<Object>>
        Vector<Vector<Object>> tableData = setsTable.getModel().getDataVector();
                                                                             ^
C:\Users\Joe\Documents\GitHub\RobotBuilder\src\main\java\robotbuilder\ParameterSetsTable.java:306: error: getDataVector() in PresetsTableModel cannot override getDataVector() in DefaultTableModel
        public Vector<Vector<Object>> getDataVector() {
                                      ^
  return type Vector<Vector<Object>> is not compatible with Vector<Vector>
C:\Users\Joe\Documents\GitHub\RobotBuilder\src\main\java\robotbuilder\ParameterSetsTable.java:305: error: method does not override or implement a method from a supertype
        @Override
        ^
C:\Users\Joe\Documents\GitHub\RobotBuilder\src\main\java\robotbuilder\ParameterSetsTable.java:307: error: incompatible types: Vector<Vector> cannot be converted to Vector<Vector<Object>>
            return super.getDataVector();

Improve error checking for DoubleSolenoid

Currently, if a double solenoid is declared on two different PCMs, instead of triggering Robot Builder error checking, it puts an error message in the users code.

Updating a preset for a command's parameters does not update usages of that preset

Detail

  1. Create a new command that takes a parameter (for example, a Setpoint Command)
  2. Add a preset for the parameters for that command
  3. Use that command elsewhere (button binding, command group, etc)
  4. Update the preset to use different value(s)

The usages of that command will still use the initial values of the preset, not the new ones.

Possible Solutions

Bind preset usages to that preset
This would make RobotBuilder read the preset values at generation time, not at use-time, and as such would always be up to date.

Generate static factory methods for each preset
For example, having a MoveElevator command taking a single setpoint as its argument and with the presets top, middle, bottom, and intake.

class MoveElevator extends SetpointCommand {
  MoveElevator(double setpoint);
  static MoveElevator moveElevatorToTop()
  static MoveElevator moveElevatorToMiddle()
  static MoveElevator moveElevatorToBottom()
  static MoveElevator moveElevatorToIntake()
}

This would be an improvement on the previous solution, as usages of the presets would need to know which factory method to call. The constructor would remain public so more than just the presets would be usable. However, a default constructor should not be generated

RobotBuilder overwrites subsystems that implement an interface

In java, if the user exports a subsystem, then keeps the base class, but implements an interface with the subsystem, the RobotBuilder parser sees that as changing the base class and overwrites the whole file. The parser should ignore the implements.

SpeedControllerGroup looses children on reorder

When moving a SpeedControllerGroup around in the tree it looses some of its children. It looks like it has a 50% retention rate.

Steps to reproduce:

  1. Open a RobotBuilder project
  2. Create a Subsystem
  3. Add a RobotDrive to the created subsystem
  4. Add a speed controller group to the subsystem
  5. Add speed controllers to the speed controller group
  6. Move the speed controllers to the RobotDrive

This also works when moving the speed controller group from the RobotDrive to another subsystem or subsystem to subsystem.

Save project settings in home/Robotbuilder

This would allow teams to have their RobotBuilder project files to be used by multiple people and let it be in their version control system.

Something like

~
|_ Robotbuilder
  |_ settings
    |_ gearsbot.yml
    |_ 2017bot.yml
    |_ practicebot.yml
    |_ ...

With the settings YAML files storing workspace, wiring file, etc.

workspace: /home/sam/workspace
simulation_world_file: ...
wiring_file_location: ...

Extensions !DistinctValidator

While trying to improve the TalonSRX and VictorSPX options in Robotbuilder I want to create a more custom Validator.

- !DistinctValidator
  name: CANSpeedControllerGroup
  fields: ["MasterSpeedController1", "SpeedController2", "SpeedController3", "SpeedController4"]

I can not seem to get the syntax correct in the Validators.yaml file. If I insert this into the robotbuilder source code and build/run it works as desired.
What might be the trick?

Re-Exporting C++ with TimedCommand causes exception

When re-exporting a project with a Timed Command, robot builder throws an exception when exporting the TimedCommand header.

  New type: TimedCommand
Modifying C:\Users\Joe\workspace\TimedCommandCPP\src\Commands\TimedCommand1.cpp
Saved type: TimedCommand
  New type: TimedCommand
Modifying C:\Users\Joe\workspace\TimedCommandCPP\src\Commands\TimedCommand1.h
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at java.io.Reader.<init>(Reader.java:78)
        at java.io.InputStreamReader.<init>(InputStreamReader.java:72)
        at robotbuilder.exporters.GenericExporter.evalResource(GenericExporter.java:237)
        at robotbuilder.exporters.ExportFile.export(ExportFile.java:61)
        at robotbuilder.exporters.GenericExporter.export(GenericExporter.java:164)
        at robotbuilder.actions.ExporterAction.actionPerformed(ExporterAction.java:36)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
        at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
        at java.awt.Component.processMouseEvent(Component.java:6533)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
        at java.awt.Component.processEvent(Component.java:6298)
        at java.awt.Container.processEvent(Container.java:2236)
        at java.awt.Component.dispatchEventImpl(Component.java:4889)
        at java.awt.Container.dispatchEventImpl(Container.java:2294)
        at java.awt.Component.dispatchEvent(Component.java:4711)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
        at java.awt.Container.dispatchEventImpl(Container.java:2280)
        at java.awt.Window.dispatchEventImpl(Window.java:2746)
        at java.awt.Component.dispatchEvent(Component.java:4711)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
        at java.awt.EventQueue.access$500(EventQueue.java:97)
        at java.awt.EventQueue$3.run(EventQueue.java:709)
        at java.awt.EventQueue$3.run(EventQueue.java:703)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
        at java.awt.EventQueue$4.run(EventQueue.java:731)
        at java.awt.EventQueue$4.run(EventQueue.java:729)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

This occurs with the attached yaml file, which is basically as simple as it can get.

Steps to reproduce:

  1. Load rb.yaml.txt
  2. Export to C++
  3. Export to C++ again

Generated code should have @Override/override

Good style.

eg

public class MyCommand extends Command {

  @Override
  protected void initialize() {
    ...
  }

}

or

class MyCommand : public frc::Command {
public:
  void initialize() override;
}

RobotBuilder Hangs when generating C++ code

Hello,

I have been using RobotBuilder successfully on the same laptop (windows 7), but within the last week have been seeing a problem that is now impacting code generation. I'm seeing an issue where after I click "C++" to generate the code, the cursor stays as a swirling blue ring (indicates something is busy). At first I didn't think this had any impact but now I am not seeing code updated in the files when I try to generate code. Note I have probably generated code 50+ times previously on same laptop, didn't change any software.

To test this, I have an empty command group and generate code. Then I add commands to the group and generate code, but no commands are added to the file.

I have refreshed the file, tried this with project closed, restarted eclipse and laptop. Now no code will generate.

-Ben Randolph

Robot Builder should support new command types

Robot Builder should have templates for the new Commands just added to WPILib (InstantCommand, TimedCommand)

  • TimedCommand Java
  • TimedCommand C++
  • InstantCommand Java
  • InstantCommand C++

Robotbuilder fails to load existing yml file.

We have one laptop using plugins version 2017.2.1 and one using 2017.1.1. The 2.1 version fails to load yml save file. The 1.1 works. When opening thru eclipse we get no output/result until we exit eclipse. Then exception/error window pops up. If we open Robotbuilder directly same thing happens after choosing to load existing project.
robotbuilder_exception

Our Robotbuilder.yml file can be found here: https://github.com/BHSRobotix/Steamworks2017/blob/master/RobotBuilder.yaml

Gradle depencies change warning

Gradle build warns about changed dependencies.

Changed dependencies of configuration ':lombok' after it has been included in dependency resolution. This behaviour has been deprecated and is scheduled to be removed in Gradle 3.0.
Changed dependencies of parent of configuration ':compile' after it has been resolved. This behaviour has been deprecated and is scheduled to be removed in Gradle 3.0

Subsystem imports are not regenerated

In RobotMap, the imports are regenerated based on what items are currently being exported. However, the Subsystem imports are not regenerated, so if a new item was added after they initial export, there will be compile errors due to the missing import.

VS Code compile does not find gradlew

I downloaded and built RobotBuilder as I did not have Eclipse installed.

If I create a template command robot program from VS Code the build works fine.

If I try to use robotbuilder on the template, I can't ever seem to get the paths to work properly to use the files created by the template. Robotbuild seems to have a different hard coded path to source code beginning with org...

I created a new robot builder program and then tried to use VS Code to edit. The edit worked fine, however, the build using WPILIB: Build Robot Code throws the following errors... robot builder doesn't seem to create the proper gradlew files or put them in the proper location for VS Code to find them.

Executing task: gradlew assemble --offline <

'gradlew' is not recognized as an internal or external command,
operable program or batch file.
The terminal process terminated with exit code: 1

I think the correct sequence to use robot builder and VS Code would be to create a robot initially with Robot Builder and then to edit and customize with VS Code?

There might be a similar issue with deploy?

Should CANTalon and CANJaguar be removed?

Since CANTalon and CANJaguar have been removed from WPILib, it seems like they should be removed from RobotBuilder as well. Since RobotBuilder supports extensions, they could be moved to extensions and installed by the CANTalon / CANJaguar installers.

Adding a pointer to the TalonSRX resources.

During set up of Robotbuilder we point to our Eclipse Workspace, Simulation File, Wiring file location and a few other customization. Would it be possible to Identify the TalonSRX Jar and equivalent C++ file locations and add that to the project if a SRX was selected as a motor controller? Now that third party devices are not included in the WPILIB but by the manufacture we need to add these to the project manually. Although knowing how to do this in Eclipse is not a bad skill. We also have to do this with our NavX Micro that simply can't be added using Robotbuilder.

#13 I just read that this issue may have already been asked

Add the ability to "finalize" your code

My suggestion is to give users the option to disable the ability to modify RobotBuilder in lieu of the removal of the automatic comments. Last year, we used RobotBuilder once in the very beginning of the year and it really helped set up the base of our code. Afterwards however, we only added and removed commands and subsystems, along with their dependencies, manually and ended up spending a while removing all of the auto-generated comments because they were a bit of an eyesore.

A system that allows changes to the RobotBuilder project until a user would like to continue manually. At that point, they will go through some advanced options to allow them to remove all automatic comments at once.

RobotBuilder leaves files open

After you export, RobotBuilder doesn't close all files until you exit. It should close it after export, and reopen the next time it exports.

Extension filter too strict

The filter for checking if an extension is valid requires that all files in the directory be files related to the extension. This makes it so that you can't add additional files, such as nested HTML or pictures. The filter should only check that required files exist and ignore extraneous files.

Subsystem & Command Name Validation

Subsystems and Commands should be validated to have the following properties:

  • have a capital letter
  • Do not conflict with another wpilib class name

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.