Skip to content

Commit

Permalink
Merge pull request #693 from Autodesk/emulator-restore
Browse files Browse the repository at this point in the history
Restored Emulator For WPI 2020 Updates
  • Loading branch information
MattMoradi authored Jan 9, 2021
2 parents 8549f83 + fce4e2a commit 41dcf1a
Show file tree
Hide file tree
Showing 148 changed files with 29,200 additions and 0 deletions.
1 change: 1 addition & 0 deletions emulation/EmulationCommunication/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages/*
25 changes: 25 additions & 0 deletions emulation/EmulationCommunication/EmulationCommunication.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.705
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmulationCommunication", "EmulationCommunication\EmulationCommunication.csproj", "{DED98240-B00B-4053-ADEE-4D717AA7339D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DED98240-B00B-4053-ADEE-4D717AA7339D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DED98240-B00B-4053-ADEE-4D717AA7339D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DED98240-B00B-4053-ADEE-4D717AA7339D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DED98240-B00B-4053-ADEE-4D717AA7339D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AC7030FD-3C34-4BB7-9581-1206B1410D83}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Grpc.Tools.1.22.0\build\Grpc.Tools.props" Condition="Exists('..\packages\Grpc.Tools.1.22.0\build\Grpc.Tools.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DED98240-B00B-4053-ADEE-4D717AA7339D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>EmulationCommunication</RootNamespace>
<AssemblyName>EmulationCommunication</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Google.Apis, Version=1.40.2.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Apis.1.40.2\lib\net45\Google.Apis.dll</HintPath>
</Reference>
<Reference Include="Google.Apis.Auth, Version=1.40.2.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Apis.Auth.1.40.2\lib\net45\Google.Apis.Auth.dll</HintPath>
</Reference>
<Reference Include="Google.Apis.Auth.PlatformServices, Version=1.40.2.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Apis.Auth.1.40.2\lib\net45\Google.Apis.Auth.PlatformServices.dll</HintPath>
</Reference>
<Reference Include="Google.Apis.Core, Version=1.40.2.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Apis.Core.1.40.2\lib\net45\Google.Apis.Core.dll</HintPath>
</Reference>
<Reference Include="Google.Apis.PlatformServices, Version=1.40.2.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Apis.1.40.2\lib\net45\Google.Apis.PlatformServices.dll</HintPath>
</Reference>
<Reference Include="Google.Protobuf, Version=3.9.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Protobuf.3.9.0\lib\net45\Google.Protobuf.dll</HintPath>
</Reference>
<Reference Include="Grpc.Auth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<HintPath>..\packages\Grpc.Auth.1.22.0\lib\net45\Grpc.Auth.dll</HintPath>
</Reference>
<Reference Include="Grpc.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<HintPath>..\packages\Grpc.Core.1.22.0\lib\net45\Grpc.Core.dll</HintPath>
</Reference>
<Reference Include="Grpc.Core.Api, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<HintPath>..\packages\Grpc.Core.Api.1.22.0\lib\net45\Grpc.Core.Api.dll</HintPath>
</Reference>
<Reference Include="Grpc.Reflection, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<HintPath>..\packages\Grpc.Reflection.1.22.0\lib\net45\Grpc.Reflection.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Interactive.Async, Version=3.2.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
<HintPath>..\packages\System.Interactive.Async.3.2.0\lib\net46\System.Interactive.Async.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="Zlib.Portable, Version=1.11.0.0, Culture=neutral, PublicKeyToken=431cba815f6a8b5b, processorArchitecture=MSIL">
<HintPath>..\packages\Zlib.Portable.Signed.1.11.0\lib\portable-net4+sl5+wp8+win8+wpa81+MonoTouch+MonoAndroid\Zlib.Portable.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Protobuf Include="..\..\api\v1\proto\emulator_service.proto" Link="protos\emulator_service.proto" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Grpc.Core.1.22.0\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.22.0\build\net45\Grpc.Core.targets'))" />
<Error Condition="!Exists('..\packages\Grpc.Tools.1.22.0\build\Grpc.Tools.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Tools.1.22.0\build\Grpc.Tools.props'))" />
<Error Condition="!Exists('..\packages\Grpc.Tools.1.22.0\build\Grpc.Tools.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Tools.1.22.0\build\Grpc.Tools.targets'))" />
</Target>
<Import Project="..\packages\Grpc.Core.1.22.0\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.22.0\build\net45\Grpc.Core.targets')" />
<Import Project="..\packages\Grpc.Tools.1.22.0\build\Grpc.Tools.targets" Condition="Exists('..\packages\Grpc.Tools.1.22.0\build\Grpc.Tools.targets')" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("EmulationCommunication")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EmulationCommunication")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("ded98240-b00b-4053-adee-4d717aa7339d")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
23 changes: 23 additions & 0 deletions emulation/EmulationCommunication/EmulationCommunication/app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Apis.Auth" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.40.2.0" newVersion="1.40.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Apis.Auth.PlatformServices" publicKeyToken="4b01fa6e34db77ab" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.40.2.0" newVersion="1.40.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Google.Protobuf" publicKeyToken="a7d26565bac4d604" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.9.0.0" newVersion="3.9.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Google.Apis" version="1.40.2" targetFramework="net461" />
<package id="Google.Apis.Auth" version="1.40.2" targetFramework="net461" />
<package id="Google.Apis.Core" version="1.40.2" targetFramework="net461" />
<package id="Google.Protobuf" version="3.9.0" targetFramework="net461" />
<package id="Grpc" version="1.22.0" targetFramework="net461" />
<package id="Grpc.Auth" version="1.22.0" targetFramework="net461" />
<package id="Grpc.Core" version="1.22.0" targetFramework="net461" />
<package id="Grpc.Core.Api" version="1.22.0" targetFramework="net461" />
<package id="Grpc.Reflection" version="1.22.0" targetFramework="net461" />
<package id="Grpc.Tools" version="1.22.0" targetFramework="net461" developmentDependency="true" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net461" />
<package id="System.Interactive.Async" version="3.2.0" targetFramework="net461" />
<package id="Zlib.Portable.Signed" version="1.11.0" targetFramework="net461" />
</packages>
19 changes: 19 additions & 0 deletions emulation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# FRC Robot Code Emulation

## Overview
The emulator is the Synthesis tool designed to help users test their FRC robot code ([Getting started with FRC control system](https://docs.wpilib.org "FRC Control System")). Users can upload their own user code as the FRC user programs they would normally deploy to the RoboRIO. Its normal communication with hardware is then redirected to the [engine](../engine "Engine Source") for simulation and testing.

## HEL - Hardware Emulation Layer
The core of Synthesis's emulator is HEL. HEL is a reimplementation of the NI FPGA, which normally runs on the RoboRIO, that instead runs in an [ARM](./emulator_building.md "Building the Emulator") or x86 virtual environment and interfaces with a simulation. This allows robot code to run on users' computers as a normal application and to communicates with Synthesis. Emulating this low layer of robot code runtime enables compatibility across new releases of WPILib and other external solutions. Read more [here](./hel/README.md "HEL README").

#### Engine and Exporter Integration

Although HEL may support emulation of a given input or output, it must interface with the engine simulation, which uses the user program to control the robot model and emulate RoboRIO inputs. This robot model was generated using Synthesis's [robot exporter tool](../exporters/robot_exporter "Robot Exporter Source"). In terms of emulation, the robot exporter tool is used to specify which inputs and outputs are attached to which parts of the robot. This means that as features are added to HEL, they must must also be added to the engine and robot exporter.

# Emulation Bridge and API

HEL communicates with the engine using [gRPC](https://grpc.io/ "gRPC Home Page"), an RPC framework utilizing [Google Protocol Buffers](https://developers.google.com/protocol-buffers/ "Google Protocol Buffers"). The definition of this API is located in the `api/v1` directory. HEL's CMake script automatically builds its own gRPC interface, while the C# solution in `EmulationCommunication` builds the interface used by the engine. The gRPC bridge application located in the `bridge` directory routes the connection from the engine to the correct virtual machine (x86 for Java; ARM for C++) and its running HEL instance.

# x86 Cross-Compilation

Due to recent updates to [WPILib](https://github.com/wpilibsuite/allwpilib "WPILib Source"), a separate virtual machine using an x86 architecture is now required to emulate Java and other JVM user programs. [Docker](https://www.docker.com/ "Docker Home Page") is used with [Buildroot](https://buildroot.org/ "Buildroot Home Page") to generate this x86 virtual machine. To compile WPILib's hardware abstraction layer (the HAL Athena implementation) for x86 instead of ARM, two shim files were needed, which are located in the `wpi_cross` folder.
Loading

0 comments on commit 41dcf1a

Please sign in to comment.