Commit 2fd48a34 authored by Sreekanth Arikatla's avatar Sreekanth Arikatla
Browse files

ENH: Add rotational offset for camera head

Add additional rotational offset for camera
head that is applied before the angulation offset.
parent e2152ca1
......@@ -53,17 +53,24 @@ CameraController::runModule()
Vec3d p;
Quatd r;
// Retrieve the position and orientation data of the controlling device
if (!this->computeTrackingData(p, r))
{
LOG(WARNING) << "CameraController::runModule warning: could not update tracking info.";
return;
}
// Apply Offsets
p = p + m_cameraTranslationOffset;
r *= m_cameraRotationOffset;
// Retrieve the camera head's current rotation angle (in degrees)
/*
this->setCameraHeadAngleOffset(headAngle);
*/
// Set camera info
// Apply Offsets over the device pose
p = p + m_cameraTranslationOffset; // Offset the device position
r *= Quatd(Eigen::AngleAxisd(m_cameraHeadAngleOffset*PI / 180., Vec3d(0., 0., 1.))); // Apply camera head rotation offset
r *= m_cameraTelescopeRotationOffset; // Apply rotation offset from angulation
// Set camera pose
m_camera.setPosition(p);
m_camera.setFocalPoint((r*FORWARD_VECTOR) + p);
m_camera.setViewUp(r*UP_VECTOR);
......@@ -72,7 +79,7 @@ CameraController::runModule()
void
CameraController::setCameraRotationOffset(const Quatd& r)
{
m_cameraRotationOffset = r;
m_cameraTelescopeRotationOffset = r;
}
void
......@@ -81,16 +88,28 @@ CameraController::setCameraTranslationOffset(const Vec3d& t)
m_cameraTranslationOffset = t;
}
const imstk::Vec3d&
const Vec3d&
CameraController::getCameraTranslationOffset() const
{
return m_cameraTranslationOffset;
}
const imstk::Quatd&
const Quatd&
CameraController::getCameraRotationOffset() const
{
return m_cameraRotationOffset;
return m_cameraTelescopeRotationOffset;
}
void
CameraController::setCameraHeadAngleOffset(const double angle)
{
m_cameraHeadAngleOffset = angle;
}
const double
CameraController::getCameraHeadAngleOffset() const
{
return m_cameraHeadAngleOffset;
}
} // imstk
......@@ -34,7 +34,7 @@ namespace imstk
///
/// \class CameraController
///
/// \brief
/// \brief Endoscopic camera controller
///
class CameraController : public Module, public TrackingController
{
......@@ -79,6 +79,12 @@ public:
///
const Quatd& getCameraRotationOffset() const;
///
/// \brief Get/Set the rotation offset from the camera head
///
void setCameraHeadAngleOffset(const double angle /*in degrees*/);
const double getCameraHeadAngleOffset() const;
protected:
///
/// \brief
......@@ -97,9 +103,10 @@ protected:
Camera& m_camera; ///< Camera controlled by the external device
Vec3d m_cameraTranslationOffset = WORLD_ORIGIN; ///< Translation offset for the camera over tracking data
Quatd m_cameraRotationOffset = Quatd::Identity(); ///< Rotation offset for the camera over tracking data
Vec3d m_cameraTranslationOffset = WORLD_ORIGIN; ///< Translation offset for the camera over tracking data
Quatd m_cameraTelescopeRotationOffset = Quatd::Identity(); ///< Rotation offset for the camera via telescope angulation
double m_cameraHeadAngleOffset = 0; ///< camera head angle offset (in deg)
};
} // imstk
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment