Creating simple shapes with physics properties
[
Front page
] [
New
|
List of pages
|
Search
|
Recent changes
|
Help
]
Start:
[[Tutorial]]
#contents
*Robot Dynamics [#la446dbf]
SIGVerse using OpenDynamicsEngine (ODE) to model the dyna...
This tutorial shows how to model simple objects using th...
**Simple Model [#yc108ce2]
*** Creating a model [#o8f6b967]
To begin with, please create a directory and copy the x3d...
We shall then discuss its contents.
$ cd ~/MyWorld
$ emacs robot_test.x3d
robot_test.x3d
#highlight(xml){{
<?xml version="1.0" encoding="UTF-8"?>
<X3D profile="Immersive" version="3.0">
<Scene>
<ProtoDeclare name='Joint' >
<ProtoInterface>
<field accessType='inputOutput' type='SFVec3f' name='cen...
<field accessType='inputOutput' type='MFNode' name='chil...
<field accessType='inputOutput' type='MFFloat' name='lli...
<field accessType='inputOutput' type='SFRotation' name='...
<field accessType='inputOutput' type='SFString' name='na...
<field accessType='inputOutput' type='SFRotation' name='...
<field accessType='inputOutput' type='SFVec3f' name='sca...
<field accessType='inputOutput' type='SFRotation' name='...
<field accessType='inputOutput' type='MFFloat' name='sti...
<field accessType='inputOutput' type='SFVec3f' name='tra...
<field accessType='inputOutput' type='MFFloat' name='uli...
<field accessType='inputOutput' type='MFFloat' name='dh'...
<field accessType='inputOutput' type='SFString' name='jo...
<field accessType='inputOutput' type='SFFloat' name='joi...
<field accessType='inputOutput' type='SFVec3f' name='joi...
</ProtoInterface>
<ProtoBody>
<Transform>
<IS>
<connect nodeField='children' protoField='children' />
<connect nodeField='center' protoField='center' />
<connect nodeField='rotation' protoField='rotation' />
<connect nodeField='scale' protoField='scale' />
<connect nodeField='scaleOrientation' protoField='sc...
<connect nodeField='translation' protoField='transla...
</IS>
</Transform>
</ProtoBody>
</ProtoDeclare>
<ProtoDeclare name='Segment' >
<ProtoInterface>
<field accessType='initializeOnly' type='SFVec3f' name='...
<field accessType='initializeOnly' type='SFVec3f' name='...
<field accessType='inputOutput' type='SFVec3f' name='cen...
<field accessType='inputOutput' type='MFNode' name='chil...
<field accessType='inputOutput' type='SFNode' name='coor...
<field accessType='inputOutput' type='MFNode' name='disp...
<field accessType='inputOutput' type='SFFloat' name='mas...
<field accessType='inputOutput' type='MFFloat' name='mom...
<field accessType='inputOutput' type='SFString' name='na...
<field accessType='inputOnly' type='MFNode' name='addChi...
<field accessType='inputOnly' type='MFNode' name='remove...
</ProtoInterface>
<ProtoBody>
<Group>
<IS>
<connect nodeField='children' protoField='children' />
<connect nodeField='addChildren' protoField='addChil...
<connect nodeField='removeChildren' protoField='remo...
<connect nodeField='bboxCenter' protoField='bboxCent...
<connect nodeField='bboxSize' protoField='bboxSize' />
</IS>
</Group>
</ProtoBody>
</ProtoDeclare>
<ProtoDeclare name='Humanoid' >
<ProtoInterface>
<field accessType='initializeOnly' type='SFVec3f' name='...
<field accessType='initializeOnly' type='SFVec3f' name='...
<field accessType='inputOutput' type='SFVec3f' name='cen...
<field accessType='inputOutput' type='MFNode' name='huma...
<field accessType='inputOutput' type='MFString' name='in...
<field accessType='inputOutput' type='MFNode' name='join...
<field accessType='inputOutput' type='SFString' name='na...
<field accessType='inputOutput' type='SFRotation' name='...
<field accessType='inputOutput' type='SFVec3f' name='sca...
<field accessType='inputOutput' type='SFRotation' name='...
<field accessType='inputOutput' type='MFNode' name='segm...
<field accessType='inputOutput' type='MFNode' name='site...
<field accessType='inputOutput' type='SFVec3f' name='tra...
<field accessType='inputOutput' type='SFString' name='ve...
<field accessType='inputOutput' type='MFNode' name='view...
</ProtoInterface>
<ProtoBody>
<Transform>
<IS>
<connect nodeField='bboxCenter' protoField='bboxCent...
<connect nodeField='bboxSize' protoField='bboxSize' />
<connect nodeField='center' protoField='center' />
<connect nodeField='rotation' protoField='rotation' />
<connect nodeField='scale' protoField='scale' />
<connect nodeField='scaleOrientation' protoField='sc...
<connect nodeField='translation' protoField='transla...
</IS>
<Group>
<IS>
<connect nodeField='children' protoField='viewpoin...
</IS>
</Group>
<Group>
<IS>
<connect nodeField='children' protoField='humanoid...
</IS>
</Group>
</Transform>
</ProtoBody>
</ProtoDeclare>
<ProtoInstance name='Humanoid' DEF="HRP1" contain...
<fieldValue name='info' value='"Test Joint"' />
<fieldValue name='name' value='sample' />
<fieldValue name='version' value='1.1' />
<ProtoInstance name='Joint' DEF="JOINT0" container...
<fieldValue name='name' value='JOINT0' />
<fieldValue name='jointType' value='free' />
<fieldValue name='jointId' value='1.0' />
<ProtoInstance name='Joint' DEF="JOINT1" containerField...
<fieldValue name='name' value='JOINT1' />
<fieldValue name='jointId' value='2.0' />
<fieldValue name='jointType' value='fixed' />
<ProtoInstance name='Segment' DEF="LINK1" containe...
<fieldValue name='name' value='LINK1' />
<fieldValue name='mass' value='0.5' />
<Transform>
<Shape>
<Box size="2 10 2"/>
<Appearance>
<Material diffuseColor='0.6 0.6 0.1' />
</Appearance>
</Shape>
</Transform>
</ProtoInstance>
<ProtoInstance name='Joint' DEF="JOINT2" containerFie...
<fieldValue name='name' value='JOINT2' />
<fieldValue name='translation' value='0.0 5.0 0.0' />
<fieldValue name='jointType' value='rotate' />
<fieldValue name='jointAxis' value='1.0 0.0 0.0' />
<fieldValue name='jointId' value='3.0' />
<ProtoInstance name='Segment' DEF="LINK2" containe...
<fieldValue name='name' value='LINK2' />
<fieldValue name='centerOfMass' value='0.0 5.0 0.0...
<fieldValue name='mass' value='0.5' />
<Transform>
<Shape>
<Box size="2 10 2"/>
<Appearance>
<Material diffuseColor='0.6 0.6 0.1' />
</Appearance>
</Shape>
</Transform>
</ProtoInstance>
</ProtoInstance>
</ProtoInstance>
</ProtoInstance>
</ProtoInstance>
</Scene>
</X3D>
}}
*** Layout of the model [#e89cc0fd]
The Basic layout of the file is as FOLLOWS:
Header:
PROTO declaration part (Declare the PROTO Structure)
The rest:
Real-model definition part (Declare the instances th...
In OpenHRP format, a model is created by combining the in...
There are three types of PROTO nodes:
--1.Joint node
--2.Segment node
--3.Humanoid node
The JOINT node specifies the link structure.
The Segment node defines the Link shape.
The Humanoid Node is the root node of the model.
For more information about OpenHRP format and modeling, p...
The parent-child relationship of the model we have create...
Humanoid sample(the root node of the model)
+ Joint JOINT0 (the root joint has six degree of fre...
+ Joint JOINT1
Segment LINK1 ( its fixed joint i.e. zero degre...
+ Joint JOINT2
Segment LINK2(hinge joint, single degrees o...
With the rotation and movement of a Joint, the segment an...
In this example, LINK1 is the segment of JOINT1 while JOI...
#ref(./bou_2.jpg)
*** Making of Configuration and World file [#afca224a]
Lets create the configuration file to read the model we c...
$ emacs robot_test.xml
robot_test.xml
#highlight(xml){{
<?xml version="1.0" encoding="utf8"?>
<define-class name="robot_test" inherit="Agent.xml">
<x3d>
<!--Reading the model you just created-->
<filename>robot_test.x3d</filename>
</x3d>
</define-class>
}}
Lets create the world model to use the configuration file...
DynamicsWorld.xml
#highlight(xml){{
<?xml version="1.0" encoding="utf8"?>
<world name="myworld11">
<gravity x="0.0" y="-980.7" z="0.0"/>
<instanciate class="robot_test.xml">
<set-attr-value name="name" value="robot_test"/>
<!--dynamics true-->
<set-attr-value name="dynamics" value="true"/>
<set-attr-value name="x" value="5.0"/>
<set-attr-value name="y" value="10.0"/>
<set-attr-value name="z" value="5.0"/>
<set-attr-value name="language" value="c++"/>
<set-attr-value name="collision" value="true"/>
</instanciate>
</world>
}}
The dynamics of the robot model is set as "TRUE"
*** Upload the World File to SIGViewer [#y3a4127e]
Let's run without any controller first. Just to see how i...
$ sigserver.sh -w ./DynamicsWorld.xml
You can see the bar If you look in connection with the SI...
Then click the bar by clicking the "Entity Data" in the t...
#ref(./bou_4.PNG,40%)
--Red dot indicates the position of the entity. Position ...
--Blue is the position of the JOINT2.
--Green is the position of the part (Segment).
#ref(./bou_1.PNG,40%)
Bar stands straight in the beginning, but when we start t...
*** Controller [#yb37abf3]
Let's create a controller for applying a torque to the jo...
$ emacs DynamicsController.cpp
DynamicsController.cpp
#highlight(cpp){{
#include "Controller.h"
class MoveController : public Controller {
public:
double onAction(ActionEvent&);
};
double MoveController::onAction(ActionEvent &evt) {
SimObj *my = getObj(myname());
//add torque on JOINT2 ...
my->addJointTorque("JOINT2",50000.0);
return 0.1;
}
extern "C" Controller * createController() {
return new MoveController;
}
}}
Here we apply torque to the hinge joint using the SIGVers...
Lets compile the controller.
$ ./sigmake.sh DynamicsController.cpp
*** World file modification [#hcb3d322]
Please add the executable in the xml world file.
<set-attr-value name="implementation" value="./DynamicsC...
Thus, the world file shall look like below:
DynamicsWorld.xml
#highlight(xml){{
<?xml version="1.0" encoding="utf8"?>
<world name="myworld11">
<gravity x="0.0" y="-980.7" z="0.0"/>
<instanciate class="robot_test.xml">
<set-attr-value name="name" value="robot_test"/>
<!--dynamics true-->
<set-attr-value name="dynamics" value="true"/>
<set-attr-value name="x" value="5.0"/>
<set-attr-value name="y" value="10.0"/>
<set-attr-value name="z" value="5.0"/>
<set-attr-value name="language" value="c++"/>
<set-attr-value name="implementation" value="./Dynami...
<set-attr-value name="collision" value="true"/>
</instanciate>
</world>
}}
*** Uploading the world file to SIGViewer [#h7ccf63e]
Its time to run.
$ sigserver.sh -w ./DynamicsWorld.xml
When you start the simulation, you will notice that the J...
#ref(./bou_2.PNG,40%)
*** Setting of the angular velocity of the joint [#lc87ba...
We added a torque to the joint on the controller earlier....
Please replace the function to torque to joints with a fu...
DynamicsController.cpp
#highlight(cpp:firstline[13]){{
my->addJointTorque("JOINT2",50000.0);
}}
↓
#highlight(cpp:firstline[13]){{
my->setJointVelocity("JOINT2", 1.57, 50000.0);
}}
We set the angular velocity of the joint using the API fu...
You will reach quickly to the angular velocity that you s...
It is now time to compile and run.
$ ./sigmake.sh DynamicsController.cpp
$ sigserver.sh -w ./DynamicsWorld.xml
#ref(./bou_3.PNG,40%)
Joint continues to rotate at a constant speed after it fa...
#highlight(end)
#counter
End:
[[Tutorial]]
#contents
*Robot Dynamics [#la446dbf]
SIGVerse using OpenDynamicsEngine (ODE) to model the dyna...
This tutorial shows how to model simple objects using th...
**Simple Model [#yc108ce2]
*** Creating a model [#o8f6b967]
To begin with, please create a directory and copy the x3d...
We shall then discuss its contents.
$ cd ~/MyWorld
$ emacs robot_test.x3d
robot_test.x3d
#highlight(xml){{
<?xml version="1.0" encoding="UTF-8"?>
<X3D profile="Immersive" version="3.0">
<Scene>
<ProtoDeclare name='Joint' >
<ProtoInterface>
<field accessType='inputOutput' type='SFVec3f' name='cen...
<field accessType='inputOutput' type='MFNode' name='chil...
<field accessType='inputOutput' type='MFFloat' name='lli...
<field accessType='inputOutput' type='SFRotation' name='...
<field accessType='inputOutput' type='SFString' name='na...
<field accessType='inputOutput' type='SFRotation' name='...
<field accessType='inputOutput' type='SFVec3f' name='sca...
<field accessType='inputOutput' type='SFRotation' name='...
<field accessType='inputOutput' type='MFFloat' name='sti...
<field accessType='inputOutput' type='SFVec3f' name='tra...
<field accessType='inputOutput' type='MFFloat' name='uli...
<field accessType='inputOutput' type='MFFloat' name='dh'...
<field accessType='inputOutput' type='SFString' name='jo...
<field accessType='inputOutput' type='SFFloat' name='joi...
<field accessType='inputOutput' type='SFVec3f' name='joi...
</ProtoInterface>
<ProtoBody>
<Transform>
<IS>
<connect nodeField='children' protoField='children' />
<connect nodeField='center' protoField='center' />
<connect nodeField='rotation' protoField='rotation' />
<connect nodeField='scale' protoField='scale' />
<connect nodeField='scaleOrientation' protoField='sc...
<connect nodeField='translation' protoField='transla...
</IS>
</Transform>
</ProtoBody>
</ProtoDeclare>
<ProtoDeclare name='Segment' >
<ProtoInterface>
<field accessType='initializeOnly' type='SFVec3f' name='...
<field accessType='initializeOnly' type='SFVec3f' name='...
<field accessType='inputOutput' type='SFVec3f' name='cen...
<field accessType='inputOutput' type='MFNode' name='chil...
<field accessType='inputOutput' type='SFNode' name='coor...
<field accessType='inputOutput' type='MFNode' name='disp...
<field accessType='inputOutput' type='SFFloat' name='mas...
<field accessType='inputOutput' type='MFFloat' name='mom...
<field accessType='inputOutput' type='SFString' name='na...
<field accessType='inputOnly' type='MFNode' name='addChi...
<field accessType='inputOnly' type='MFNode' name='remove...
</ProtoInterface>
<ProtoBody>
<Group>
<IS>
<connect nodeField='children' protoField='children' />
<connect nodeField='addChildren' protoField='addChil...
<connect nodeField='removeChildren' protoField='remo...
<connect nodeField='bboxCenter' protoField='bboxCent...
<connect nodeField='bboxSize' protoField='bboxSize' />
</IS>
</Group>
</ProtoBody>
</ProtoDeclare>
<ProtoDeclare name='Humanoid' >
<ProtoInterface>
<field accessType='initializeOnly' type='SFVec3f' name='...
<field accessType='initializeOnly' type='SFVec3f' name='...
<field accessType='inputOutput' type='SFVec3f' name='cen...
<field accessType='inputOutput' type='MFNode' name='huma...
<field accessType='inputOutput' type='MFString' name='in...
<field accessType='inputOutput' type='MFNode' name='join...
<field accessType='inputOutput' type='SFString' name='na...
<field accessType='inputOutput' type='SFRotation' name='...
<field accessType='inputOutput' type='SFVec3f' name='sca...
<field accessType='inputOutput' type='SFRotation' name='...
<field accessType='inputOutput' type='MFNode' name='segm...
<field accessType='inputOutput' type='MFNode' name='site...
<field accessType='inputOutput' type='SFVec3f' name='tra...
<field accessType='inputOutput' type='SFString' name='ve...
<field accessType='inputOutput' type='MFNode' name='view...
</ProtoInterface>
<ProtoBody>
<Transform>
<IS>
<connect nodeField='bboxCenter' protoField='bboxCent...
<connect nodeField='bboxSize' protoField='bboxSize' />
<connect nodeField='center' protoField='center' />
<connect nodeField='rotation' protoField='rotation' />
<connect nodeField='scale' protoField='scale' />
<connect nodeField='scaleOrientation' protoField='sc...
<connect nodeField='translation' protoField='transla...
</IS>
<Group>
<IS>
<connect nodeField='children' protoField='viewpoin...
</IS>
</Group>
<Group>
<IS>
<connect nodeField='children' protoField='humanoid...
</IS>
</Group>
</Transform>
</ProtoBody>
</ProtoDeclare>
<ProtoInstance name='Humanoid' DEF="HRP1" contain...
<fieldValue name='info' value='"Test Joint"' />
<fieldValue name='name' value='sample' />
<fieldValue name='version' value='1.1' />
<ProtoInstance name='Joint' DEF="JOINT0" container...
<fieldValue name='name' value='JOINT0' />
<fieldValue name='jointType' value='free' />
<fieldValue name='jointId' value='1.0' />
<ProtoInstance name='Joint' DEF="JOINT1" containerField...
<fieldValue name='name' value='JOINT1' />
<fieldValue name='jointId' value='2.0' />
<fieldValue name='jointType' value='fixed' />
<ProtoInstance name='Segment' DEF="LINK1" containe...
<fieldValue name='name' value='LINK1' />
<fieldValue name='mass' value='0.5' />
<Transform>
<Shape>
<Box size="2 10 2"/>
<Appearance>
<Material diffuseColor='0.6 0.6 0.1' />
</Appearance>
</Shape>
</Transform>
</ProtoInstance>
<ProtoInstance name='Joint' DEF="JOINT2" containerFie...
<fieldValue name='name' value='JOINT2' />
<fieldValue name='translation' value='0.0 5.0 0.0' />
<fieldValue name='jointType' value='rotate' />
<fieldValue name='jointAxis' value='1.0 0.0 0.0' />
<fieldValue name='jointId' value='3.0' />
<ProtoInstance name='Segment' DEF="LINK2" containe...
<fieldValue name='name' value='LINK2' />
<fieldValue name='centerOfMass' value='0.0 5.0 0.0...
<fieldValue name='mass' value='0.5' />
<Transform>
<Shape>
<Box size="2 10 2"/>
<Appearance>
<Material diffuseColor='0.6 0.6 0.1' />
</Appearance>
</Shape>
</Transform>
</ProtoInstance>
</ProtoInstance>
</ProtoInstance>
</ProtoInstance>
</ProtoInstance>
</Scene>
</X3D>
}}
*** Layout of the model [#e89cc0fd]
The Basic layout of the file is as FOLLOWS:
Header:
PROTO declaration part (Declare the PROTO Structure)
The rest:
Real-model definition part (Declare the instances th...
In OpenHRP format, a model is created by combining the in...
There are three types of PROTO nodes:
--1.Joint node
--2.Segment node
--3.Humanoid node
The JOINT node specifies the link structure.
The Segment node defines the Link shape.
The Humanoid Node is the root node of the model.
For more information about OpenHRP format and modeling, p...
The parent-child relationship of the model we have create...
Humanoid sample(the root node of the model)
+ Joint JOINT0 (the root joint has six degree of fre...
+ Joint JOINT1
Segment LINK1 ( its fixed joint i.e. zero degre...
+ Joint JOINT2
Segment LINK2(hinge joint, single degrees o...
With the rotation and movement of a Joint, the segment an...
In this example, LINK1 is the segment of JOINT1 while JOI...
#ref(./bou_2.jpg)
*** Making of Configuration and World file [#afca224a]
Lets create the configuration file to read the model we c...
$ emacs robot_test.xml
robot_test.xml
#highlight(xml){{
<?xml version="1.0" encoding="utf8"?>
<define-class name="robot_test" inherit="Agent.xml">
<x3d>
<!--Reading the model you just created-->
<filename>robot_test.x3d</filename>
</x3d>
</define-class>
}}
Lets create the world model to use the configuration file...
DynamicsWorld.xml
#highlight(xml){{
<?xml version="1.0" encoding="utf8"?>
<world name="myworld11">
<gravity x="0.0" y="-980.7" z="0.0"/>
<instanciate class="robot_test.xml">
<set-attr-value name="name" value="robot_test"/>
<!--dynamics true-->
<set-attr-value name="dynamics" value="true"/>
<set-attr-value name="x" value="5.0"/>
<set-attr-value name="y" value="10.0"/>
<set-attr-value name="z" value="5.0"/>
<set-attr-value name="language" value="c++"/>
<set-attr-value name="collision" value="true"/>
</instanciate>
</world>
}}
The dynamics of the robot model is set as "TRUE"
*** Upload the World File to SIGViewer [#y3a4127e]
Let's run without any controller first. Just to see how i...
$ sigserver.sh -w ./DynamicsWorld.xml
You can see the bar If you look in connection with the SI...
Then click the bar by clicking the "Entity Data" in the t...
#ref(./bou_4.PNG,40%)
--Red dot indicates the position of the entity. Position ...
--Blue is the position of the JOINT2.
--Green is the position of the part (Segment).
#ref(./bou_1.PNG,40%)
Bar stands straight in the beginning, but when we start t...
*** Controller [#yb37abf3]
Let's create a controller for applying a torque to the jo...
$ emacs DynamicsController.cpp
DynamicsController.cpp
#highlight(cpp){{
#include "Controller.h"
class MoveController : public Controller {
public:
double onAction(ActionEvent&);
};
double MoveController::onAction(ActionEvent &evt) {
SimObj *my = getObj(myname());
//add torque on JOINT2 ...
my->addJointTorque("JOINT2",50000.0);
return 0.1;
}
extern "C" Controller * createController() {
return new MoveController;
}
}}
Here we apply torque to the hinge joint using the SIGVers...
Lets compile the controller.
$ ./sigmake.sh DynamicsController.cpp
*** World file modification [#hcb3d322]
Please add the executable in the xml world file.
<set-attr-value name="implementation" value="./DynamicsC...
Thus, the world file shall look like below:
DynamicsWorld.xml
#highlight(xml){{
<?xml version="1.0" encoding="utf8"?>
<world name="myworld11">
<gravity x="0.0" y="-980.7" z="0.0"/>
<instanciate class="robot_test.xml">
<set-attr-value name="name" value="robot_test"/>
<!--dynamics true-->
<set-attr-value name="dynamics" value="true"/>
<set-attr-value name="x" value="5.0"/>
<set-attr-value name="y" value="10.0"/>
<set-attr-value name="z" value="5.0"/>
<set-attr-value name="language" value="c++"/>
<set-attr-value name="implementation" value="./Dynami...
<set-attr-value name="collision" value="true"/>
</instanciate>
</world>
}}
*** Uploading the world file to SIGViewer [#h7ccf63e]
Its time to run.
$ sigserver.sh -w ./DynamicsWorld.xml
When you start the simulation, you will notice that the J...
#ref(./bou_2.PNG,40%)
*** Setting of the angular velocity of the joint [#lc87ba...
We added a torque to the joint on the controller earlier....
Please replace the function to torque to joints with a fu...
DynamicsController.cpp
#highlight(cpp:firstline[13]){{
my->addJointTorque("JOINT2",50000.0);
}}
↓
#highlight(cpp:firstline[13]){{
my->setJointVelocity("JOINT2", 1.57, 50000.0);
}}
We set the angular velocity of the joint using the API fu...
You will reach quickly to the angular velocity that you s...
It is now time to compile and run.
$ ./sigmake.sh DynamicsController.cpp
$ sigserver.sh -w ./DynamicsWorld.xml
#ref(./bou_3.PNG,40%)
Joint continues to rotate at a constant speed after it fa...
#highlight(end)
#counter
Page: