-
Notifications
You must be signed in to change notification settings - Fork 938
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
Add copy()
and deepCopy()
methods to RobotTrajectory class.
#1760
Conversation
Thanks for helping in improving MoveIt and open source robotics! |
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.
Would a unit test be relevant here?
|
||
void RobotTrajectory::deepCopy(const RobotTrajectory& robot_traj) | ||
{ | ||
this->robot_model_ = robot_traj.robot_model_; |
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 this really a deep copy of the RobotModel?
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 for the review! No, this isn't a deep copy. But I observer that constructor is receiving a shared ptr so I thought I should assigned it to a same shared pointer. But now I get the picture, value should be same not the memory! Sorry, I am not much familiar with this part of the package.
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 believe we actually want to keep the same RobotModel
in the copied trajectory.
the "deep" is supposed to imply that RobotStates are copied, not the whole underlying moveit class structure.
other proposals for this name are welcome.
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 believe we actually want to keep the same
RobotModel
in the copied trajectory.
I agree
the "deep" is supposed to imply that RobotStates are copied, not the whole underlying moveit class structure.
other proposals for this name are welcome.
I think "deep" could be a bit misleading. I would prefer something more explicit, maybe copyWithRobotStates()
.
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 RobotTrajectory::copy(const RobotTrajectory& other, bool copy_robot_states = false)
would be more explicit. This is the approach used in robot_state/conversions.h
for copy_attached_bodies
.
@davetcoleman I noticed there wasn't any unit test dir for the robot_trajectory package. Is it okay if I create it? |
|
||
void RobotTrajectory::deepCopy(const RobotTrajectory& robot_traj) | ||
{ | ||
this->robot_model_ = robot_traj.robot_model_; |
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 believe we actually want to keep the same RobotModel
in the copied trajectory.
the "deep" is supposed to imply that RobotStates are copied, not the whole underlying moveit class structure.
other proposals for this name are welcome.
moveit_core/robot_trajectory/include/moveit/robot_trajectory/robot_trajectory.h
Outdated
Show resolved
Hide resolved
Sorry for the late comment, but I think we could just implement the copy constructor as a deepcopy operation on the waypoints. Is there any use case for a shallow copy, i.e. keeping the waypoints but modifying the durations only? @v4hn: What do you think? |
This is the usual "should we change semantics without changing interfaces" question.
There's likely *someone* out there who exploited the shallow copy.
In this case I somewhat prefer the implemented approach (that I proposed),
but I don't have a strong opinion and it is indeed a rather drastic step
to eventually remove it as it breaks, e.g., STL containers...
Either way I would like to keep the proposed copy methods around.
|
I understand this argument in general, but it is rather unlikely in this case that somebody made use of this. In my point of view, it's a simple bug fix to return a deep copy of the waypoints by the copy constructor.
IMHO, this just clutters the API in this case. |
In my point of view, it's a simple bug fix to return a deep copy of the waypoints by the copy constructor.
...
IMHO, this just clutters the API in this case.
We'll need a third opinion then, as I do not agree with you (nor do I strongly disagree though).
@henningkayser :-)
|
Its always ok to add more tests! :-)
I lean towards @rhaschke 's thought that its a simple bug fix that makes the API more correct, and that should not be backported to Melodic but should be in MIGRATION.md But I also want to hear @henningkayser 's opinion |
I am curious to know if we have a decision here? |
Can't we just change the default copy constructor to shallow copy (here |
Can't we just change the default copy constructor to shallow copy (here `copy()`) and just provide one alternative for specifically copying the robot states?
If I understand your comment right, it's the exact opposite of what Robert and Dave proposed. :-)
They argue `copy()` is not needed at all (I'm unsure about that) and `copyWithRobotStates` should be the semantics of the copy constructor.
|
Well, you asked for my opinion ;)
I think shallow copy is probably the most needed of them all.
This is arguable, I would not expect that. It's fine if properly documented. |
Good point. Adding or removing states doesn't require a deep copy. |
The problem with this solution is that users will probably still make the same silly mistake and perform a shallow copy, using the copy constructor - I did so two years ago and a colleague of mine did some months ago. |
I have revived the copy constructor which calls method copy(). Let me know if everyone is fine with it. |
- Assign the deprecated attribute to copy constructor which forwards the call to the member method called copy().
b319def
to
7053676
Compare
4a8da29
to
fe40231
Compare
Codecov Report
@@ Coverage Diff @@
## master #1760 +/- ##
==========================================
+ Coverage 48.36% 48.44% +0.07%
==========================================
Files 297 297
Lines 23261 23278 +17
==========================================
+ Hits 11250 11276 +26
+ Misses 12011 12002 -9
Continue to review full report at Codecov.
|
moveit_core/robot_trajectory/include/moveit/robot_trajectory/robot_trajectory.h
Outdated
Show resolved
Hide resolved
moveit_core/robot_trajectory/include/moveit/robot_trajectory/robot_trajectory.h
Outdated
Show resolved
Hide resolved
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.
See proposed changes in #1813
Additionally to @mlautman's fixups I restored the assignment operator (performing a shallow copy), |
Congrats on getting your first MoveIt pull request merged and improving open source robotics! |
Description
This PR points to issue #1660. I have deprecated the "normal" copy constructors and added two new methods,
RobotTrajectory::copy()
andRobotTrajectory::deepCopy()
. Also documented these methods.Checklist