SEARCH
TOOLBOX
LANGUAGES
Xitact Howto

Xitact Howto

From SOFAWiki

Jump to: navigation, search
How to use XITACT haptic tools in SOFA

Contents

Getting started with XITACT tools

Tools installation

As explain in previous page, handle of two Xitact models are available in SOFA for the moment: Xitact ITP and IHP. We will assume that you have the whole Xitact SDK package given by Mentice. Thus, as explains in the documentation. You should have on your computer:

- A directory: C:/xitact/licenses/ containing your license. Remember the name of your license file. It will be needed in further step.
- Others files: XiTrocarInterface.h / XiRobot.lib / XiRobot.dll which will be used in further step too.
- And finally an executable: Xitact Lap Tester.exe which allows you to calibrate your tools (Note that this must be done before using SOFA as no calibration is available directly in SOFA)

Where in SOFA

All developement for Xitact tools are done in the plugin SOFA_DIR/applications/plugins/Xitact For the rest of this tutorial, this path will be named XITACT_DIR.

In this directory you will find:

- Interface for IHP (resp. ITP) tool in IHPDriver.h/cpp (resp. ITPDriver.h/cpp). 
- A class to create thread at a given frequency: PaceMaker.h/cpp
- A class for handling haptic events (not done yet)


Configuration and Compilation

Before compiling this plugin, it is necessary to place the different files given in the SDK package:

- XiTrocarInterface.h should be placed in Sofa/include
- XiRobot.lib should be placed in Sofa/lib/win32/Common
- XiRobot.dll should be placed in Sofa/bin

Then, edit the configuration file (or use the utility SofaConfiguration) and uncomment (or enable) the option :

SOFA_HAVE_XITACT

and update Makefiles, executing

Project VC7.bat (Visual Studio 2003) 
Project VC8.bat (Visual Studio 2005)
Project VC9.bat (Visual Studio 2008)


How to use them

Test and calibration

For the correct use, run the file Xitact Lap Tester.exe provided by the productor for testing and calibrating the instrument before lauching SOFA scenes.

Example scenes

Some basic scenes are available in XITACT_DIR/examples

- For one IHP tool: XitactGrasping.scn
- For two simultaneous IHP tools: XitactGrasping_coupledModel.scn
- For one ITP tool: xitactTestITP.scn
- For coupled models: XitactGrasping_coupledModel_withITP.scn
- To test forcefeedback: XitactGraspingWithForceFeedBack.scn


Drivers parameters

In the simulation scene, it will appears at:

<IHPDriver name="IHPdrivers"  listening="1"  Scale="10" />

For both models:

- listening = 1 to activate the driver.
- Sclae = to give the tool scale (must be consistent with interaction forces).
- toolIndex By default equal to 0. If using several tools in the same scene. It give the device identifier (0 for first one). To know tool indices, see the Xitact Lap Tester.exe.

For IHP model only:

- permanent = 1 if you want to use forcefeedback.
- graspThreshold: Threshold in double under which grasping will launch an event.


How to use the driver in a scene

As it can be seen in scene example, this node show how to use a Xitact tool. See the comments to understand the goal of the different components:

