Skip to content

Commit c27f00c

Browse files
authored
Release 0.7.0
AIRO-1696
2 parents 7f05510 + 84fe88f commit c27f00c

File tree

84 files changed

+1715
-235
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1715
-235
lines changed

.github/workflows/jira-link.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: jira-link
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, reopened, synchronize]
6+
7+
jobs:
8+
jira-link:
9+
runs-on: ubuntu-20.04
10+
steps:
11+
- name: check pull request title and source branch name
12+
run: |
13+
echo "Checking pull request with title ${{ github.event.pull_request.title }} from source branch ${{ github.event.pull_request.head.ref }}"
14+
if ! [[ "${{ github.event.pull_request.title }}" =~ ^AIRO-[0-9]+[[:space:]].*$ ]] && ! [[ "${{ github.event.pull_request.head.ref }}" =~ ^AIRO-[0-9]+.*$ ]]
15+
then
16+
echo -e "Please make sure one of the following is true:\n \
17+
1. the pull request title starts with 'AIRO-xxxx ', e.g. 'AIRO-1024 My Pull Request'\n \
18+
2. the source branch starts with 'AIRO-xxx', e.g. 'AIRO-1024-my-branch'"
19+
exit 1
20+
else
21+
echo "Completed checking"
22+
fi

.yamato/sonar.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Sonarqube Scan
2+
agent:
3+
type: Unity::metal::macmini
4+
image: package-ci/mac
5+
flavor: m1.mac
6+
variables:
7+
PROJECT_PATH: TestRosTcpConnector
8+
SONARQUBE_PROJECT_KEY: ai-robotics-ros-tcp-connector
9+
SONARQUBE_PROJECT_BASE_DIR: /Users/bokken/build/output/Unity-Technologies/ROS-TCP-Connector/com.unity.robotics.ros-tcp-connector
10+
MSBUILD_SLN_PATH: ./TestRosTcpConnector/TestRosTcpConnector.sln
11+
UNITY_VERSION: 2020.3.11f1
12+
commands:
13+
- npm install upm-ci-utils@stable -g --registry https://artifactory.prd.it.unity3d.com/artifactory/api/npm/upm-npm
14+
- unity-downloader-cli -u $UNITY_VERSION -c Editor
15+
- brew install mono corretto
16+
- curl https://github.com/SonarSource/sonar-scanner-msbuild/releases/download/5.2.1.31210/sonar-scanner-msbuild-5.2.1.31210-net46.zip -o sonar-scanner-msbuild-net46.zip -L
17+
- unzip sonar-scanner-msbuild-net46.zip -d ~
18+
- chmod a+x ~/sonar-scanner-4.6.1.2450/bin/sonar-scanner
19+
- .Editor/Unity.app/Contents/MacOS/Unity -projectPath $PROJECT_PATH -batchmode -quit -nographics -logFile - -executeMethod "UnityEditor.SyncVS.SyncSolution"
20+
- command: |
21+
cd $PROJECT_PATH
22+
for file in *.csproj; do sed -i.backup "s/^[[:blank:]]*<ReferenceOutputAssembly>false<\/ReferenceOutputAssembly>/<ReferenceOutputAssembly>true<\/ReferenceOutputAssembly>/g" $file; rm $file.backup; done
23+
cd ../
24+
- mono ~/SonarScanner.MSBuild.exe begin /k:$SONARQUBE_PROJECT_KEY /d:sonar.host.url=$SONARQUBE_ENDPOINT_URL_PRD /d:sonar.login=$SONARQUBE_TOKEN_PRD /d:sonar.projectBaseDir=$SONARQUBE_PROJECT_BASE_DIR
25+
- msbuild $MSBUILD_SLN_PATH
26+
- mono ~/SonarScanner.MSBuild.exe end /d:sonar.login=$SONARQUBE_TOKEN_PRD
27+
triggers:
28+
cancel_old_ci: true
29+
expression: |
30+
((pull_request.target eq "main" OR pull_request.target eq "dev")
31+
AND NOT pull_request.push.changes.all match "**/*.md") OR
32+
(push.branch eq "main" OR push.branch eq "dev")

