214
214
function _importdeps! (mod:: ROSModule , deps:: Vector )
215
215
global _rospy_imports
216
216
for d in deps
217
- if ! (d in keys (_ros_builtin_types))
217
+ # We don't care about array types when doing dependency resolution
218
+ dclean = _check_array_type (d)[1 ]
219
+ if ! (dclean in keys (_ros_builtin_types))
218
220
@debug (" Dependency: " , d)
219
- pkgname, typename = _splittypestr (d )
221
+ pkgname, typename = _splittypestr (dclean )
220
222
221
223
@debug_addindent
222
224
# Create a new ROSPackage if needed
@@ -230,9 +232,7 @@ function _importdeps!(mod::ROSModule, deps::Vector)
230
232
# pushing to a set does not create duplicates
231
233
push! (mod. deps, depmod. name)
232
234
233
- # Don't want to include the brackets in the string if present
234
- typeclean = _check_array_type (typename)[1 ]
235
- addtype! (depmod, typeclean)
235
+ addtype! (depmod, typename)
236
236
@debug_subindent
237
237
end
238
238
end
347
347
348
348
# The exported names for each module
349
349
function _exportexpr (mod:: ROSMsgModule )
350
- exports = [symbol (m) for m in mod. members]
351
- Expr (:export , exports... )
350
+ exportexpr = Expr (:export )
351
+ for m in mod. members
352
+ push! (exportexpr. args, _nameconflicts (m) ?
353
+ symbol (string (m," Msg" )) :
354
+ symbol (m))
355
+ end
356
+ exportexpr
352
357
end
353
358
function _exportexpr (mod:: ROSSrvModule )
354
359
exportexpr = Expr (:export )
@@ -371,6 +376,11 @@ function buildtype(mod::ROSMsgModule, typename::String)
371
376
memtypes = pyobj[:_slot_types ]
372
377
members = collect (zip (memnames, memtypes))
373
378
379
+ # Some ROS message names conflict with Julia built-in types
380
+ # Append 'Msg' to the type name to resolve
381
+ if _nameconflicts (typename)
382
+ fulltypestr = fulltypestr * " Msg"
383
+ end
374
384
typecode (fulltypestr, :MsgT , members)
375
385
end
376
386
@@ -610,6 +620,17 @@ function _get_rospy_class(typ::DataType)
610
620
rospycls
611
621
end
612
622
623
+ # Check if the type name conflicts with a Julia builtin. Currently this is only
624
+ # some of the messages from the std_msgs.msg package
625
+ function _nameconflicts (typename:: String )
626
+ try
627
+ eval (Base, symbol (typename))
628
+ true
629
+ catch
630
+ false
631
+ end
632
+ end
633
+
613
634
# Get a default value for any builtin ROS type
614
635
_typedefault {T<:Real} (:: Type{T} ) = zero (T)
615
636
_typedefault (:: Type{ASCIIString} ) = " "
0 commit comments