-
Notifications
You must be signed in to change notification settings - Fork 325
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
Scaled jtc #1191
base: master
Are you sure you want to change the base?
Scaled jtc #1191
Conversation
This adds a scaling factor between 0 and 1 to the JTC so that the trajectory time inside the controller is extended respectively. A value of 0.5 means that trajectory execution will take twice as long as the trajectory states. The scaling factor itself is read from the hardware for now.
Co-authored-by: Christoph Fröhlich <[email protected]>
This avoids writing the explicit conversion by hand Internally that basically does: static_cast<rcl_duration_value_t>(static_cast<long double>(rcl_duration_.nanoseconds) * scale_ld)
…etting of scaling factor Co-authored-by: Manuel M <[email protected]>
That was changed in a previous commit
used The current implementation only works correctly when a position interface is used. When the hardware in fact slows down the robot (as UR does), also velocity interfaces should be scaled correctly, but that't rather an edge case right now.
It is accessed from the RT thread only, anyway.
Thoughts on tests I should implement:
|
joint_trajectory_controller/include/joint_trajectory_controller/joint_trajectory_controller.hpp
Outdated
Show resolved
Hide resolved
joint_trajectory_controller/src/joint_trajectory_controller.cpp
Outdated
Show resolved
Hide resolved
joint_trajectory_controller/src/joint_trajectory_controller.cpp
Outdated
Show resolved
Hide resolved
hi @fmauch Great to see this being worked on again. I added some comments to the code. Regarding the tests:
Makes sense
Isn't this what we patched in: UniversalRobots/Universal_Robots_ROS2_Driver#882. As far as I can tell you also backported this patch. (And I still think the goal time should be also scaled ;) )
Same as above. From heavily using this controller in our system I have the opinion that in most use cases it makes sense (and is what a user would expect) that the goal time should also be scaled. But perhaps I understood your suggestion wrong. |
Thank you for your input. That's why I put my brain dump on that here, so we can discuss this :-) And that's also why I didn't write the documentation on that, yet. I'll wrap my head around this a little more and try to get a better feeling for the current behavior, then come back to this. |
|
||
control_msgs: | ||
type: git | ||
url: https://github.com/fmauch/control_msgs.git | ||
version: scaled_jtc |
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.
control_msgs: | |
type: git | |
url: https://github.com/fmauch/control_msgs.git | |
version: scaled_jtc |
|
||
control_msgs: | ||
type: git | ||
url: https://github.com/fmauch/control_msgs.git | ||
version: scaled_jtc |
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.
control_msgs: | |
type: git | |
url: https://github.com/fmauch/control_msgs.git | |
version: scaled_jtc |
Yes. we sample the trajectory half as fast
Yes we sample the trajectory twice as fast
I would call this paused. I have the feeling this is one of the major usecases of this controller
In case the trajectory is within the (scaled) goal time, it should not fail -> yes. Otherwise the combination of a scaled trajectory + a set goal time tolerance would always fail. |
My concern is mainly this: If you have an application and you execute a trajectory on a robot that does speed scaling. The trajectory gets slowed down due to safety reasons, which means it finishes later than originally requested. This will slow down the whole application and no longer behave as programmed. This might be considered a fault. One could argue that
I just quickly discussed that with a colleague and he also agreed that the behavior that we currently have is probably the expected one. He was also emphasizing the second point. So, I guess, I'll just leave that result standing. As I said, I can definitively live with it. And it's probably even better / more appropriate than "I can live with that". |
Update on the tests:
|
In the last weeks, I compiled ros2_control+controllers on jammy+humble to run the tests. |
This isn't the best explanation, but it's a start.
joint_trajectory_controller/src/joint_trajectory_controller.cpp
Outdated
Show resolved
Hide resolved
return false; | ||
} | ||
|
||
RCLCPP_INFO(get_node()->get_logger(), "New scaling factor will be %f", scaling_factor); |
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 it should be possible to disable this logging message. Some one could have the idea of continuously streaming the scaling factor and this would lead to spamming the log/terminal
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.
We could set that output to an equality check with the current value and add a throttle to it. I think that might be a better approach than adding yet another config 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.
And/Or use a different child logger that can be separately silenced
joint_trajectory_controller/src/joint_trajectory_controller.cpp
Outdated
Show resolved
Hide resolved
So what about the remaining issues especially regarding the tests.
Regarding the tests: @christophfroehlich I am not sure if your suggestion works. I had to explicitly make 1-2 small fixes to some ros2control packages in order to compile ros2control on iron. I would guess that's the same for humble. Is there currently any work in progress in order to get the test working on rolling again? @fmauch I guess given that you can't run any of the tests at the moment you didn't start to implement any of the new tests we discussed before?
Is there already an issue for that ? Do we need to discuss it in an extra issue? |
@firesurfer we have a CI job for that, it currently builds but some tests fail/are flaky |
Precisely. #1206 could be the PR removing this barrier.
Sorry for not answering earlier: See #1192 So, I'll probably start implementing tests tomorrow, either locally rebased ontop of #1206 or on a merged master :-) |
I was sick yesterday, but I'll try my best to squeeze in the tests until the end of the week. |
This pull request is in conflict. Could you fix it @fmauch? |
@fmauch what's the current state ? |
I've spent some time last week (or the week before?) on trying to get the tests running correctly. With that I realized that I basically ran into #697. The JTC currently samples the trajectory at the time given to the update loop. In the scaled version, however we basically sample at Another issue related to that is that we move forward in the trajectory only based on the controller periods combined with the speed scaling (which again is different to the current method which is why I will have to rewrite the tests). We can't really use the time directly, since the time we spent in the trajectory has been scaled, so we have to sum up the periods. This will also get interesting when it comes to trajectory replacement, I think, but I haven't looked into that, yet. So, in summary: Looks like the devil is in the details and this requires still some implementation work to do. While looking at that I did some refactoring work which I haven't pushed yet, as I want to get this together with working basic tests to make sure that the refactoring is actually behaving as expected. As I will be on vacation the next three weeks I don't know how much time I will find for that, though. But I will try. |
I'm planning to split things up a bit into separate PRs to make things with a smaller scope, especially when it comes to adapting the tests.
I'll leave out trajectory replacement for now, since this shall be implemented at a later point, anyway. It might still make sense to merge them all in one PR, but I'll separate at least development like that. |
Ping me if you want me to create a |
This pull request is in conflict. Could you fix it @fmauch? |
Any updates ? :D |
I almost finished the t+dT change on https://github.com/fmauch/ros2_controllers/tree/jtc_tdt. This change still makes tests fail which I have to investigate: fmauch@f453049#diff-8dd2135dc1f4abe6382cc7671ef9ce939196b2d8adf18ac3a77b5c0fddf1a25fR287 |
Update: #1306 implements sampling at With this the next step would be to propagate through the trajectory based on the accumulated periods instead of the absolute time. I expect that this will be quite a lot of work to make all tests comply with that. I will update this PR once #1306 is merged. |
Another update:
Edit: Note: You will need ros-controls/ros2_control#1774 in order to get valid period times. |
This is my take2 on #301.
I plan to finish this until Friday, @firesurfer feel free to poke me :-)
Currently missing
Things that will get changed, as discussed in the latest working group meeting
might get postponed to a later point.ros2 topic pub
will not work with this.