-
Notifications
You must be signed in to change notification settings - Fork 16
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
Split the urscript into a header and a control loop. #14
Conversation
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.
In general, I think the idea is really good, but we should definitely tackle the generateScript
problem mentioned.
src/main/java/com/fzi/externalcontrol/impl/ExternalControlInstallationNodeContribution.java
Outdated
Show resolved
Hide resolved
|
||
while (it < splitData.length) { | ||
// Find the first line of the control loop | ||
if (splitData[it].startsWith(" socket_open(")) { |
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 seems absolutely brittle. As you mentioned in the OP, it might be better to define some anchors.
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.
Once the script has been moved to the client library issue I will define some anchors to search for.
src/main/java/com/fzi/externalcontrol/impl/ExternalControlInstallationNodeContribution.java
Outdated
Show resolved
Hide resolved
I have added a PR in the ROS driver, where I define the header and control loop part in the control script. These changes are needed in order to be able to have multiple URCap nodes in one program. |
@urmahp If the HEADER section is not defined, will it result in the similar behavior as before? |
I think this comment has not been addressed, right? |
Yes we should see same behavior as before the changes if the header is not defined.
It has been addressed in commit efbdfb8. I moved the request part, so that the script is only requested if the URCap is part of the robot program. |
I'll give it another review then, later today / tonight |
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 just have minor suggestions for the documentation, otherwise it looks good. However, I didn't have time to properly test it, yet. Will do that tonight.
Thanks for the review @fmauch. I will update the documentation first thing tomorrow. |
I would be fine with simply accepting my suggestions 😉 |
Could I just click commit suggestion to accept them? |
Yes, indeed. |
String[] programArray = program.split("\n"); | ||
|
||
for (int it = 0; it < programArray.length; ++it) { | ||
if (programArray[it].matches("(.*)# HEADER_BEGIN(.*)")) { |
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.
Allowing only whitespaces before and after might be safer. If people write comments like
# This does not go into the "# HEADER_BEGIN" section
if (programArray[it].matches("(.*)# HEADER_BEGIN(.*)")) { | |
if (programArray[it].matches("(\s*)# HEADER_BEGIN(\s*)")) { |
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 seems to brake the URCap when building, to make it build following if (programArray[it].matches("(\\s*)# HEADER_BEGIN(\\s*)"))
will be needed.
When testing it with # This does not go into the "# HEADER_BEGIN" section
the only time it seems to be able to find the # HEADER_BEGIN
is with the original implementation.
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.
According to this post \\p{Zs}
might be a working solution.
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 tested \\p{Zs}
and it recognizes # HEADER_BEGIN
but not # This is a comment about # HEADER_BEGIN
@urmahp If you would be fine with this, I will push that to your branch and then we're ready to merge.
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 I have also tested that it works and it seems like a good solution, thanks for you help.
I've tested it and it seems to do its job perfectly! |
Thx, for your approach! |
@ipa-lth Thanks for your suggestion and sharing it, we are really grateful for that. It help pushing us in the right direction. I agree that the control loop could be placed into a script function as well. Thus global variables have the disadvantage/feature that they will show up in the teach pendant's variable window. The "share codes between the URCap nodes" is a general problem and the "workaround" should also work with other contexts than the ROS driver. See e.g. https://sdurobotics.gitlab.io/ur_rtde/examples/examples.html#use-with-externalcontrol-ur-cap |
Nice lib! Thanks for sharing. |
The header is only appended to the UR program once, while the control loop is appended for each urcap node. This enables the possibility to have multiple urcap nodes in one program.
Changed behavior so the program is only requested once the urcap is part of the program.
7d9dd9b
to
d97f7a2
Compare
The header is only appended to the UR program once, while the control loop is appended for each urcap node. This enables the possibility to have multiple urcap nodes in one program.
This implements #5
It is related to pr #7 and UniversalRobots/Universal_Robots_ROS_Driver#207.
But it is a slightly different approach, with this approach the urscript doesn't have to be changed, it works with how the urscript looks at moment.
A more robust solution might be to add a line to the urscript which makes it possible to distinguish between header and control loop. The current solution is searching for the "socket_open" line, which is the first line of code in the control loop.