I added a probe tool model（.stl）to the scene and coupled it with Touch device, but how do I set the transformation relationship between the coordinate system of Touch device and the probe tool? I have the following questions: 1 What are the rules for establishing the coordinate system of the tool itself in imstk? (I created the tool model with SOLIDWORK) 2 What are the rules for establishing the coordinate system of the Touch device itself? 3. How to set the transformation relationship between Touch device and the tool coordinate system? Which sample programs describe the setting method?
The tool modeled in your program has its own local coordinate system. You can transform it there, or before giving it to imstk via:
Geometry::transform(<transform here>, Geometry::TransformType::ApplyToData);
To control it with a haptic device you need to set one of those up. A phantom omni through open haptics by default gives you [-1, 1] bounds on all axes (which physically corresponds to the space in front of it).
It is setup like so:
imstkNew<HapticDeviceManager> hapticManager; std::shared_ptr<HapticDeviceClient> client = hapticManager->makeDeviceClient(); driver->addModule(hapticManager);
You can directly access this positional and orientation data via:
However in many of our examples we set the tool up as a rigid body with mass and inertia, then move it with forces, particularly a spring damper force, this can be done like so:
auto controller = std::make_shared<RigidObjectController>(myRigidObject, myHapticDeviceClient); controller->setLinearKs(100000.0); // Linear spring force controller->setAngularKs(300000000.0); // Angular spring force controller->setUseCritDamping(true); // Critical damping, automatically determines suitable damping controller->setForceScaling(0.001); // Scale the force the user feels controller->setTranslationScaling(0.001); // Scale the translation of the device controller->setTranslationOffset(Vec3d(0.0, 1.0, 0.0)); // Apply a world offset that moves it up controller->setSmoothingKernelSize(10); // Using a running average of the last 10 forces for the current rendered force scene->addController(controller);