diff --git a/.styleguide b/.styleguide index 5cbd3e79f1..d835dfde51 100644 --- a/.styleguide +++ b/.styleguide @@ -16,6 +16,7 @@ modifiableFileExclude { generatedFileExclude { FRCNetComm\.java$ simulation/gz_msgs/src/include/simulation/gz_msgs/msgs\.h$ + fieldImages/src/main/native/resources/ } repoRootNameOverride { diff --git a/CMakeLists.txt b/CMakeLists.txt index e1cafeab76..a2b56f4c25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -239,6 +239,7 @@ if (WITH_TESTS) include(GoogleTest) endif() +add_subdirectory(fieldImages) add_subdirectory(wpiutil) add_subdirectory(ntcore) diff --git a/fieldImages/CMakeLists.txt b/fieldImages/CMakeLists.txt new file mode 100644 index 0000000000..efe6d4d85f --- /dev/null +++ b/fieldImages/CMakeLists.txt @@ -0,0 +1,37 @@ +project(fieldImages) + +include(CompileWarnings) +include(GenResources) + +if (WITH_JAVA) + find_package(Java REQUIRED) + include(UseJava) + + file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java) + file(GLOB_RECURSE JAVA_RESOURCES src/main/native/resources/*.json src/main/native/resources/*.png src/main/native/resources/*.jpg) + add_jar(field_images_jar SOURCES ${JAVA_SOURCES} RESOURCES NAMESPACE "edu/wpi/first/fields" ${JAVA_RESOURCES} OUTPUT_NAME fieldImages) + + get_property(FIELD_IMAGES_JAR_FILE TARGET field_images_jar PROPERTY JAR_FILE) + install(FILES ${FIELD_IMAGES_JAR_FILE} DESTINATION "${java_lib_dest}") + + set_property(TARGET field_images_jar PROPERTY FOLDER "java") + +endif() + + +GENERATE_RESOURCES(src/main/native/resources/edu/wpi/first/fields generated/main/cpp FIELDS fields field_images_resources_src) + + +add_library(fieldImages ${field_images_resources_src}) +set_target_properties(fieldImages PROPERTIES DEBUG_POSTFIX "d") + +set_property(TARGET fieldImages PROPERTY FOLDER "libraries") +target_compile_features(fieldImages PUBLIC cxx_std_17) +if (MSVC) + target_compile_options(fieldImages PUBLIC /bigobj) +endif() +wpilib_target_warnings(fieldImages) + +target_include_directories(fieldImages PUBLIC + $ + $) diff --git a/fieldImages/build.gradle b/fieldImages/build.gradle new file mode 100644 index 0000000000..03a3443fd0 --- /dev/null +++ b/fieldImages/build.gradle @@ -0,0 +1,66 @@ +import org.gradle.internal.os.OperatingSystem + +if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian') && !project.hasProperty('onlylinuxaarch64bionic')) { + + apply plugin: 'cpp' + apply plugin: 'c' + apply plugin: 'java' + apply plugin: 'google-test-test-suite' + apply plugin: 'visual-studio' + apply plugin: 'edu.wpi.first.NativeUtils' + + if (OperatingSystem.current().isWindows()) { + apply plugin: 'windows-resources' + } + + ext { + nativeName = 'fieldImages' + } + + apply from: "${rootDir}/shared/resources.gradle" + apply from: "${rootDir}/shared/config.gradle" + + def generateTask = createGenerateResourcesTask('main', 'FIELDS', 'fields', project) + + project(':').libraryBuild.dependsOn build + tasks.withType(CppCompile) { + dependsOn generateTask + } + + sourceSets { + main { + resources { + srcDirs 'src/main/native/resources' + } + } + } + + model { + components { + "${nativeName}"(NativeLibrarySpec) { + baseName = 'fieldImages' + sources { + cpp { + source { + srcDirs "$buildDir/generated/main/cpp" + include '**/*.cpp' + } + exportedHeaders { + srcDirs 'src/main/native/include' + } + } + if (OperatingSystem.current().isWindows()) { + rc { + source { + srcDirs 'src/main/native/win' + include '*.rc' + } + } + } + } + } + } + } + + apply from: 'publish.gradle' +} diff --git a/fieldImages/publish.gradle b/fieldImages/publish.gradle new file mode 100644 index 0000000000..b985f2158f --- /dev/null +++ b/fieldImages/publish.gradle @@ -0,0 +1,71 @@ +apply plugin: 'maven-publish' + +def baseArtifactId = 'fieldImages' +def artifactGroupId = 'edu.wpi.first.fieldImages' +def zipBaseName = '_GROUP_edu_wpi_first_field_images_ID_CLS' + +def outputsFolder = file("$project.buildDir/outputs") + +task cppSourcesZip(type: Zip) { + destinationDirectory = outputsFolder + archiveBaseName = zipBaseName + classifier = "sources" + + from(licenseFile) { + into '/' + } + + from('src/main/native/cpp') { + into '/' + } + from("$buildDir/generated/cpp") { + into '/' + } +} + +task cppHeadersZip(type: Zip) { + destinationDirectory = outputsFolder + archiveBaseName = zipBaseName + classifier = "headers" + + from(licenseFile) { + into '/' + } + + ext.includeDirs = [ + project.file('src/main/native/include') + ] + + ext.includeDirs.each { + from(it) { + into '/' + } + } +} + +build.dependsOn cppHeadersZip +build.dependsOn cppSourcesZip + +addTaskToCopyAllOutputs(cppHeadersZip) +addTaskToCopyAllOutputs(cppSourcesZip) + +model { + publishing { + def wpilibCTaskList = createComponentZipTasks($.components, ['fieldImages'], zipBaseName, Zip, project, includeStandardZipFormat) + + publications { + cpp(MavenPublication) { + wpilibCTaskList.each { + artifact it + } + + artifact cppHeadersZip + artifact cppSourcesZip + + artifactId = baseArtifactId + groupId artifactGroupId + version wpilibVersioning.version.get() + } + } + } +} diff --git a/fieldImages/src/main/java/edu/wpi/fields/FieldImages.java b/fieldImages/src/main/java/edu/wpi/fields/FieldImages.java new file mode 100644 index 0000000000..5602546855 --- /dev/null +++ b/fieldImages/src/main/java/edu/wpi/fields/FieldImages.java @@ -0,0 +1,23 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package edu.wpi.fields; + +public class FieldImages { + public static final String k2018PowerUpFieldConfig = "/edu/wpi/first/fields/2018-powerup.json"; + public static final String k2019DeepSpaceFieldConfig = + "/edu/wpi/first/fields/2019-deepspace.json"; + public static final String k2020InfiniteRechargeFieldConfig = + "/edu/wpi/first/fields/2020-infiniterecharge.json"; + public static final String k2021InfiniteRechargeFieldConfig = + "/edu/wpi/first/fields/2021-infiniterecharge.json"; + public static final String k2021BarrelFieldConfig = + "/edu/wpi/first/fields/2021-barrelracingpath.json"; + public static final String k2021BounceFieldConfig = "/edu/wpi/first/fields/2021-bouncepath.json"; + public static final String k2021GalacticSearchAFieldConfig = + "/edu/wpi/first/fields/2021-galacticsearcha.json"; + public static final String k2021GalacticSearchBFieldConfig = + "/edu/wpi/first/fields/2021-galacticsearchb.json"; + public static final String k2021SlalomFieldConfig = "/edu/wpi/first/fields/2021-slalompath.json"; +} diff --git a/fieldImages/src/main/native/include/fields/2018-powerup.h b/fieldImages/src/main/native/include/fields/2018-powerup.h new file mode 100644 index 0000000000..1f5b316c13 --- /dev/null +++ b/fieldImages/src/main/native/include/fields/2018-powerup.h @@ -0,0 +1,12 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +#pragma once + +#include + +namespace fields { +std::string_view GetResource_2018_powerup_json(); +std::string_view GetResource_2018_field_jpg(); +} // namespace fields diff --git a/fieldImages/src/main/native/include/fields/2019-deepspace.h b/fieldImages/src/main/native/include/fields/2019-deepspace.h new file mode 100644 index 0000000000..8d008d024d --- /dev/null +++ b/fieldImages/src/main/native/include/fields/2019-deepspace.h @@ -0,0 +1,12 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +#pragma once + +#include + +namespace fields { +std::string_view GetResource_2019_deepspace_json(); +std::string_view GetResource_2019_field_jpg(); +} // namespace fields diff --git a/fieldImages/src/main/native/include/fields/2020-infiniterecharge.h b/fieldImages/src/main/native/include/fields/2020-infiniterecharge.h new file mode 100644 index 0000000000..7d9a30cfb7 --- /dev/null +++ b/fieldImages/src/main/native/include/fields/2020-infiniterecharge.h @@ -0,0 +1,12 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +#pragma once + +#include + +namespace fields { +std::string_view GetResource_2020_infiniterecharge_json(); +std::string_view GetResource_2020_field_png(); +} // namespace fields diff --git a/fieldImages/src/main/native/include/fields/2021-barrel.h b/fieldImages/src/main/native/include/fields/2021-barrel.h new file mode 100644 index 0000000000..8f5ba1c6f1 --- /dev/null +++ b/fieldImages/src/main/native/include/fields/2021-barrel.h @@ -0,0 +1,12 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +#pragma once + +#include + +namespace fields { +std::string_view GetResource_2021_barrelracingpath_json(); +std::string_view GetResource_2021_barrel_png(); +} // namespace fields diff --git a/fieldImages/src/main/native/include/fields/2021-bounce.h b/fieldImages/src/main/native/include/fields/2021-bounce.h new file mode 100644 index 0000000000..66207fd8ce --- /dev/null +++ b/fieldImages/src/main/native/include/fields/2021-bounce.h @@ -0,0 +1,12 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +#pragma once + +#include + +namespace fields { +std::string_view GetResource_2021_bouncepath_json(); +std::string_view GetResource_2021_bounce_png(); +} // namespace fields diff --git a/fieldImages/src/main/native/include/fields/2021-galacticsearcha.h b/fieldImages/src/main/native/include/fields/2021-galacticsearcha.h new file mode 100644 index 0000000000..df74800ec2 --- /dev/null +++ b/fieldImages/src/main/native/include/fields/2021-galacticsearcha.h @@ -0,0 +1,12 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +#pragma once + +#include + +namespace fields { +std::string_view GetResource_2021_galacticsearcha_json(); +std::string_view GetResource_2021_galacticsearcha_png(); +} // namespace fields diff --git a/fieldImages/src/main/native/include/fields/2021-galacticsearchb.h b/fieldImages/src/main/native/include/fields/2021-galacticsearchb.h new file mode 100644 index 0000000000..cbf62311a5 --- /dev/null +++ b/fieldImages/src/main/native/include/fields/2021-galacticsearchb.h @@ -0,0 +1,12 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +#pragma once + +#include + +namespace fields { +std::string_view GetResource_2021_galacticsearchb_json(); +std::string_view GetResource_2021_galacticsearchb_png(); +} // namespace fields diff --git a/fieldImages/src/main/native/include/fields/2021-infiniterecharge.h b/fieldImages/src/main/native/include/fields/2021-infiniterecharge.h new file mode 100644 index 0000000000..10ca6585f1 --- /dev/null +++ b/fieldImages/src/main/native/include/fields/2021-infiniterecharge.h @@ -0,0 +1,12 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +#pragma once + +#include + +namespace fields { +std::string_view GetResource_2021_field_png(); +std::string_view GetResource_2021_infiniterecharge_json(); +} // namespace fields diff --git a/fieldImages/src/main/native/include/fields/2021-slalom.h b/fieldImages/src/main/native/include/fields/2021-slalom.h new file mode 100644 index 0000000000..a660f1bbeb --- /dev/null +++ b/fieldImages/src/main/native/include/fields/2021-slalom.h @@ -0,0 +1,12 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +#pragma once + +#include + +namespace fields { +std::string_view GetResource_2021_slalompath_json(); +std::string_view GetResource_2021_slalom_png(); +} // namespace fields diff --git a/fieldImages/src/main/native/resources/edu/wpi/first/fields/2018-field.jpg b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2018-field.jpg new file mode 100644 index 0000000000..cf5bb91f6c Binary files /dev/null and b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2018-field.jpg differ diff --git a/fieldImages/src/main/native/resources/edu/wpi/first/fields/2018-powerup.json b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2018-powerup.json new file mode 100644 index 0000000000..1b63c2934d --- /dev/null +++ b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2018-powerup.json @@ -0,0 +1,10 @@ +{ + "game": "FIRST Power Up", + "field-image": "2018-field.jpg", + "field-corners": { + "top-left": [125, 20], + "bottom-right": [827, 370] + }, + "field-size": [54, 27], + "field-unit": "feet" +} diff --git a/fieldImages/src/main/native/resources/edu/wpi/first/fields/2019-deepspace.json b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2019-deepspace.json new file mode 100644 index 0000000000..96087f740e --- /dev/null +++ b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2019-deepspace.json @@ -0,0 +1,10 @@ +{ +"game" : "Destination: Deep Space", +"field-image" : "2019-field.jpg", +"field-corners": { + "top-left" : [217, 40], + "bottom-right" : [1372, 615] +}, +"field-size" : [54, 27], +"field-unit" : "foot" +} diff --git a/fieldImages/src/main/native/resources/edu/wpi/first/fields/2019-field.jpg b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2019-field.jpg new file mode 100644 index 0000000000..20b966268d Binary files /dev/null and b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2019-field.jpg differ diff --git a/fieldImages/src/main/native/resources/edu/wpi/first/fields/2020-field.png b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2020-field.png new file mode 100644 index 0000000000..8b18648e82 Binary files /dev/null and b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2020-field.png differ diff --git a/fieldImages/src/main/native/resources/edu/wpi/first/fields/2020-infiniterecharge.json b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2020-infiniterecharge.json new file mode 100644 index 0000000000..6187cae89c --- /dev/null +++ b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2020-infiniterecharge.json @@ -0,0 +1,10 @@ +{ + "game" : "Infinite Recharge", + "field-image" : "2020-field.png", + "field-corners": { + "top-left" : [96, 25], + "bottom-right" : [1040, 514] + }, + "field-size" : [52.4375, 26.9375], + "field-unit" : "foot" + } diff --git a/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-barrel.png b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-barrel.png new file mode 100644 index 0000000000..acfc96a44e Binary files /dev/null and b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-barrel.png differ diff --git a/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-barrelracingpath.json b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-barrelracingpath.json new file mode 100644 index 0000000000..c0e49dc063 --- /dev/null +++ b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-barrelracingpath.json @@ -0,0 +1,10 @@ +{ + "game": "Barrel Racing Path", + "field-image": "2021-barrel.png", + "field-corners": { + "top-left": [20, 20], + "bottom-right": [780, 400] + }, + "field-size": [30, 15], + "field-unit": "feet" + } diff --git a/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-bounce.png b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-bounce.png new file mode 100644 index 0000000000..8f9594aea9 Binary files /dev/null and b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-bounce.png differ diff --git a/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-bouncepath.json b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-bouncepath.json new file mode 100644 index 0000000000..b02b855bcd --- /dev/null +++ b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-bouncepath.json @@ -0,0 +1,10 @@ +{ + "game": "Bounce Path", + "field-image": "2021-bounce.png", + "field-corners": { + "top-left": [20, 20], + "bottom-right": [780, 400] + }, + "field-size": [30, 15], + "field-unit": "feet" + } diff --git a/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-field.png b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-field.png new file mode 100644 index 0000000000..3c74df88da Binary files /dev/null and b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-field.png differ diff --git a/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-galacticsearcha.json b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-galacticsearcha.json new file mode 100644 index 0000000000..063d351cbc --- /dev/null +++ b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-galacticsearcha.json @@ -0,0 +1,10 @@ +{ + "game": "Galactic Search A", + "field-image": "2021-galacticsearcha.png", + "field-corners": { + "top-left": [20, 20], + "bottom-right": [780, 400] + }, + "field-size": [30, 15], + "field-unit": "feet" + } diff --git a/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-galacticsearcha.png b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-galacticsearcha.png new file mode 100644 index 0000000000..69b10d68d2 Binary files /dev/null and b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-galacticsearcha.png differ diff --git a/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-galacticsearchb.json b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-galacticsearchb.json new file mode 100644 index 0000000000..615ec45009 --- /dev/null +++ b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-galacticsearchb.json @@ -0,0 +1,10 @@ +{ + "game": "Galactic Search B", + "field-image": "2021-galacticsearchb.png", + "field-corners": { + "top-left": [20, 20], + "bottom-right": [780, 400] + }, + "field-size": [30, 15], + "field-unit": "feet" + } diff --git a/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-galacticsearchb.png b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-galacticsearchb.png new file mode 100644 index 0000000000..90daef5a1b Binary files /dev/null and b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-galacticsearchb.png differ diff --git a/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-infiniterecharge.json b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-infiniterecharge.json new file mode 100644 index 0000000000..d34fc6506f --- /dev/null +++ b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-infiniterecharge.json @@ -0,0 +1,10 @@ +{ + "game": "Infinite Recharge 2021", + "field-image": "2021-field.png", + "field-corners": { + "top-left": [127, 34], + "bottom-right": [1323, 649] + }, + "field-size": [52.4375, 26.9375], + "field-unit": "foot" + } diff --git a/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-slalom.png b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-slalom.png new file mode 100644 index 0000000000..b1753268cd Binary files /dev/null and b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-slalom.png differ diff --git a/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-slalompath.json b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-slalompath.json new file mode 100644 index 0000000000..bb80f55b92 --- /dev/null +++ b/fieldImages/src/main/native/resources/edu/wpi/first/fields/2021-slalompath.json @@ -0,0 +1,10 @@ +{ + "game": "Slalom Path", + "field-image": "2021-slalom.png", + "field-corners": { + "top-left": [20, 20], + "bottom-right": [780, 400] + }, + "field-size": [30, 15], + "field-unit": "feet" + } diff --git a/settings.gradle b/settings.gradle index ac22bc4fc9..dc3be28b6c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -29,6 +29,7 @@ include 'wpilibjExamples' include 'wpilibjIntegrationTests' include 'wpilibj' include 'crossConnIntegrationTests' +include 'fieldImages' include 'glass' include 'outlineviewer' include 'simulation:gz_msgs' diff --git a/shared/resources.gradle b/shared/resources.gradle index f5aa19f241..4fecb17f8f 100644 --- a/shared/resources.gradle +++ b/shared/resources.gradle @@ -1,3 +1,5 @@ +import groovy.io.FileType + ext.createGenerateResourcesTask = { name, prefix, namespace, project -> def generatedOutputDir = file("$buildDir/generated/$name/cpp") @@ -11,7 +13,7 @@ ext.createGenerateResourcesTask = { name, prefix, namespace, project -> doLast { generatedOutputDir.mkdirs() - inputDir.eachFile { inputFile -> + inputDir.eachFileRecurse (FileType.FILES) { inputFile -> if (inputFile.name.startsWith('.')) return def fileBytes = inputFile.bytes def outputFile = file("$generatedOutputDir/${inputFile.name}.cpp")