<?xml version="1.0" ?>
  <Node name="VirtualArticulatedXitact">
   <!-- *** Tool model: mechanical behaviour*** -->
    <EulerImplicit rayleighMass="0.1" rayleighStiffness="0.01"/>
    <CGLinearSolver iterations="40" name="linear solver" tolerance="1.0e-9" threshold="1.0e-15"/>
    <!-- Modify this position in the scene -->
    <MechanicalObject name="bati" template="Rigid" position="0 0 0 -0.7071068 0 0 0.7071068"/>
    <UniformMass totalMass="0.01"/>
 
    <RestShapeSpringsForceField points="0" stiffness="10000" angularStiffness="1000000000" external_rest_shape="toto"/>
    <UncoupledConstraintCorrection compliance="0.0001  0.000000001 0 0 0.000000001 0 0.000000001"/>
 
 
  <!-- *** Bati visual model*** -->
    <Node name="VisuOfXitactBase">
      <OglModel name="VM1" fileMesh="dt/cube_low_res.obj" scale="3"   dy="15.0" dz="30" />
      <OglModel name="VM2" fileMesh="dt/cube_low_res.obj" scale="3"   dy="30.0" dz="30" />
      <OglModel name="VM3" fileMesh="dt/cube_low_res.obj" scale="0.5" dy="38" />
      <RigidMapping object1="../.." object2="VM1" index="0"/>
      <RigidMapping object1="../.." object2="VM2" index="0"/>
      <RigidMapping object1="../.." object2="VM3" index="0"/>
    </Node>
 
  <!-- *** Grasper model: mechanical behaviour*** -->
    <Node name="Grasper">
      <MechanicalObject name="Articulations" template="Vec1d" position="0 0 0 0 0 0" rest_position="0 0 0 0 0 0"/>
      <RestShapeSpringsForceField points="0 1 2 3 4 5" stiffness="1000000 1000000 1000000 1000 1000000 1000000 " printLog="true"/>
      <UncoupledConstraintCorrection compliance="0.000001 0.000001 0.000001 0.001 0.000001 0.000001 " />
      <!-- Driver -->
      <IHPDriver Scale="1000"/>
 
      <!-- *** Grasper model details: composed of on stem and a pair of claws for grasping*** -->
      <Node name="Jaws">
        <MechanicalObject name="GrasperDOFs" template="Rigid" position="0 0 0 0 0 0 1  0 0 0 0 0 0 1  0 0 0 0 0 0 1  0 0 0 0 0 0 1  "/>
        <!--	<UniformMass mass="0.1 1  2.0 0 0  0 10.0 0  0 0 10.0"/>	-->
 
        <!-- *** stem visual model *** -->
        <Node name="Tool1VM">
          <OglModel name="VM" fileMesh="dt/aspi.trian" scale="1" rx="90.0" />
          <RigidMapping object1="../.." object2="VM" index="1"/>
        </Node>
 
        <!-- *** stem collision model *** -->
        <Node name="Tool1CM">
          <RegularGrid nx="1" ny="2" nz="1" min="0 -350 0" max="0 0 0" />
          <MechanicalObject name="Endoscope Collision State"/>
          <Line group="1"/>
          <Point group="1"/>
          <RigidMapping name="MM->CM mapping" object1="../.." index="1"/>
        </Node>
 
        <!-- *** first claw part visual model *** -->
        <Node name="Grasp1_1VM">
          <OglModel name="VM" fileMesh="dt/mors1.trian" color="0.9 0.9 0.2 1.0" scale="1"  dy="25"/>
          <RigidMapping object1="../.." object2="VM" index="2"/>
        </Node>
 
        <!-- *** first claw part collision model *** -->
        <Node name="Grasp1_1CM">
          <MeshLoader filename="dt/mors1_extralight.obj" />
          <Mesh/>
          <MechanicalObject name="CM" scale="1"  dy="25"/>
          <Triangle group="1"/>
          <Line group="1"/>
          <Point group="1"/>
          <RigidMapping object1="../.." object2="CM" index="2"/>
        </Node>
 
        <!-- *** second claw part visual model *** -->
        <Node name="Grasp1_2VM">
          <OglModel name="VM" fileMesh="dt/mors2.trian" color="0.9 0.9 0.2 1.0" scale="1"   dy="25"/>
          <RigidMapping object1="../.." object2="VM" index="3"/>
        </Node>
 
        <!-- *** second claw part collision model *** -->
        <Node name="Grasp1_2CM">
          <MeshLoader filename="dt/mors1_extralight.obj" />
          <Mesh/>
          <MechanicalObject name="CM" scale="1"  dy="25" />
          <Triangle group="1"/>
          <Line group="1"/>
          <Point group="1"/>
          <RigidMapping object1="../.." object2="CM" index="3"/>
        </Node>
 
       <!-- *** Articulation system between the end of the stem and the ''bati'' *** -->
        <ArticulatedSystemMapping object1="Articulations" object2="Jaws/GrasperDOFs" rootModel="../bati"/>
      </Node>
 
      <!-- *** Articulation system between claws and the stem ? *** -->
      <ArticulatedHierarchyContainer/>
 
      <Node name="articulationCenters">
        <Node name="articulationCenter1">
          <ArticulationCenter parentIndex="0" childIndex="1" posOnParent="0 0 0" posOnChild="0 0 0"/>
          <Node name="articulations">
            <Articulation translation="0" rotation="1" rotationAxis="1 0 0" articulationIndex="0"/>
            <Articulation translation="0" rotation="1" rotationAxis="0 0 1" articulationIndex="1"/>
            <Articulation translation="0" rotation="1" rotationAxis="0 1 0" articulationIndex="2"/>
            <Articulation translation="1" rotation="0" rotationAxis="0 1 0" articulationIndex="3"/>
          </Node>
        </Node>
 
        <Node name="articulationCenter1_1">
          <ArticulationCenter parentIndex="1" childIndex="2" posOnParent="0 0 0" posOnChild="0 0.0 0"/>
          <Node name="articulations">
            <Articulation translation="0" rotation="1" rotationAxis="1 0 0" articulationIndex="4"/>
          </Node>
        </Node>
 
        <Node name="articulationCenter1_2">
          <ArticulationCenter parentIndex="1" childIndex="3" posOnParent="0 0 0" posOnChild="0 0.0 0"/>
          <Node name="articulations">
            <Articulation translation="0" rotation="1" rotationAxis="-1 0 0" articulationIndex="5"/>
          </Node>
        </Node>
 
      </Node>
 
    </Node>
 
  </Node>

Finally, as collision pipeline. It is better to use:

<?xml version="1.0" ?>
	<MasterContactSolver />
	<LCPConstraintSolver initial_guess="true" displayTime="0" mu="0.7" tolerance="0.0000000001" printLog="0" maxIt="3000" build_lcp="true"/>
	<CollisionPipeline depth="6" verbose="0" draw="0"/>
	<BruteForceDetection name="N2" />
	<LocalMinDistance name="Proximity" alarmDistance="6.0" contactDistance="1.5" coneFactor="0.5" angleCone="-0.001"/>
	<CollisionResponse name="Response" response="FrictionContact" />

How to develop new applications with those devices

TODO