Skip to content

Commit bf195c8

Browse files
authored
Merge pull request #38 from RobotecAI/foxy_fixes_for_custom_messages
Foxy fixes
2 parents 90f009a + bc96e90 commit bf195c8

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

deploy_unity_plugins.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ if (Test-Path -Path $pluginDir) {
2626
Write-Host "Copying libraries to: '$pluginDir\Windows\x86_64\' ..."
2727
(Copy-Item -verbose -Path $scriptPath\install\bin\*.dll -Destination ${pluginDir}\Windows\x86_64\ 4>&1).Message
2828
(Copy-Item -verbose -Path $scriptPath\install\standalone\*.dll -Destination ${pluginDir}\Windows\x86_64\ 4>&1).Message
29+
(Copy-Item -verbose -Path $scriptPath\install\resources\*.dll -Destination ${pluginDir}\Windows\x86_64\ 4>&1).Message
2930
Write-Host "Libraries copied to '${pluginDir}\Windows\x86_64\'" -ForegroundColor Green
3031
} else {
3132
Write-Host "Plugins directory: '$pluginDir' doesn't exist. Please create it first manually." -ForegroundColor Red

deploy_unity_plugins.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ fi
1414
pluginDir=$1
1515

1616
mkdir -p ${pluginDir}/Linux/x86_64/
17-
cp --verbose $SCRIPTPATH/install/lib/dotnet/* ${pluginDir}
18-
cp --verbose $SCRIPTPATH/install/standalone/* ${pluginDir}/Linux/x86_64/
19-
cp --verbose $SCRIPTPATH/install/lib/*.so ${pluginDir}/Linux/x86_64/
17+
cp $SCRIPTPATH/install/lib/dotnet/* ${pluginDir}
18+
cp $SCRIPTPATH/install/standalone/* ${pluginDir}/Linux/x86_64/
19+
cp $SCRIPTPATH/install/lib/*.so ${pluginDir}/Linux/x86_64/
20+
cp $SCRIPTPATH/install/resources/*.so ${pluginDir}/Linux/x86_64/

src/Ros2ForUnity/Scripts/ROS2ForUnity.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ private void SetEnvPathVariable()
136136
/// Check if the ros version is supported, only applicable to non-standalone plugin versions
137137
/// (i. e. without ros2 libraries included in the plugin).
138138
/// </summary>
139-
private void CheckROSVersionSourced()
139+
private string CheckROSVersionSourced()
140140
{
141141
string currentVersion = Environment.GetEnvironmentVariable("ROS_DISTRO");
142142
List<string> supportedVersions = new List<string>() { "foxy", "galactic" };
@@ -169,6 +169,7 @@ private void CheckROSVersionSourced()
169169
#endif
170170
}
171171
Debug.Log("Running with a supported ROS 2 version: " + currentVersion);
172+
return currentVersion;
172173
}
173174

174175
private void RegisterCtrlCHandler()
@@ -200,9 +201,14 @@ internal ROS2ForUnity()
200201
} else {
201202
// Linux version needs to have ros2 sourced, which is checked here. It also loads plugins by absolute path
202203
// since LD_LIBRARY_PATH cannot be set dynamically within the process for dlopen() which is used under the hood.
203-
// Since libraries are built with -rpath=".", dependencies will be correcly located within plugins directory
204-
CheckROSVersionSourced();
204+
// Since libraries are built with -rpath=".", dependencies will be correcly located within plugins directory.
205+
// For foxy, it is also necessary to use modified version of librcpputils to resolve custom msgs packages.
206+
string currentRosVersion = CheckROSVersionSourced();
205207
ROS2.GlobalVariables.absolutePath = GetPluginPath() + "/";
208+
if (currentRosVersion == "foxy") {
209+
ROS2.GlobalVariables.preloadLibrary = true;
210+
ROS2.GlobalVariables.preloadLibraryName = "librcpputils.so";
211+
}
206212
}
207213
ConnectLoggers();
208214
Ros2cs.Init();

0 commit comments

Comments
 (0)