@@ -136,7 +136,7 @@ private void SetEnvPathVariable()
136
136
/// Check if the ros version is supported, only applicable to non-standalone plugin versions
137
137
/// (i. e. without ros2 libraries included in the plugin).
138
138
/// </summary>
139
- private void CheckROSVersionSourced ( )
139
+ private string CheckROSVersionSourced ( )
140
140
{
141
141
string currentVersion = Environment . GetEnvironmentVariable ( "ROS_DISTRO" ) ;
142
142
List < string > supportedVersions = new List < string > ( ) { "foxy" , "galactic" } ;
@@ -169,6 +169,7 @@ private void CheckROSVersionSourced()
169
169
#endif
170
170
}
171
171
Debug . Log ( "Running with a supported ROS 2 version: " + currentVersion ) ;
172
+ return currentVersion ;
172
173
}
173
174
174
175
private void RegisterCtrlCHandler ( )
@@ -200,9 +201,14 @@ internal ROS2ForUnity()
200
201
} else {
201
202
// Linux version needs to have ros2 sourced, which is checked here. It also loads plugins by absolute path
202
203
// 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 ( ) ;
205
207
ROS2 . GlobalVariables . absolutePath = GetPluginPath ( ) + "/" ;
208
+ if ( currentRosVersion == "foxy" ) {
209
+ ROS2 . GlobalVariables . preloadLibrary = true ;
210
+ ROS2 . GlobalVariables . preloadLibraryName = "librcpputils.so" ;
211
+ }
206
212
}
207
213
ConnectLoggers ( ) ;
208
214
Ros2cs . Init ( ) ;
0 commit comments