Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ros node is shutdown after keyboard interrupt #99

Open
tomerarnon opened this issue Mar 24, 2023 · 0 comments
Open

ros node is shutdown after keyboard interrupt #99

tomerarnon opened this issue Mar 24, 2023 · 0 comments

Comments

@tomerarnon
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant