Stop solid merging at the Robot node level #4066
Replies: 1 comment 2 replies
-
Well, I replied myself ! |
Beta Was this translation helpful? Give feedback.
-
Well, I replied myself ! |
Beta Was this translation helpful? Give feedback.
-
Hi everyone,
I'm importing CAO (FreeCAD) to Webots. I've wrote a Python script for that, and work nicely ! It simply export my CAO into a proto (Robot) file.
However, translating CAO "constraints" to Webots "joints" is not easy : the former is a object with two members to link, and could be used anywhere, whereas the latter use an object with only one member, and link with the parent.
To deal with that, the easiest way was the following : declare as children of the Robot node all my parts (to get all my part in place, eventually adjusting the translation/rotations values). Then, for each of my constraints, I choose one of the two members (usually the first of the two), and I add a SolidReference to the second member as a children of the first part.
To make things clear, here is an example :
Will produce the following pseudo proto :
This should work like wonder, BUT !
Their is solid merging. And all my part will be merged as one, because they all define a physic node, as well as the Robot node.
My solution was to add a Solid node without physic as a children of Robot, and place all my parts as children of this Solid node.
Hence, it stop solid merging because there is no Physic on this node, and all my parts are free to move again !
However, this solution has two issues : It involves an artificial Solid node, and I'm starting to experiment issues when working with this. Especially using connectors to Solid outside of the Robot, it get messed up. (I've try without this additional Solid node, and apart from the fact that the robot is stuck, the connector work fine, for instance. That why I blame this "hacky" Solid node)
One solution would be to deactivate solid merging at the Robot node. It should not be that bad in term of performance because we should not have often solid needed to be merged with the Robot node. Moreover, The doc state :
That would match the description, given that currently, all solid that derivate from Solid are used, and not only the Solid themself. Or if we don't want to change things, I thing it would be wise to warn that solid merging will act also on the Robot node. For beginner Robot and Solid node might be two separated concepts (that the mistake I've made, anyway...), even if they are actually linked.
To sum up, I'm arguing on the fact that Solids being direct children of Robot shouldn't be merge together, I don't see use case for that to be useful. I totally agree on the solid merging process otherwise, but I don't see is point is this particular case. Moreover Robot node are always at the top of the node tree, which emphasis this particularity.
In the code, we could change only a bit of code :
in WbSolid:750 :
const WbSolid *const us = jointParent() ? NULL : upperSolid();
could become :
const WbSolid *const us = jointParent() ? NULL : dynamic_cast<WbRobot *>(upperSolid());
Careful however, that the condition on "left wheel" / "right wheel" (in case of a differential robot, I'm correct ?) should be studied : do we need it still ? Is it handled by the proposed modification ? Should we keep it as a special case ? (I'm not sure about it, if possible I would prefer remove hard coded value, and if need be move the wheels of the Samples that need to be updated to put the wheel as a direct children of the Robot node)
In addition, it should be checked that it doesn't cause trouble to this part of the documentation :
Thank for reading up to here, I'm obviously open to any point of view, and aware that my use case is not the usual way of doing things in Webots.
Cheers
Beta Was this translation helpful? Give feedback.
All reactions