-
Notifications
You must be signed in to change notification settings - Fork 333
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. |
Another update:
Edit: Note: You will need ros-controls/ros2_control#1774 in order to get valid period times. |
This should be a state that could be started to get reviewed. There are a couple of things left that I'm not 100% happy, but they don't necessarily have to be covered in this PR in my opinion:
|
|
Co-authored-by: Felix Exner (fexner) <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1191 +/- ##
==========================================
- Coverage 83.56% 83.37% -0.19%
==========================================
Files 122 122
Lines 10992 11076 +84
Branches 937 951 +14
==========================================
+ Hits 9185 9235 +50
- Misses 1493 1520 +27
- Partials 314 321 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
|
facepalm I thought I changed that back some time ago already. |
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.
Some first remarks
- Add a short description to the release_notes please.
- Add the new ROS interfaces here
joint_trajectory_controller/src/joint_trajectory_controller_parameters.yaml
Outdated
Show resolved
Hide resolved
joint_trajectory_controller/src/joint_trajectory_controller_parameters.yaml
Show resolved
Hide resolved
@@ -1580,6 +1683,32 @@ void JointTrajectoryController::resize_joint_trajectory_point_command( | |||
} | |||
} | |||
|
|||
bool JointTrajectoryController::set_scaling_factor(const double 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.
This method has no test coverage
@@ -902,6 +967,34 @@ controller_interface::CallbackReturn JointTrajectoryController::on_activate( | |||
// parse remaining parameters | |||
default_tolerances_ = get_segment_tolerances(logger, params_); | |||
|
|||
// Set scaling interfaces |
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.
This part has no test coverage
============= | ||
|
||
The ``joint_trajectory_controller`` (JTC) supports dynamically scaling its trajectory execution speed. | ||
That means, when specifying a scaling factor :math:`{f}` of less than 1, execution will proceed only |
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.
Is it possible to specify a value > 1 for simulation purposes ? We are using this quite a lot in our setup.
What would the maximum rate be? I saw the limit with the old implementation at 2.5
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.
Yes, it can be greater than 1. I haven't investigated a limit, though.
|
||
.. note:: | ||
The current implementation only works for position-based interfaces. | ||
|
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.
Perhaps I am too tired after the ROScon. But could it be that it doesn't become 100% clear how to select a specfic mode?
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 do you mean by "how to select a specific mode"? The current implementation will simply not do speed scaling when any other interface than position is configured for the controller.
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 I just read the documentation I would think:
a) There are multiple modes I can choose from with the hint that on-robot scaling probably produces the better results
b) If there are multiple modes I would think: Ok somehow I have to tell the JTC to select which mode.
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
"of speed scaling, please only use a position interface when configuring this controller."); | ||
scaling_factor_ = 1.0; | ||
} | ||
if (!params_.speed_scaling_state_interface_name.empty()) |
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 make sense to allow changing the scaling_factor via the topic and from the teach panel ?
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.
It should be either topic or hardware, at least that was my intention. I'll revisit that to verify that that;s what I've implemented.
Edit: It's in the JointTrajectoryController::set_scaling_factor
function. If speed scaling is set with a speed scaling state interface configured, but not with a command interface it will print a warning. This way it will also update the value on the teach pendant.
@@ -1012,3 +1021,74 @@ INSTANTIATE_TEST_SUITE_P( | |||
std::make_tuple( | |||
std::vector<std::string>({"effort"}), | |||
std::vector<std::string>({"position", "velocity", "acceleration"})))); | |||
|
|||
TEST_P(TestTrajectoryActionsTestScalingFactor, test_scaling_execution_time_succeeds) |
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 have the feeling that just adding one test for such a complex feature is probably not enough.
I think it is missing some parts:
-
It just checks the if the trajectory took the right amount of time -> It does not check if the trajectory was executed in the right way (e.g. had a spike what ever)
-
Executing multiple trajectories in series
-
Proper behavior regarding state and goal tolerances (and goal time tolerances)
2/3. are motivated by: UniversalRobots/Universal_Robots_ROS2_Driver#882
Co-authored-by: Christoph Fröhlich <[email protected]>
Also run two trajectories
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.