-
Notifications
You must be signed in to change notification settings - Fork 507
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 test_message_conversion.py #645
Fix test_message_conversion.py #645
Conversation
a78ef21
to
d13769b
Compare
0faf609
to
b2d8d8d
Compare
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! needs rebase before merging
@amacneil Thank you! How do we merge this?
|
for msg in [{"data": data_value}]: | ||
inst = ros_loader.get_message_instance(msgtype) | ||
c.populate_instance(msg, inst) | ||
self.assertEqual(inst.data, bytes([data_value])) |
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'm not sure this is right. std_msgs/Byte holds a single byte, why should it be a bytes
instance?
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'm not so familiar with this, but as far as I know, it's because rclpy
defines so.
https://design.ros2.org/articles/generated_interfaces_python.html
In [1]: from example_interfaces.msg import Byte
In [2]: Byte().data
Out[2]: b'\x00'
In [3]: Byte().data == bytes([0])
Out[3]: True
In [4]: Byte().data == 0
Out[4]: False
As for how to merge this PR: I think it's fine to merge this PR first (once approved), just disable the failing tests using unittest.skip. Then the skip can be removed in #646. |
msg = {"sec": 3, "nanosec": 5} | ||
self.do_test(msg, "builtin_interfaces/Time") | ||
|
||
msg = {"times": [{"secs": 3, "nsecs": 5}, {"secs": 2, "nsecs": 7}]} | ||
msg = {"times": [{"sec": 3, "nanosec": 5}, {"sec": 2, "nanosec": 7}]} |
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 this mean the JSON format of time
/duration
fields is changing for ROS 2? Will clients need to update their code? I think we need to maintain backward compatibility with the secs
/nsecs
format if that is the format existing JSON clients are expecting.
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 this mean the JSON format of time/duration fields is changing for ROS 2?
As a test spec, yes.
As an application spec, no. It's already changed.
To test this, please run the following commands.
Case 1. Working
// Terminal 1
$ ros2 run rosbridge_server rosbridge_websocket
// normal outputs
// Terminal 2
$ curl -sL https://github.com/tier4/rosbridge_suite/raw/add-test-scripts/test_scripts/time.py | python
publish: {'sec': 1, 'nanosec': 2}
subscribe: {'sec': 1, 'nanosec': 2}
publish: {'sec': 1, 'nanosec': 2}
subscribe: {'sec': 1, 'nanosec': 2}
Case 2. Not working
// Terminal 1
$ ros2 run rosbridge_server rosbridge_websocket
[ERROR 1634483257.554689935] [rosbridge_websocket]: [Client 4] [id: publish:/time:3] publish: 'Time' object has no attribute 'secs'
[ERROR 1634483258.559444873] [rosbridge_websocket]: [Client 4] [id: publish:/time:4] publish: 'Time' object has no attribute 'secs'
// Terminal 2
$ curl -sL https://github.com/tier4/rosbridge_suite/raw/add-test-scripts/test_scripts/time_old_format.py | python
publish: {'secs': 1, 'nsecs': 2}
publish: {'secs': 1, 'nsecs': 2}
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.
Even though it's already changed, we could still choose to change it back (and we should bump the major version of the package if it's not backward compatible). Do you think users of the library will be confused by the difference in behavior between ROS 1/2? If someone upgrades from ROS 1 to ROS 2 their websocket client will start receiving values. Should we change it back to secs/nsecs
or at least change the publish side to accept both forms?
cc @defunctzombie @amacneil for thoughts.
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.
@jtbandes I'll leave the decision to the maintainers, but my personal (and selfish) thought is, since our company has completely moved to ROS2, either one is fine.
Do you think users of the library will be confused by the difference in behavior between ROS 1/2?
Yes, I remember we had to fix some web application code for ROS2, but it wasn't so big confusion.
But anyway, I think clients should change the data format when they receive the data because rosbridge
outputs the same data for each client. Is this correct or does rosbridge
change output data depending on the client ROS version?
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'm not following the comments in this thread. Is the statement that rosbridge currently outputs sec/nsec
and this is confusing for ros2 users and we should change to sec/nanosec? Or that rosbridge outputs sec/nanosec
and this is confusing for ros1 users?
What is the specific change (if any) being requested of the api/protocol?
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.
Currently it outputs secs/nsecs for ROS 1 and sec/nanosec for ROS 2. This PR just changes the test.
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.
If this is just changing a test then we should merge the PR to have tests and tackle API changes in separate discussions.
Can you please rebase on #686 ? These newly added tests were not running in CI, and they might need more changes to be able to pass CI. |
Hmm, It seems the test is running at least in this PR. @jtbandes Do you know why? But anyway, I'll rebase related PRs later. |
Hm, maybe only some tests are affected, not sure why. I just merged that PR so you should be able to rebase on ros2 now. Thanks for your patience! |
f8a543a
to
f914541
Compare
Rebased. The tests won't pass because there is no logic change. |
Yep, that makes sense. Can you use |
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>
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>
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
@jtbandes Yes it's possible, but before that, we have to agree with the test specifications around Should I add tests for both |
I think it's fine to keep |
Signed-off-by: Kenji Miyake <kenji.miyake@tier4.jp>
f914541
to
be45b8e
Compare
I see. Just trying to understand the current behavior... is rosbridge currently accepting both secs/nsecs and sec/nanosec for any time/duration fields in On the subscriber side, is it right that rosbridge will always send sec/nanosec to subscribers (since the initial ros2 conversion)? Anyway, I think these issues can be addressed in #646. If you don't mind, I can merge this PR now. By the way, if you would like to discuss any of these issues/PRs in a faster communication channel, we have a Slack workspace at http://foxglove.dev/slack with a #ros2 channel. Feel free to ping us anytime in there 🙂 I'm also a member of the ros discord server. |
@jtbandes Yes, I'm okay if maintainers are okay with test specs. (Oh, merged while I'm writing, thank you!)
I'm sorry, I'm not familiar with this behavior. 🥲 |
Me neither 😆 But I thought maybe that's what this code is trying to do (convert a JSON message from the ws client into a ROS time/duration msg). |
Public Changes
None
Description
Fixed test_message_conversion.py.
Since it has some bugs in the application code, I'll fix them in another PR #646.
Related: #643