-
Notifications
You must be signed in to change notification settings - Fork 526
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
Fix time behavior #691
Fix time behavior #691
Conversation
@jtbandes Should I change the code to support the old format? My concern is that the output from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks and sorry for the delay. From your examples in the description, it looks like the main change is to fix the handling of time[]
arrays. Do you think it would be better to leave the other features as-is and focus on only fixing time arrays?
if rostype == "time" and msg == "now": | ||
return ROSClock().now().to_msg() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this is removing a feature where the string "now"
will be translated to the current time. I guess this feature was not documented, so it's ok to remove? Is that what you're thinking too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I didn't care about that, sorry. Will confirm the reason why this was added!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Introduced here: 8e3eb96
# Copy across the fields, try ROS1 and ROS2 fieldnames | ||
for field in ["secs", "nsecs", "sec", "nanosec"]: | ||
try: | ||
if field in msg: | ||
setattr(inst, field, msg[field]) | ||
except TypeError: | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the impact of removing this? Does it mean a client publisher might need to change their code if they are still using the old values?
It's not necessarily bad to remove, but technically we should bump the package version to 2.0.0 if we remove features.
On the other hand, since some of the changes from #692 are significant to clients, I wonder if we should bump the version to 2.x anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it mean a client publisher might need to change their code if they are still using the old values?
Yes, if this part is removed, they should change their code that uses secs/nsecs
.
But I believe they should do so because they must update their subscriber-side code in any case, since rosbridge
outputs Time data in the sec/nanosec
format.
What do you think about it?
It's not necessarily bad to remove, but technically we should bump the package version to 2.0.0 if we remove features.
I see, I agree with you!
On the other hand, since some of the changes from #692 are significant to clients, I wonder if we should bump the version to 2.x anyway.
Yes, I think it's a good idea.
@jtbandes Yes, I agree. I changed this to draft and will update the code at a later date. |
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
afdeafb
to
f53d547
Compare
@jtbandes I'm sorry to be late. Since I've fixed the code, could you review this again, please? FYI, Related PRs/commits: |
return {"sec": inst.sec, "nanosec": inst.nanosec} | ||
except AttributeError: | ||
return {"secs": inst.secs, "nsecs": inst.nsecs} | ||
return {"sec": inst.sec, "nanosec": inst.nanosec} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since rostype
is ROS 2 type, I guess there is no need to use the secs/nsecs
format.
from rcl_interfaces.msg import Parameter | ||
from rclpy.clock import ROSClock | ||
from rclpy.time import Duration, Time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By import rclpy
, I couldn't access to rclpy.time
.
In [1]: import rclpy
In [2]: rclpy.time
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Input In [2], in <module>
----> 1 rclpy.time
AttributeError: module 'rclpy' has no attribute 'time'
if rostype == "builtin_interfaces/Time": | ||
inst = Time().to_msg() | ||
elif rostype == "builtin_interfaces/Duration": | ||
inst = Duration().to_msg() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these ("time/duration") are probably ROS 2 porting mistakes.
setattr(inst, "sec", msg[field]) | ||
for field in ["nanosec", "nsecs"]: | ||
if field in msg: | ||
setattr(inst, "nanosec", msg[field]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since inst
is ROS 2 type, I believe we must force converting to ROS 2 fields here.
rosbridge_library/src/rosbridge_library/internal/message_conversion.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
I'm not sure about the CI failure on Rolling, I'll investigate it separately. It looks like the same failure is happening on the ros2 branch right now. |
…rsion.py Co-authored-by: Jacob Bandes-Storch <jacob@bandes-stor.ch>
Public API Changes
To be discussed.
Description
Split from #646.
Since the current code doesn't pass the tests, I fixed it.
However, this deletes a lot of code, so should be discussed carefully.
How to test
Time Array
Before(upstream/ros2)
After(this PR)
Time (new format of
sec/nanosec
)Before(upstream/ros2)
After(this PR)
Time (old format of
secs/nsecs
)Before(upstream/ros2)
After(this PR)