.yamato/yamato-config.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,27 @@ agent:
44
image: robotics/ci-ubuntu20:v0.1.0-795910
55
flavor: i1.large
66
variables:
7+
# Coverage is defined in a percentage (out of 100)
8+
COVERAGE_EXPECTED: 2.5
79
PATH: /root/.local/bin:/home/bokken/bin:/home/bokken/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/sbin:/home/bokken/.npm-global/bin
810
commands:
911
- python3 -m pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade
1012
- unity-downloader-cli -u 2020.2.0b9 -c editor -c StandaloneSupport-IL2CPP -c Linux --wait --published
1113
- git clone [email protected]:unity/utr.git utr
12-
- utr/utr --testproject=./TestRosTcpConnector --editor-location=.Editor --reruncount=0 --artifacts_path=test-results --suite=playmode --suite=editor --platform=Editor --enable-code-coverage --coverage-results-path=../test-results --coverage-options="assemblyFilters:+Unity.Robotics.ROSTCPConnector,+Unity.Robotics.ROSTCPConnector.Editor;generateHtmlReport;generateBadgeReport;generateAdditionalMetrics"
14+
- utr/utr --testproject=./TestRosTcpConnector --editor-location=.Editor --reruncount=0 --artifacts_path=test-results --suite=playmode --suite=editor --platform=Editor --enable-code-coverage --coverage-results-path=../test-results --coverage-options="assemblyFilters:+Unity.Robotics.ROSTCPConnector,+Unity.Robotics.ROSTCPConnector.Editor,+Unity.Robotics.ROSTCPConnector.MessageGeneration;generateHtmlReport;generateBadgeReport;generateAdditionalMetrics"
1315
# check test coverage
1416
- command: |
1517
linecoverage=$(cat test-results/Report/Summary.xml | grep Linecoverage | grep -Eo '[+-]?[0-9]+([.][0-9]+)?')
1618
echo "Line coverage: $linecoverage%"
17-
if (( $(echo "$linecoverage < 0" | bc -l) )); then exit 1; fi
19+
if (( $(echo "$linecoverage < $COVERAGE_EXPECTED" | bc -l) ))
20+
then echo "ERROR: Code coverage is under threshold of $COVERAGE_EXPECTED%" && exit 1
21+
fi
1822
triggers:
1923
cancel_old_ci: true
2024
expression: |
21-
(pull_request.target eq "main" AND
22-
NOT pull_request.push.changes.all match "**/*.md") OR
23-
(pull_request.target eq "dev" AND
24-
NOT pull_request.push.changes.all match "**/*.md")
25+
((pull_request.target eq "main" OR pull_request.target eq "dev")
26+
AND NOT pull_request.push.changes.all match "**/*.md") OR
27+
(push.branch eq "main" OR push.branch eq "dev")
2528
artifacts:
2629
logs:
2730
paths:

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22

33
[![Version](https://img.shields.io/github/v/tag/Unity-Technologies/ROS-TCP-Connector)](https://github.com/Unity-Technologies/ROS-TCP-Connector/releases)
44
[![License](https://img.shields.io/badge/license-Apache--2.0-green.svg)](LICENSE.md)
5-
![ROS](https://img.shields.io/badge/ros-melodic-brightgreen)
6-
![ROS](https://img.shields.io/badge/ros-noetic-brightgreen)
7-
![ROS](https://img.shields.io/badge/ros2-foxy-brightgreen)
5+
![ROS](https://img.shields.io/badge/ros-melodic,noetic-brightgreen)
6+
![ROS](https://img.shields.io/badge/ros2-foxy,galactic-brightgreen)
87
![Unity](https://img.shields.io/badge/unity-2020.2+-brightgreen)
98

9+
---
10+
11+
We're currently working on lots of things! Please take a short moment fill out our [survey](https://unitysoftware.co1.qualtrics.com/jfe/form/SV_0ojVkDVW0nNrHkW) to help us identify what products and packages to build next.
12+
13+
---
14+
1015
## Introduction
1116

1217
This repository contains two Unity packages: the ROS TCP Connector, for sending/receiving messages from ROS, and the Visualizations Package, for adding visualizations of incoming and outgoing messages in the Unity scene.

ROSGeometry.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,13 @@ Or, if you need to work with it in the FLU coordinate space for now, you can wri
9898
(Note, the As function does NOT do any coordinate conversion. It simply assumes the point is in the FLU coordinate frame already, and transfers it into an appropriate container.)
9999

100100
And again, the same goes for converting a Quaternion message into a Unity Quaternion or `Quaternion<C>`.
101+
102+
# Geographical Coordinates
103+
104+
The geographical coordinate systems NED and ENU are more complicated than the rest: besides the obvious "north" direction, they also provide a convention for which direction is "forward", which is not even consistent between them - In NED, forward (i.e. yaw 0) is north, whereas in ENU forward is east. Because of this inconsistency, there's no universal convention that we could establish for which direction is north in Unity. Instead, we're forced to make a distinction between local and world rotations.
105+
106+
To correctly convert a *world* position or rotation to or from NED or ENU coordinates, you should use the standard NED or ENU coordinate space - for example, `To<NED>()`. This conversion will respect what direction you have set as North. By default, the Unity Z axis points north, but this is a configuration option that you can change in the Robotics/ROS Settings menu.
107+
108+
If you have a *local* rotation represented in NED or ENU coordinates, you should convert it using the coordinate space NEDLocal or ENULocal: for example, `To<NEDLocal>()`. These conversions are not appropriate for handling world rotations, because they don't respect the north direction, only what direction is forward (i.e. the Unity Z axis). In other words, with NEDLocal and ENULocal, an identity quaternion is still identity. This is not necessarily true for NED or ENU. NEDLocal is a synonym for the FRD coordinate space (north = forward, east = right, down = down) and ENULocal is a synonym for the FLU coordinate space (east = forward, north = left, up = up).
109+
110+
If you only care about NED coordinates, you can avoid having to deal with this distinction by setting the Z axis direction to North (the default) - this will make the NED coordinate space equal to NEDLocal. Similarly, if you only care about ENU coordinates, setting the Z axis direction to East will make ENU equal to ENULocal.

TestRosTcpConnector/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
/[Bb]uild.app/
1212
/[Ll]ogs/
1313
/[Uu]ser[Ss]ettings/
14+
/[Cc]ode[Cc]overage/
1415

1516
# MemoryCaptures can get excessive in size.
1617
# They also could contain extremely sensitive data
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &11400000
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 0
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
m_GameObject: {fileID: 0}
10+
m_Enabled: 1
11+
m_EditorHideFlags: 0
12+
m_Script: {fileID: 11500000, guid: 6ad8cf01110e54df290b36a418e91285, type: 3}
13+
m_Name: GeometryCompassSettings
14+
m_EditorClassIdentifier:
15+
m_ZAxisDirection: 3

TestRosTcpConnector/Assets/Resources/GeometryCompassSettings.asset.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TestRosTcpConnector/Assets/Settings/ForwardRenderer.asset

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ MonoBehaviour:
2121
copyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3}
2222
screenSpaceShadowPS: {fileID: 4800000, guid: 0f854b35a0cf61a429bd5dcfea30eddd, type: 3}
2323
samplingPS: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3}
24+
tileDepthInfoPS: {fileID: 0}
25+
tileDeferredPS: {fileID: 0}
26+
stencilDeferredPS: {fileID: 4800000, guid: e9155b26e1bc55942a41e518703fe304, type: 3}
2427
fallbackErrorPS: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3}
28+
materialErrorPS: {fileID: 4800000, guid: 5fd9a8feb75a4b5894c241777f519d4e, type: 3}
2529
m_OpaqueLayerMask:
2630
serializedVersion: 2
2731
m_Bits: 4294967295
@@ -36,3 +40,5 @@ MonoBehaviour:
3640
failOperation: 0
3741
zFailOperation: 0
3842
m_ShadowTransparentReceive: 1
43+
m_RenderingMode: 0
44+
m_AccurateGbufferNormals: 0
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"m_Name": "Settings",
3+
"m_Path": "ProjectSettings/Packages/com.unity.testtools.codecoverage/Settings.json",
4+
"m_Dictionary": {
5+
"m_DictionaryValues": [
6+
{
7+
"type": "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
8+
"key": "Path",
9+
"value": "{\"m_Value\":\"{ProjectPath}\"}"
10+
},
11+
{
12+
"type": "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
13+
"key": "HistoryPath",
14+
"value": "{\"m_Value\":\"{ProjectPath}\"}"
15+
},
16+
{
17+
"type": "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
18+
"key": "IncludeAssemblies",
19+
"value": "{\"m_Value\":\"Unity.Robotics.ROSTCPConnector,Unity.Robotics.ROSTCPConnector.Editor,Unity.Robotics.ROSTCPConnector.MessageGeneration\"}"
20+
},
21+
{
22+
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
23+
"key": "EnableCodeCoverage",
24+
"value": "{\"m_Value\":true}"
25+
}
26+
]
27+
}
28+
}

com.unity.robotics.ros-tcp-connector/CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ All notable changes to this repository will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
78
## Unreleased
89

910
### Upgrade Notes
@@ -21,6 +22,35 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
2122
### Fixed
2223

2324

25+
## [0.7.0-preview] - 2022-02-01
26+
27+
### Added
28+
29+
Added "Listen for TF Messages" to Settings
30+
31+
Enabled Android and IOS builds
32+
33+
Added Sonarqube scanner
34+
35+
Added more tests
36+
37+
Add support for cloud rendering
38+
39+
Added MessagePool<T> to enable message reuse and reduce garbage collection
40+
41+
Can configure what direction is "north" for NED and ENU coordinates
42+
43+
### Changed
44+
45+
CameraInfo.msg field names are different in ROS2
46+
47+
Bug fix - cope with tab character in a .msg file
48+
49+
Bug fix - no padding when serializing an empty array
50+
51+
Can publish messages from threads other than main
52+
53+
2454
## [0.6.0-preview] - 2021-09-30
2555

2656
Add the [Close Stale Issues](https://github.com/marketplace/actions/close-stale-issues) action
@@ -49,6 +79,8 @@ Upgrade the TestRosTcpConnector project to use Unity LTS version 2020.3.11f1
4979

5080
- Unity service implementations can be async
5181

82+
- Added geographical world coordinate transformation by a Compass component
83+
5284
### Changed
5385
- Publishing a message to an unregistered topic will show an error.
5486
- Registering a service now requires both the request and response message type.

com.unity.robotics.ros-tcp-connector/Editor/MessageGeneration/ActionAutoGen.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,9 @@ public void WrapActionSections(string type)
354354

355355
writer.Write(GenerateSerializationStatements(type));
356356

357+
// Omit the subtype because subtype is baked into the class name
358+
writer.Write(MsgAutoGenUtilities.InitializeOnLoad());
359+
357360
// Close class
358361
writer.Write(ONE_TAB + "}\n");
359362
// Close namespace

com.unity.robotics.ros-tcp-connector/Editor/MessageGeneration/MessageParser.cs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -154,20 +154,10 @@ public void Parse()
154154
// Write ToString override
155155
writer.Write(GenerateToString());
156156

157-
string subtopicParameter = subtopic == MessageSubtopic.Default ? "" : $", MessageSubtopic.{subtopic}";
157+
var subtopicParameter =
158+
subtopic == MessageSubtopic.Default ? "" : $", MessageSubtopic.{subtopic}";
158159

159-
writer.Write(
160-
"\n" +
161-
"#if UNITY_EDITOR\n" +
162-
TWO_TABS + "[UnityEditor.InitializeOnLoadMethod]\n" +
163-
"#else\n" +
164-
TWO_TABS + "[UnityEngine.RuntimeInitializeOnLoadMethod]\n" +
165-
"#endif\n" +
166-
TWO_TABS + "public static void Register()\n" +
167-
TWO_TABS + "{\n" +
168-
THREE_TABS + $"MessageRegistry.Register(k_RosMessageName, Deserialize{subtopicParameter});\n" +
169-
TWO_TABS + "}\n"
170-
);
160+
writer.Write(InitializeOnLoad(subtopicParameter));
171161

172162
// Close class
173163
writer.Write(MsgAutoGenUtilities.ONE_TAB + "}\n");
@@ -319,7 +309,7 @@ private void Declaration()
319309
// Check if identifier is a ROS message built-in type
320310
if (builtInTypeMapping.ContainsKey(identifier))
321311
{
322-
throw new MessageParserException(
312+
Debug.LogWarning(
323313
"Invalid field identifier '" + identifier +
324314
"' at " + inFilePath + ":" + lineNum +
325315
". '" + identifier + "' is a ROS message built-in type.");

com.unity.robotics.ros-tcp-connector/Editor/MessageGeneration/MessageTokenizer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ private MessageToken NextTypeIdentifierToken()
287287
}
288288

289289
// Otherwise, consume input until seperator, EOF or '['
290-
while (reader.Peek() != ' ' && reader.Peek() != '[' && !reader.EndOfStream)
290+
while (reader.Peek() != ' ' && reader.Peek() != '[' && reader.Peek() != '\t' && !reader.EndOfStream)
291291
{
292292
if (!Char.IsLetterOrDigit((char)reader.Peek()) && !allowedSpecialCharacterForTypeIdentifier.Contains((char)reader.Peek()))
293293
{

com.unity.robotics.ros-tcp-connector/Editor/MessageGeneration/MsgAutoGenUtilities.cs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,17 @@ public class MsgAutoGenUtilities
100100

101101
public static bool HasHandwrittenMessage(string rosPackageName, string inFileName)
102102
{
103-
if (!rosPackageName.Equals("std_msgs"))
104-
return false;
105-
106-
return inFileName.Equals("Time") || inFileName.Equals("Duration") || inFileName.Equals("Header");
103+
switch (inFileName)
104+
{
105+
case "Header":
106+
case "Time":
107+
case "Duration":
108+
return rosPackageName == "std_msgs";
109+
case "CameraInfo":
110+
return rosPackageName == "sensor_msgs";
111+
default:
112+
return false;
113+
}
107114
}
108115

109116
public static string CapitalizeFirstLetter(string s)
@@ -129,6 +136,7 @@ public static string PascalCase(string s)
129136

130137
public static string ResolvePackageName(string s)
131138
{
139+
s = s.Replace('-', '_');
132140
if (s.Contains("_msgs") || s.Contains("_srvs") || s.Contains("_actions"))
133141
{
134142
return PascalCase(s.Substring(0, s.LastIndexOf('_')));
@@ -139,5 +147,19 @@ public static string ResolvePackageName(string s)
139147
}
140148
return CapitalizeFirstLetter(s);
141149
}
150+
151+
public static string InitializeOnLoad(string subtopicArgument = "")
152+
{
153+
return "\n" +
154+
"#if UNITY_EDITOR\n" +
155+
TWO_TABS + "[UnityEditor.InitializeOnLoadMethod]\n" +
156+
"#else\n" +
157+
TWO_TABS + "[UnityEngine.RuntimeInitializeOnLoadMethod]\n" +
158+
"#endif\n" +
159+
TWO_TABS + "public static void Register()\n" +
160+
TWO_TABS + "{\n" +
161+
THREE_TABS + $"MessageRegistry.Register(k_RosMessageName, Deserialize{subtopicArgument});\n" +
162+
TWO_TABS + "}\n";
163+
}
142164
}
143165
}

0 commit comments

Comments
 (0)