diff --git a/src/gentypes.jl b/src/gentypes.jl index 0f2a717..9bb551a 100644 --- a/src/gentypes.jl +++ b/src/gentypes.jl @@ -2,6 +2,7 @@ using Compat import Compat: String, Symbol +using PyCall export @rosimport, rostypegen, rostypereset @@ -633,6 +634,11 @@ function _get_rospy_class(typ::DataType) rospycls end +#Overwrite PyCall's default constructor to call the `convert` functions generated here +PyCall.PyObject(m::AbstractMsg) = convert(PyCall.PyObject, m) +PyCall.PyObject(s::AbstractSrv) = convert(PyCall.PyObject, s) +PyCall.PyObject(s::AbstractService) = convert(PyCall.PyObject, s) + _jl_safe_name(name::AbstractString, suffix) = _nameconflicts(name) ? string(name,suffix) : name diff --git a/test/typegeneration.jl b/test/typegeneration.jl index cbdf2b1..cc4fa49 100644 --- a/test/typegeneration.jl +++ b/test/typegeneration.jl @@ -48,6 +48,10 @@ pypose = convert(PyObject, posestamp) @test pypose[:pose][:position][:x] == 1. @test pypose[:pose][:position][:y] == 2. @test pypose[:pose][:position][:z] == 3. +pypose2 = PyObject(posestamp) +@test pypose2[:pose][:position][:x] == 1. +@test pypose2[:pose][:position][:y] == 2. +@test pypose2[:pose][:position][:z] == 3. pose2 = convert(geometry_msgs.msg.PoseStamped, pypose) @test pose2.pose.position.x == 1. @test pose2.pose.position.y == 2.