Skip to content

Commit ddcf639

Browse files
committed
Fixed some scripts, added missing build.ps1, fixed asset folder name
1 parent d868ebc commit ddcf639

File tree

8 files changed

+75
-14
lines changed

8 files changed

+75
-14
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The asset can be prepared in two flavors:
2626

2727
#### Platform considerations
2828

29-
Running the Editor or App using this Asset on Ubuntu requires a start script that populates the LD_LIBRARY_PATH. This is due to dynamic plugin loading mechanism used in the ros2cs library.
29+
Running the Editor or App using this Asset on Ubuntu requires a start script that populates the `LD_LIBRARY_PATH`. This is due to dynamic plugin loading mechanism used in the ros2cs library.
3030
On Windows, no script is necessary and both Editor and App can be ran the usual way (e.g. with a click or cmd line).
3131

3232
### Releases
@@ -86,13 +86,15 @@ The project will pull `ros2cs` into the workspace, which also functions independ
8686
8787
> There is a bug with hardcoded include exports in some **ros2 galactic** packages on **Windows**. Easiest workaround is to create a `C:\ci\ws\install\include` directory in your system. More about this bug and proposed workarounds: [github issue](https://github.com/ros2/rclcpp/issues/1688#issuecomment-858467147).
8888
89+
> Sometimes it is required to set NuGet package feed to nuget.org: `dotnet nuget add source --name nuget.org https://api.nuget.org/v3/index.json` in order to resolve some missing packages for `ros2cs` project.
90+
8991
#### Build instructions
9092

9193
* Clone this project.
9294
* If you wish to include custom messages in your build, make sure to put them into `ros2_for_unity_custom_messages.repos` file. You can change this file in your fork or change `custom_messages.repos` in the ros2cs repository fork, it will work either way as the scripts will pull both sources.
9395
As an alternative, you can also add your custom messages package directly by copying it to `src/ros2cs/custom_messages` folder after the next step. Any message package in the build tree will be subjected to `.cs` file generator during the build.
9496
* You need to source your ROS2 installation (e.g. `source /opt/ros/foxy/setup.bash` on Ubuntu or `C:\dev\ros2_foxy\local_setup.ps1` on Windows) before you proceed, for each new open terminal. On Ubuntu, you can also include this command in your `~/.bashrc` file.
95-
* Run 'pull_repositories.sh'. This will pull `ros2cs` as well as your custom messages.
97+
* Run `pull_repositories.sh`. This will pull `ros2cs` as well as your custom messages.
9698
* Run `build.sh` (Ubuntu) or `build.ps1` (Windows) script.
9799
* You can build tests by adding `--with-tests` argument to `build` command.
98100
* It invokes `colcon_build` with `--merge-install` argument to simplify libraries installation.

build.ps1

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
2+
3+
function Print-Help {
4+
"
5+
Usage:
6+
build.ps1 [--with-tests]
7+
8+
Options:
9+
--with-tests - build with tests.
10+
"
11+
}
12+
13+
$tests=0
14+
$msg="Build started."
15+
if ($args[0] -eq "--with-tests") {
16+
$tests=1
17+
$msg+=" (with tests)"
18+
} elseif ($args[0] -eq "--help" -Or $args[0] -eq "-h") {
19+
Print-Help
20+
exit
21+
}
22+
23+
$tests_info=0
24+
$plugin_path=Join-Path -Path $scriptPath -ChildPath "\src\Ros2ForUnity\Plugins\"
25+
26+
Write-Host $msg -ForegroundColor Green
27+
colcon build --merge-install --event-handlers console_direct+ --cmake-args -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=$tests
28+
29+
Write-Host "Deploying build to $plugin_path" -ForegroundColor Green
30+
& "$scriptPath\deploy_unity_plugins.ps1" $plugin_path

build.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/bin/bash
2+
SCRIPT=$(readlink -f $0)
3+
SCRIPTPATH=`dirname $SCRIPT`
24

35
if [ -z "${ROS_DISTRO}" ]; then
46
echo "Source your ros2 distro first (Foxy and Galactic are supported)"
@@ -21,4 +23,4 @@ fi
2123

2224
echo $MSG
2325
#TODO - call ros2cs ./build.sh instead, but with this workspace directory (parametrize the script)
24-
colcon build --merge-install --event-handlers console_direct+ --cmake-args -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=$TESTS && ./deploy_unity_plugins.sh src/Ros2ForUnity/Plugins/
26+
colcon build --merge-install --event-handlers console_direct+ --cmake-args -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=$TESTS && $SCRIPTPATH/deploy_unity_plugins.sh $SCRIPTPATH/src/Ros2ForUnity/Plugins/

create_unity_asset.ps1

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.SYNOPSIS
44
Creates a 'unitypackage' from an input asset.
55
.DESCRIPTION
6-
This script screates a temporary Unity project in "%USERPROFILE%\AppData\Local\Temp" directory, copy input asset and makes an unity package out of it.
6+
This script screates a temporary Unity project in "%USERPROFILE%\AppData\Local\Temp" directory, copy input asset and makes an unity package out of it. Valid Unity license is required.
77
.PARAMETER unity_path
88
Unity editor executable path
99
.PARAMETER input_asset
@@ -15,14 +15,23 @@
1515
#>
1616
Param (
1717
[Parameter(Mandatory=$true)][string]$unity_path,
18-
[Parameter(Mandatory=$true)][string]$input_asset,
19-
[Parameter(Mandatory=$true)][string]$package_name,
18+
[Parameter(Mandatory=$false)][string]$input_asset,
19+
[Parameter(Mandatory=$false)][string]$package_name="Ros2ForUnity",
2020
[Parameter(Mandatory=$true)][string]$output_dir
2121
)
2222

2323
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
2424
$temp_dir = $Env:TEMP
2525

26+
if(-Not $PSBoundParameters.ContainsKey('input_asset')) {
27+
$input_asset= Join-Path -Path $scriptPath -ChildPath "\src\Ros2ForUnity"
28+
}
29+
30+
if(-Not (Test-Path -Path "$output_dir")) {
31+
Write-Host "Output dir doesn't exist!" -ForegroundColor red
32+
exit 1
33+
}
34+
2635
& "$unity_path" -version | Tee-Object -Variable unity_version | Out-Null
2736

2837
if ($unity_version -match '^[0-9]{4}\.[0-9]*\.[0-9]*[f]?[0-9]*$') {
@@ -49,7 +58,7 @@ Copy-Item -Path "$input_asset" -Destination "$tmp_project_path\Assets\$package_n
4958

5059
# Creating asset
5160
Write-Host "Saving unitypackage '$output_dir\$package_name.unitypackage'..."
52-
& "$unity_path" -projectPath "$tmp_project_path" -exportPackage "$package_name" "$output_dir\$package_name.unitypackage" -batchmode -quit | Out-Null
61+
& "$unity_path" -projectPath "$tmp_project_path" -exportPackage "Assets\$package_name" "$output_dir\$package_name.unitypackage" -batchmode -quit | Out-Null
5362

5463
# Cleaning up
5564
Write-Host "Cleaning up temporary project..."

create_unity_asset.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ SCRIPT=$(readlink -f $0)
44
SCRIPTPATH=`dirname $SCRIPT`
55

66
display_usage() {
7-
echo "This script creates a temporary Unity project in '/tmp' directory, copy input asset and makes an unity package out of it."
7+
echo "This script creates a temporary Unity project in '/tmp' directory, copy input asset and makes an unity package out of it. Valid Unity license is required."
88
echo ""
99
echo "Usage:"
10-
echo "create_unity_asset.sh -u <UNITY_PATH> -i <INPUT_ASSET> -p <PACKAGE_NAME> -o <OUTPUT_DIR>"
10+
echo "create_unity_asset.sh -u <UNITY_PATH> -i [INPUT_ASSET] -p [PACKAGE_NAME] -o <OUTPUT_DIR>"
1111
echo ""
1212
echo "UNITY_PATH - Unity editor executable path"
13-
echo "INPUT_ASSET - input asset to pack into unity package"
14-
echo "PACKAGE_NAME - unity package name"
13+
echo "INPUT_ASSET - input asset to pack into unity package, default = './src/Ros2ForUnity'"
14+
echo "PACKAGE_NAME - unity package name, default = 'Ros2ForUnity'"
1515
echo "OUTPUT_DIR - output file directory"
1616
}
1717

pull_repositories.ps1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
2+
3+
if (([string]::IsNullOrEmpty($Env:ROS_DISTRO)))
4+
{
5+
Write-Host "Can't detect ROS2 version. Source your ros2 distro first. Foxy and Galactic are supported." -ForegroundColor Red
6+
exit
7+
}
8+
9+
$ros2cs_repos = Join-Path -Path $scriptPath -ChildPath "\ros2cs.repos"
10+
$custom_repos = Join-Path -Path $scriptPath -ChildPath "\ros2_for_unity_custom_messages.repos"
11+
vcs import --input $ros2cs_repos
12+
vcs import --input $custom_repos
13+
14+
& "$scriptPath/src/ros2cs/get_repos.ps1"

pull_repositories.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
#!/bin/bash
22

3+
SCRIPT=$(readlink -f $0)
4+
SCRIPTPATH=`dirname $SCRIPT`
5+
36
if [ -z "${ROS_DISTRO}" ]; then
47
echo "Can't detect ROS2 version. Source your ros2 distro first. Foxy and Galactic are supported"
58
exit 1
69
fi
710

811
vcs import < "ros2cs.repos"
912
vcs import < "ros2_for_unity_custom_messages.repos"
10-
cd src/ros2cs
11-
./get_repos.sh --get-custom-messages
13+
cd "$SCRIPTPATH/src/ros2cs"
14+
./get_repos.sh
15+
cd -

src/Ros2ForUnity/Scripts/ROS2ForUnity.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace ROS2
2727
internal class ROS2ForUnity
2828
{
2929
private static bool isInitialized = false;
30-
private static string ros2ForUnityAssetFolderName = "ROS2";
30+
private static string ros2ForUnityAssetFolderName = "Ros2ForUnity";
3131

3232
enum Platform
3333
{

0 commit comments

Comments
 (0)