# Mapping between rospy and rclpy

**URL:** https://discourse.openrobotics.org/t/mapping-between-rospy-and-rclpy/5737
**Category:** ROS General
**Tags:** ros2
**Created:** [August 15, 2018, 1:15am UTC](https://discourse.openrobotics.org/t/mapping-between-rospy-and-rclpy/5737 "2018-08-15T01:15:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![hemantku](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/hemantku/32/2307_2.png) [@hemantku](https://discourse.openrobotics.org/u/hemantku)
#### Post date: [August 15, 2018, 1:15am UTC](https://discourse.openrobotics.org/t/mapping-between-rospy-and-rclpy/5737/1 "2018-08-15T01:15:41Z")

</div>

I am attempting to migrate join\_state\_publisher package from ROS 1 to ROS 2 and trying to find equivalent API. For example

1. rospy has Exceptions like ROSInterruptException. I do not find an equivalent exception to use from rclpy. Is there some other package which defines these?
2. rospy.get\_param is missing in rclpy. Will this be covered as part of this - [Implement Time Features in rclpy · Issue #186 · ros2/rclpy · GitHub](https://github.com/ros2/rclpy/issues/186)? Also, what is the alternative for this till then? Can I use the example in [rclpy/rclpy/test/test\_node.py at 0db8fc763ead2cf3184f8c876f1be1bdd85944d8 · ros2/rclpy · GitHub](https://github.com/ros2/rclpy/blob/0db8fc763ead2cf3184f8c876f1be1bdd85944d8/rclpy/test/test_node.py#L77) ?
3. rospy.Rate() is missing which I do guess will covered here: [Implement Time Features in rclpy · Issue #186 · ros2/rclpy · GitHub](https://github.com/ros2/rclpy/issues/186).. Any alternative?
4. Does rospy.is\_shutdown seems to have been removed in rclp. How do we check for shutdown? Can we use rclpy.try\_shutdown()?

---

<div class="post-metadata">

### Author: ![wjwwood](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/wjwwood/32/13715_2.png) [@wjwwood](https://discourse.openrobotics.org/u/wjwwood)
#### Post date: [August 15, 2018, 1:40am UTC](https://discourse.openrobotics.org/t/mapping-between-rospy-and-rclpy/5737/2 "2018-08-15T01:40:49Z")

</div>

> [@hemantku](#):
>
> - rospy has Exceptions like ROSInterruptException. I do not find an equivalent exception to use from rclpy. Is there some other package which defines these?

If it’s not defined in `rclpy` then it’s probably not defined anywhere. I don’t know off the top of my head where this was being used in `rospy`, but it may make sense to have it in `rclpy` and it simply hasn’t been ported yet. It might be connected to the init/shutdown or rate features that are still missing.

> [@hemantku](#):
>
> - rospy.get\_param is missing in rclpy. Will this be covered as part of this - [Implement Time Features in rclpy · Issue #186 · ros2/rclpy · GitHub](https://github.com/ros2/rclpy/issues/186)? Also, what is the alternative for this till then? Can I use the example in [rclpy/rclpy/test/test\_node.py at 0db8fc763ead2cf3184f8c876f1be1bdd85944d8 · ros2/rclpy · GitHub](https://github.com/ros2/rclpy/blob/0db8fc763ead2cf3184f8c876f1be1bdd85944d8/rclpy/test/test_node.py#L77) ?

It is missing, but those issues I don’t think are the best connection to that feature. I’d say:

[https://github.com/ros2/rclpy/issues/202](https://github.com/ros2/rclpy/issues/202)

Which is being worked on now:

[https://github.com/ros2/rclpy/pull/214](https://github.com/ros2/rclpy/pull/214)

> [@hemantku](#):
>
> rospy.Rate() is missing which I do guess will covered here: [https://github.com/ros2/rclpy/issues/186…](https://github.com/ros2/rclpy/issues/186%E2%80%A6) Any alternative?

Yes, that issue specifically mentions `Timer` and `Rate` concepts, which are dependent on finishing the “ROS Time” implementation in `rclpy`.

> [@hemantku](#):
>
> Does rospy.is\_shutdown seems to have been removed in rclp. How do we check for shutdown? Can we use rclpy.try\_shutdown()?

It’s not been explicitly removed as far as I know, it just hasn’t been implemented yet. You could use `try_shutdown()` to test, but if you only wanted to test you’d be out of luck since the side-effect would be a shutdown in many cases. This feature is captured in this issue (in my opinion):

[https://github.com/ros2/rclpy/issues/190](https://github.com/ros2/rclpy/issues/190)

Which it seems you’ve already found and offered to help (thanks!).

---

<div class="post-metadata">

### Author: ![hemantku](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/hemantku/32/2307_2.png) [@hemantku](https://discourse.openrobotics.org/u/hemantku)
#### Post date: [August 15, 2018, 6:25pm UTC](https://discourse.openrobotics.org/t/mapping-between-rospy-and-rclpy/5737/3 "2018-08-15T18:25:16Z")

</div>

Thanks for answers @wjwwood. I created issue for missing exceptions here: [test multiple rmw implementations for talker/listener test · Issue #22 · ros2/rclpy · GitHub](https://github.com/ros2/rclpy/issues/22).

I can get that covered as part of [rclpy should provide a method to check if initialized · Issue #190 · ros2/rclpy · GitHub](https://github.com/ros2/rclpy/issues/190)
