Commit c4390700 authored by Sreekanth Arikatla's avatar Sreekanth Arikatla

Merge branch 'removeCustomCamControllers' into 'master'

STYLE: Remove custom FLS Camera controller sources

See merge request !184
parents 01803ad5 83d84879
/*=========================================================================
Library: iMSTK
Copyright (c) Kitware, Inc. & Center for Modeling, Simulation,
& Imaging in Medicine, Rensselaer Polytechnic Institute.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=========================================================================*/
#include "imstkFLSCameraController.h"
#include <utility>
#include <g3log/g3log.hpp>
namespace imstk
{
void
FLSCameraController::setCameraHeadAngleOffset(const double angle)
{
m_cameraHeadAngleOffset = angle;
}
const double
FLSCameraController::getCameraHeadAngleOffset() const
{
return m_cameraHeadAngleOffset;
}
void
FLSCameraController::setCameraAngulation(const double angle)
{
m_cameraAngulation = angle;
m_cameraAngulationRotOffset = Quatd(Eigen::AngleAxisd(angle*PI / 180., Vec3d(0., 1., 0.)));
}
double
FLSCameraController::getCameraAngulation() const
{
return m_cameraAngulation;
}
void
FLSCameraController::setArduinoDevice(std::shared_ptr<VRPNArduinoDeviceClient> aClient)
{
arduinoActive = true;
arduinoClient = aClient;
}
void
FLSCameraController::setAngleCalibration(const double angle)
{
m_rollOffset = angle;
}
double FLSCameraController::getAngleCalibration()
{
return m_rollOffset;
}
void
FLSCameraController::recalibrate()
{
if (arduinoActive)
{
if (arduinoClient->getRoll() != 0)
{
m_rollOffset = arduinoClient->getRoll();
std::cout << "FLS Camera Controller: Calibration complete" << std::endl;
calibrated = true;
}
else
{
std::cout << "FLS Camera Controller: Cannot calibrate - bad input from device" << std::endl;
}
}
}
void
FLSCameraController::runModule()
{
//Get head angle from Arduino
if (arduinoActive)
{
this->setCameraHeadAngleOffset(arduinoClient->getRoll() - m_rollOffset);
}
auto roff = Quatd(Eigen::AngleAxisd(m_cameraHeadAngleOffset*PI / 180., Vec3d(0., 0., 1.)));
this->setCameraRotationOffset(roff);
if (!m_trackingDataUptoDate)
{
if (!updateTrackingData())
{
LOG(WARNING) << "CameraController::runModule warning: could not update tracking info.";
return;
}
}
Vec3d p = getPosition();
Quatd r = getRotation();
//Adjust the upward angulation position to the center of the ROM
auto angulationDirectionOffset = Quatd(Eigen::AngleAxisd(-90*PI / 180., Vec3d(0., 0., 1.)));
r *= angulationDirectionOffset;
// Apply Offsets over the device pose
p += m_cameraTranslationOffset; // Offset the device position
//Apply offset from angulation
r *= m_cameraAngulationRotOffset;
// Set camera pose
m_camera.setPosition(p); //position of camera
m_camera.setFocalPoint(r*FORWARD_VECTOR + p); //direction camera is looking
m_camera.setViewUp(m_cameraRotationalOffset*UP_VECTOR); //Orientation of camera
m_trackingDataUptoDate = false;
}
} // imstk
/*=========================================================================
Library: iMSTK
Copyright (c) Kitware, Inc. & Center for Modeling, Simulation,
& Imaging in Medicine, Rensselaer Polytechnic Institute.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=========================================================================*/
#ifndef imstkFLSCameraController_h
#define imstkFLSCameraController_h
#include "imstkCameraController.h"
#include "imstkVRPNArduinoDeviceClient.h"
namespace imstk
{
///
/// \class FLSCameraController
///
/// \brief Custom camera controller for the virtual FLS camera navigation
///
class FLSCameraController : public CameraController
{
public:
///
/// \brief
///
FLSCameraController(Camera& camera,
std::shared_ptr<DeviceClient> deviceClient) :
CameraController(camera, deviceClient)
{}
///
/// \brief Destructor
///
~FLSCameraController() = default;
///
/// \brief Get/Set the camera head angular offset
///
void setCameraHeadAngleOffset(const double angle);
const double getCameraHeadAngleOffset() const;
///
/// \brief Get/Set the cameraHead angle calibration offset
///
void setAngleCalibration( const double angle);
double getAngleCalibration();
///
/// \brief Get/Set the angulation
///
void setCameraAngulation(const double angle);
double getCameraAngulation() const;
void setArduinoDevice(std::shared_ptr<VRPNArduinoDeviceClient> aClient);
void recalibrate();
protected:
///
/// \brief
///
void runModule() override;
double m_cameraHeadAngleOffset = 0; ///< camera head angle offset (in deg)
double m_cameraAngulation = 0; ///the actual angulation!!! 0, 30, 45 deg
Quatd m_cameraAngulationRotOffset = Quatd::Identity(); ///< Rotation offset for the camera via telescope angulation
std::shared_ptr<VRPNArduinoDeviceClient> arduinoClient;
bool arduinoActive = false;
bool calibrated = false;
double m_rollOffset = 0;
};
} // imstk
#endif // ifndef imstkFLSCameraController_h
\ No newline at end of file
Markdown is supported
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