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

ros node is shutdown after keyboard interrupt

Open tomerarnon opened this issue 2 years ago • 0 comments

Running the example from the docs interactively, is_shutdown returns true after a keyboard interrupt.

julia>begin
  using RobotOS
  @rosimport geometry_msgs.msg: Point, Pose2D
  rostypegen()
  using .geometry_msgs.msg
  
  function callback(msg::Pose2D, pub_obj::Publisher{Point})
      pt_msg = Point(msg.x, msg.y, 0.0)
      publish(pub_obj, pt_msg)
  end
  
  function loop(pub_obj)
      loop_rate = Rate(5.0)
      while ! is_shutdown()
          npt = Point(rand(), rand(), 0.0)
          publish(pub_obj, npt)
          rossleep(loop_rate)
      end
  end

  function main()
      init_node("rosjl_example")
      pub = Publisher{Point}("pts", queue_size=10)
      sub = Subscriber{Pose2D}("pose", callback, (pub,), queue_size=10)
      loop(pub)
  end
end

julia> main()
^C
julia> is_shutdown()
true

When debugging my own ROS project, which has a similar while !is_shutdown() structure, I want to be able to continue running pieces of the code after interrupting the loop. Is there a way to do that? E.g. handling the interrupt in some specific way, structuring the loop differently, etc.

tomerarnon avatar Mar 24 '23 22:03 tomerarnon