Re: [osg-users] Invert scene graph
Hi Robert, thanks a lot for your reply and sorry for my late answer. You were completely right regarding the seg faults: I was not careful enough but now the problem seems to be solved. Nevertheless, I was more wondering what the best way to switch from a forward to an inverse kinematic chain (KC) is. I have attached to this message a very simple code to illustrate what I would like to achieve. I used the osgrobot.cpp example and created a set of 4 boxes (corresponding to the joints) linked together in a direct chain using PositionAttitudeTransform to manage their position and orientation. They are rotating around the x axis (represented by a grey cylinder). They can be controlled using the original keyboard handler provided in the example. I would like to be able to use two keyboard keys (in the code t and g) to switch from a direct chain to an inverse KC (with t and g respectively) while keeping constant the position and orientation of all the joints (if they have moved from t heir initial position): in one case (direct KC), the black box would be the first parent of the chain, and in the other (inverse KC), it would be the red box (the transformations that happened during those two cases have to be kept, i.e. I do not want to restart from the initial position and orientation). In addition to the tried solutions I mentioned in my previous message, I've also checked the panda3D framework (http://www.panda3d.org/) and it seems that there is a function for re-parenting that keep the position and orientation constant (wrtReparentTo, The wrt prefix stands for with respect to. This special method works like reparentto(), except that it automatically recomputes the local transform on myModel to compensate for the change in transform under the new parent, so that the node ends up in the same position relative to the world.) : I was wondering if an equivalent to this function exists in osg? It would be really helpful to me if somebody would have an example of a working implementation of this KC switching (corresponding in the attached example code to the function forwardKinematicChain() and inverseKinematicChain(), line 121 and 138, respectively). I'm really thankful for the help that you already provided and I hope I will be able to find a good solution for this issue. Best, Stéphane -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=52000#52000 Attachments: http://forum.openscenegraph.org//files/main_166.cpp ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Invert scene graph
Dear all, I'm still struggling with this problem. I've tried a few new things but the result is not satisfactory: - I tried to do a dynamic re-parenting by changing the scene graph after each connection and disconnection but the script tends to become unstable after a while (segfault errors). Additionally, I was not able to properly input the world transformation to the new fixed node of the graph: for example, if P0 was fixed, the end effector P3 has been transformed due to the move of the different joints and when P3 becomes fixed and P0 free again, I need to apply the right rotation and translation so that P3 stays in its current position. Finally I think the performances of the script would not be good enough to scale this problem to multiple kinematic chains (for example a thousand of them) moving asynchronously. - As suggested by Bryan, I also tried to keep the same graph structure but applying the inverse of the transformation. Nevertheless I was not able to simulate the behaviour I described in my first message: for example if Root ipo P0 ipo P1 ipo P2 ipo P3 and I want P3 to become the fixed node, I do not really see how I could use an inverse transformation to obtain such behaviour. It would be wonderful if I could have a small example to illustrate this idea. - I'm now trying to recompute manually the transformation for each node of the kinematic chain using a chain of matrix transforms. All the nodes are independent (only attached to the root) and they do not interact with each other. This solution is really tedious to implement and I have the feeling I'm missing the point of using a scene graph manager. - I've also started looking into physic based simulation using osgBullet and applying constraints between the nodes. I don't really know what would be the more appropriate way of solving this problem and I think I'm really missing some obvious solution. I would be much obliged if somebody could give me additional advice on this or a short working example (for example with 3 boxes). Thanks a lot for your help. Best regards, Stéphane -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=50990#50990 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Invert scene graph
Hi Stéphane, I think if you invert the matrices when you are doing backward kinematics, you can keep the same scenegraph structure. For example, when the end effector is attached, you have the transform from P3 to P2 but you have P2 ipo P2, so the inverse of the transform you have is what you should set the PAT transform to. Hope this helps, Bryan Thrall Hi Bryan, Thanks a lot for your quick reply. In fact I wanted to keep the benefit of having a scene graph structure when applying a transform to the different nodes. That is, if I move one node the transform will be propagated automatically to its children. My goal would have been to have two kinematic chains (direct and inverse) automatically managed by the scene graph structure. Otherwise I would have to manually propagate the transform for the inverse chain. For example if P1 ipo P2 ipo P3 (direct kinematic chain) and I would like to consider the inverse kinematic chain (P3 is fixed), applying a transform to P2 should only move P1. But in this case I would need to cancel the transform applied to P3 and propagate it to P1. That would definitely be an option but it seems to me a bit complicated considering the great opportunity given by the graph structure. I will still try to find a solution using dynamic parenting but I will consider your solution as a backup plan. Thanks again for your suggestion! Best, Stéphane -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=50311#50311 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Invert scene graph
Dear OSG users, I've been using OSG since quite some time now but I'm facing a problem for which I was not able to find a good solution. I both searched on the forum and googled my problem but with no luck so far. Since my overall setup is a bit complicated, I'm going to use here a simplified version to explain what I'm trying to achieve. Imagine that I try to create and animate a robotic arm with three degrees of freedom (articulations): I create a scene graph composed of a root node (osg::Group, called G, the basis of the arm) and three PositionAttitudeTransforms (P1,P2, and P3) corresponding to the articulations. The parenting relationship between those elements are the following: G is parent of (ipo) P1, P1 ipo P2 and P2 ipo P3. To each of those PositionAttitudeTransforms (PAT) I attached a node (osg::Node, called N1, N2, and N3 respectively) representing the physical model of the moving parts (loaded from stl files). So far everything is working perfectly and when moving the arm using a KeyboardEventHandler to move the different degrees of freedom the children of the articulations are moving accordingly. The particularity of the arm is that it can attached to the environment using its end effector (here N3) and detached its first articulation from the basis (N1 from G). I would like to be able to replicate such a behaviour meaning having alternatively G ipo P1 ipo P2 ipo P3 and G ipo P3 ipo P2 ipo P1. I would like to control the arm with the same events than before the disconnection: when I move P3, both P2 and P1 should be moving with the correct setting for the pivot points and positions. I already tried two options: - use the removeChild function to dynamically recreate the scene graph: the main problem is that it seems that the information regarding the PAT (both the position and the pivot point) are then incorrect. My guess was that those information are relative to the parent node but I didn't know how to correctly modify them afterwards. - having two different PAT for each node (like having a forward kinematic chain and a backward one): I did not think it was a good idea at the time so I quickly dropped the idea (I remembered obtaining two copies of each node displayed). My question would be the following: what would be the correct way to simulate such a behaviour, considering that there would be a succession of connection and disconnection (P1 and P3 being connected to the root alternatively)? Thank you! Best, Stéphane -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=50200#50200 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org