-
Notifications
You must be signed in to change notification settings - Fork 21
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
Port FSU speed limit handling from MotoROS1 #157
Conversation
Hi, thanks for the PR 👍 Could I be difficult and ask you to split it into multiple commits? Ideally a first commit showing just the 'import' of @EricMarcil's work here in MotoROS2, then further commits with the changes you describe you had to make. That would facilitate review as it would very clearly show what changed, where and when. thanks. |
f10d23b
to
a19a3d5
Compare
Hi, I have split it into 3 commits |
I will try to do some testing next week. I don't currently have a system with FSU configured. |
@iydv |
@EricMarcil thank you for the update. I have checked your solution and it is better than mine. I will implement and test it in MotoROS2 (which I can do only next week). |
a19a3d5
to
2eb81f9
Compare
…represent a current desired increment of actual positions
I have integrated changes from the latest MotoROS1 commit to reset @EricMarcil unfortunately, I encountered another issue with this solution: when the robot is moved away and enabled again the following error is triggered: I believe the issue is this condition. The variable |
I have tested this on a few trajectories and it seems to work well. Admittedly, my trajectories are rather primitive and hard-coded. But the behavior with speed-limiting enabled always matches the behavior with speed-limiting disabled. I can even switch back and forth mid trajectory. The only unfortunate part is that this makes the most-complicated section of code even more complicated. But I guess that's inevitable. @gavanderhoorn, I think this is a great addition and should in the |
I've also been reviewing and testing the last recommendation from @iydv. I agree with his change but in the process, I also found a new condition where the robot can still move. If in the middle of a motion, the mode key is switch to TEACH mode, and then the robot is manually restarted by switching back to PLAY, turning on the servos and then switch back to REMOTE. The robot continues execution what's left in the motion buffer. |
Are you testing with MotoROS2 or MotoROS1? |
I'm testing on MotoRos1. I'm working on fixing it. I'll commit to the PR on MotoRos1 and then you can review to see if it applied on MotoRos2. |
It looks like this does not apply to MR2. |
Could we perhaps add some more comments? As you write @ted-miller, this is already some of the most -- if not the most -- complex code in MotoROS (1 and 2) and this PR makes it even more complex. Seeing the discussion on ros-industrial/motoman#542, it's a non-trivial change which adds quite a bit of bookkeeping and handling for new corner-cases. I'd like to see more comments explaining what's going on, perhaps also at a conceptual level. ros-industrial/motoman#542 has some of that in the PR description and the subsequent comments, but we should embed that and have it right next to the source. I would perhaps also suggest setting an IO signal whenever the new code detects the FSU is 'active'. That would allow us to use that in other places without increasing coupling even more than we already do. |
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.
Marking as request changes to prevent us from merging this accidentally.
Note: @iydv, as this is essentially @EricMarcil's code, I'm not asking you add comments of course. As maintainers we can add more commits to this PR, which I what I suggest we do @ted-miller and @EricMarcil. |
@EricMarcil / @ted-miller: friendly ping? |
It's on the todo-list. I'd be in favor of merging this and opening another issue for the next milestone regarding comments/documentation. We also need to update the EDS document to explain the overall architecture of the code. |
I added comments to code on the MotoRos1 branch ros-industrial/motoman#542 |
@iydv: I've just pushed a commit which cherry-picked @EricMarcil's comments from ros-industrial/motoman@9c6ff7d to your branch. |
I don't have an FSU configured, so I can't test this myself right now. @ted-miller: if you could verify again this works as intended -- also with different (ie: multi-group) systems? I'll leave the decision to merge to you. |
It would also still be good to address my previous comment:
but we can do that in a follow up PR. |
@gavanderhoorn I will test it tomorrow on my robot, but I do not have a multi group setup. |
Clearer intent.
I have tested all recent changes including this and everything still works fine. |
Great. I'm setting up a multi-group system now to verify. If there are no issues, I'll merge. |
@EricMarcil, I found an issue... I've got an R1+R2+S1 system. I'm commanding S1 to remain stationary. (target pos = 0, target vel = 0) However, S1 decided to rotate up and crash into R1. This behavior does not occur when using the main branch. I'm also getting some unexpected messages on the debug log:
I'm investigating now. But if you have some idea of what could cause this, please let me know. |
@ted-miller can this be the issue? In here the current controller command position is retrieved. But if the command group is always 0, the positions for all groups are set to position of group 0? |
@iydv, Good catch. That does look wrong. Unfortunately, it's not the only problem. Now the robots come to immediate violent halt after they start moving. I'm guessing R2 is getting commanded with some uninitialized value. |
Yep. There were a few instances. It is working now (with only minimal physical damage done...) Given that the main functionality has been thoroughly vetted at this point, and that we've now identified a fix for other control groups, I'd say this is good to merge. As a side note, I was surprised to find that activating the speed limit for any group in the job will activate a speed limit for all groups in the job. This makes sense in hindsight, but I was surprised. This is good because it keeps everything in sync. I also attempted to create a custom INIT_ROS job which Thank you @EricMarcil and @iydv for the implementation and debugging. |
Well... turns out this isn't entirely true. If the FSU board is not configured for a particular servo board, then group(s) on that board will not be limited. I can't imagine a scenario where it would be intentionally configured like this. But its apparently possible. |
That looks like something we might want to detect and warn about? |
As discussed at here I have implemented motoros2 version of FSU speed limit handling. Additionally, I have introduced following changes to resolve issues in the implementation:
prevPulsePosData
is defined as global variable inCtrlGroup
. This is required, since this variable is constantly changing inRos_MotionControl_IncMoveLoopStart
function. TheprevPulsePos
variable cannot be used instead, because it will break the logic ofRos_MotionControl_AddToIncQueueProcess
.This change is required to allow initialization of
prevPulsePosData
when trajectory mode is disabled/enabled. Otherwise, the robot will always tried to return to its last position every time the trajectory mode is enabled.feedback_FollowJointTrajectory.feedback.desired.positions
is estimated differently now. Previously, it was accumulating allmoveData
increments in every iteration ofRos_MotionControl_IncMoveLoopStart
function. However, the robot cannot reach desired increments due to the speed limit. Which means thatRos_ActionServer_FJT_UpdateProgressTracker
function is called multiple times with increments that are never actually executed by the robot.I have changed
feedback_FollowJointTrajectory.feedback.desired.positions
to represent a current desired increment of actual positions, which better reflects the behavior ofRos_MotionControl_IncMoveLoopStart
with current changes.