PyCall.jl icon indicating copy to clipboard operation
PyCall.jl copied to clipboard

How can I use rospy through PyCall directly?

Open wly2014 opened this issue 2 years ago • 1 comments

The code I have can only be able to run the callback once.

using PyCall

function solve_callback(data)
    println("solve_callback.")
end

rospy = pyimport("rospy")
msg = pyimport("geometry_msgs.msg")
WrenchStamped = msg.WrenchStamped

rospy.init_node("solver_interface_sub", disable_signals = false)
println("init_node solver_interface_sub.")

solver_sub = rospy.Subscriber("/solver_input", WrenchStamped, solve_callback, queue_size=1)

if rospy.is_shutdown()
    @warn "rospy.is_shutdown()"
end

rospy.spin()

println("stop.")

I am aware that RobotOS.jl is one method to accomplish this, but I want to know how can I call rospy directly using PyCall.

Thank you very much.

wly2014 avatar Jan 28 '24 07:01 wly2014

I've tried to get rospy callbacks to work too. It doesn't even run the callback once. It seems to run up until the first function call (such as a print statement) within the callback and then hangs. The rest of the code in the function gets ignored. No luck finding a solution.

ngharrison avatar Apr 10 '24 06:04 ngharrison