Skip to content

ros node is shutdown after keyboard interrupt  #99

@tomerarnon

Description

@tomerarnon

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions