Skip to content

Commit

Permalink
Merge pull request #460 from siemens/ROS2-Update
Browse files Browse the repository at this point in the history
General update, rework and improvements to the entire ROS# repository for ROS2
  • Loading branch information
memrecakal authored Oct 10, 2024
2 parents 93f771a + 65dfc8f commit fa4003b
Show file tree
Hide file tree
Showing 3,629 changed files with 142,204 additions and 24,172 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.vs/
/.vs
/.vs/slnx.sqlite
/Libraries/CombinedOutput
/test
Binary file removed .vs/slnx.sqlite
Binary file not shown.
4 changes: 1 addition & 3 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,5 @@ available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
---
© Siemens AG, 2017-2024

© Siemens AG, 2017

Author: Dr. Martin Bischoff ([email protected])
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ Please send your suggested documentation, preferably in markdown format, to the

---

© Siemens AG, 2017
© Siemens AG, 2017-2024

Author: Dr. Martin Bischoff ([email protected])
56 changes: 0 additions & 56 deletions ISSUE_TEMPLATE.md

This file was deleted.

44 changes: 40 additions & 4 deletions Libraries/MessageGeneration/ActionAutoGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace RosSharp.RosBridgeClient.MessageGeneration
{
public class ActionAutoGen
{
public static bool isRos2 = true;
private static readonly string[] types = {"Goal", "Result", "Feedback"};

public static List<string> GenerateSingleAction(string inPath, string outPath, string rosPackageName = "", bool verbose = false) {
Expand Down Expand Up @@ -61,7 +62,7 @@ public static List<string> GenerateSingleAction(string inPath, string outPath, s
string className = inFileName + types[i];

// Parse and generate goal, result, feedback messages
MessageParser parser = new MessageParser(tokens, outPath, rosPackageName, "action", MsgAutoGenUtilities.builtInTypesMapping, MsgAutoGenUtilities.builtInTypesDefaultInitialValues, className, className);
MessageParser parser = new MessageParser(tokens, outPath, rosPackageName, "action", MsgAutoGenUtilities.builtInTypesMapping, MsgAutoGenUtilities.builtInTypesDefaultInitialValues, className, className, isRos2: isRos2);
parser.Parse();
warnings.AddRange(parser.GetWarnings());

Expand Down Expand Up @@ -228,6 +229,16 @@ public void WrapActionSections(string type)
// Write block comment
writer.Write(MsgAutoGenUtilities.BLOCK_COMMENT + "\n");

// Write preprocessor directive: Begin
if (ActionAutoGen.isRos2)
{
writer.Write("#if ROS2\n");
}
else
{
writer.Write("#if !ROS2\n");
}

// Write imports
writer.Write(imports);

Expand Down Expand Up @@ -263,6 +274,9 @@ public void WrapActionSections(string type)
writer.Write(ONE_TAB + "}\n");
// Close namespace
writer.Write("}\n");

// Write preprocessor directive: End
writer.Write("#endif\n");
}
}

Expand All @@ -281,6 +295,16 @@ public void WrapAction()
// Write block comment
writer.Write(MsgAutoGenUtilities.BLOCK_COMMENT + "\n");

// Write preprocessor directive: Begin
if (ActionAutoGen.isRos2)
{
writer.Write("#if ROS2\n");
}
else
{
writer.Write("#if !ROS2\n");
}

// Write imports
writer.Write(imports);

Expand All @@ -305,9 +329,18 @@ public void WrapAction()
);

// Write ROS package name
writer.Write(
TWO_TABS + "public const string RosMessageName = \"" + rosPackageName + "/" + wrapperName + "\";\n"
);
if (ActionAutoGen.isRos2)
{
writer.Write(
TWO_TABS + "public const string RosMessageName = \"" + rosPackageName + "/" + "action" + "/"
+ wrapperName + "\";\n");
}
else
{
writer.Write(
TWO_TABS + "public const string RosMessageName = \"" + rosPackageName + "/" + wrapperName + "\";\n"
);
}

// Record variables
// Action Goal
Expand All @@ -324,6 +357,9 @@ public void WrapAction()
writer.Write(ONE_TAB + "}\n");
// Close namespace
writer.Write("}\n");

// Write preprocessor directive: End
writer.Write("#endif\n");
}
}

Expand Down
7 changes: 3 additions & 4 deletions Libraries/MessageGeneration/MessageAutoGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace RosSharp.RosBridgeClient.MessageGeneration

public class MessageAutoGen
{
public static bool isRos2 = true;
public static List<string> GenerateSingleMessage(string inPath, string outPath, string rosPackageName = "", bool verbose = false)
{
// If no ROS package name is provided, extract from path
Expand Down Expand Up @@ -52,14 +53,12 @@ public static List<string> GenerateSingleMessage(string inPath, string outPath,
throw new MessageParserException("Unexpected number of sections. Simple message should have 1 section.");
}

MessageParser parser = new MessageParser(listOfTokens[0], outPath, rosPackageName, "msg", MsgAutoGenUtilities.builtInTypesMapping, MsgAutoGenUtilities.builtInTypesDefaultInitialValues);
MessageParser parser = new MessageParser(listOfTokens[0], outPath, rosPackageName, "msg", MsgAutoGenUtilities.builtInTypesMapping, MsgAutoGenUtilities.builtInTypesDefaultInitialValues, isRos2: isRos2);
parser.Parse();
return parser.GetWarnings();
}
else {
if (verbose) {
Console.WriteLine(inFileName + " will not be generated");
}
Console.WriteLine(inFileName + " will not be generated, needs manuel attention.");
return new List<string>();
}
}
Expand Down
84 changes: 28 additions & 56 deletions Libraries/MessageGeneration/MessageGeneration.csproj
Original file line number Diff line number Diff line change
@@ -1,57 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<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>{F15D855D-FF65-4ADE-9972-31A3162E640E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MessageGeneration</RootNamespace>
<AssemblyName>MessageGeneration</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</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>
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<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" />
</ItemGroup>
<ItemGroup>
<Compile Include="ActionAutoGen.cs" />
<Compile Include="MessageAutoGen.cs" />
<Compile Include="MessageParser.cs" />
<Compile Include="MessageToken.cs" />
<Compile Include="MessageTokenizer.cs" />
<Compile Include="MsgAutoGenUtilities.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ServiceAutoGen.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Library</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Configurations>Debug;Release;ROS2</Configurations>
</PropertyGroup>
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<AssemblyTitle>MessageGeneration</AssemblyTitle>
<Description>.NET Library for generating C# source code for ROS message/service/action</Description>
<Company>Siemens AG</Company>
<Product>ROS#</Product>
<Copyright>Copyright © 2024</Copyright>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<FileVersion>2.0.0.0</FileVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
<Target Name="CopyToCombinedOutput" AfterTargets="Publish">
<!-- Copy the new DLLs to the combined output folder -->
<ItemGroup>
<NewDllFiles Include="$(OutputPath)\publish\*.dll" />
</ItemGroup>
<Copy SourceFiles="@(NewDllFiles)" DestinationFolder="$(SolutionDir)CombinedOutput" />
</Target>
</Project>
28 changes: 25 additions & 3 deletions Libraries/MessageGeneration/MessageParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class MessageParser{
private readonly string rosPackageName;
private readonly string className;
private readonly string rosMsgName;

private readonly string type;
private readonly string outPath;
private string outFilePath;

Expand All @@ -50,14 +50,16 @@ public class MessageParser{
private string body = "";

private List<string> warnings = new List<string>();
protected bool isRos2;

public MessageParser(List<MessageToken> tokens, string outPath, string rosPackageName, string type, Dictionary<string, string> builtInTypeMapping, Dictionary<string, string> builtInTypesDefaultInitialValues, string className = "", string rosMsgName = "") {
public MessageParser(List<MessageToken> tokens, string outPath, string rosPackageName, string type, Dictionary<string, string> builtInTypeMapping, Dictionary<string, string> builtInTypesDefaultInitialValues, string className = "", string rosMsgName = "", bool isRos2 = true) {
this.tokens = tokens;

this.inFilePath = tokens[0].content;
this.inFileName = Path.GetFileNameWithoutExtension(inFilePath);

this.rosPackageName = rosPackageName;
this.type = type;

if (className.Equals("")) {
this.className = MsgAutoGenUtilities.CapitalizeFirstLetter(inFileName);
Expand All @@ -83,6 +85,7 @@ public MessageParser(List<MessageToken> tokens, string outPath, string rosPackag

this.builtInTypeMapping = builtInTypeMapping;
this.builtInTypesDefaultInitialValues = builtInTypesDefaultInitialValues;
this.isRos2 = isRos2;
}

public void Parse() {
Expand All @@ -105,6 +108,15 @@ public void Parse() {
Line();
}

// Write preprocessor directive: Begin
if (isRos2)
{
writer.Write("#if ROS2");
}
else
{
writer.Write("#if !ROS2");
}
// Write imports
writer.Write(GenerateImports());

Expand All @@ -121,7 +133,14 @@ public void Parse() {
);

// Write ROS package name
writer.Write(MsgAutoGenUtilities.TWO_TABS + "public const string RosMessageName = \"" + rosPackageName + "/" + rosMsgName + "\";\n\n");
if (isRos2)
{
writer.Write(MsgAutoGenUtilities.TWO_TABS + "public const string RosMessageName = \"" + rosPackageName + "/" + type + "/" + rosMsgName + "\";\n\n");
}
else
{
writer.Write(MsgAutoGenUtilities.TWO_TABS + "public const string RosMessageName = \"" + rosPackageName + "/" + rosMsgName + "\";\n\n");
}

// Write body
writer.Write(body);
Expand All @@ -139,6 +158,9 @@ public void Parse() {
// Close namespace
writer.Write("}\n");

// Write preprocessor directive: End
writer.Write("#endif\n");

writer.Flush();
writer.Close();
}
Expand Down
23 changes: 0 additions & 23 deletions Libraries/MessageGeneration/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
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("MessageGeneration")]
[assembly: AssemblyDescription(".NET Library for generating C# source code for ROS message/service/action")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Siemens AG")]
[assembly: AssemblyProduct("ROS#")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -21,16 +11,3 @@

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f15d855d-ff65-4ade-9972-31a3162e640e")]

// 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.7.0.0")]
[assembly: AssemblyFileVersion("1.7.0.0")]
Loading

0 comments on commit fa4003b

Please sign in to comment.