Program Listing for File ncamera.h

Return to documentation for file (aslam_cv2/aslam_cv_cameras/include/aslam/cameras/ncamera.h)

#ifndef ASLAM_NCAMERA_H_
#define ASLAM_NCAMERA_H_

#include <memory>
#include <string>
#include <unordered_map>
#include <vector>

#include <aslam/common/macros.h>
#include <aslam/common/pose-types.h>
#include <aslam/common/sensor.h>
#include <aslam/common/unique-id.h>
#include <gtest/gtest_prod.h>

namespace sm {
class PropertyTree;
}
namespace aslam {
class Camera;
}

namespace aslam {

class NCamera : public Sensor {
 public:
  ASLAM_POINTER_TYPEDEFS(NCamera);
  enum { CLASS_SERIALIZATION_VERSION = 1 };
  EIGEN_MAKE_ALIGNED_OPERATOR_NEW

  // protected:
  NCamera();

  // public:
  NCamera(
      const NCameraId& id, const TransformationVector& T_C_B,
      const std::vector<std::shared_ptr<Camera>>& cameras,
      const std::string& description);

  // public:
  NCamera(
      const NCameraId& id, const TransformationVector& T_C_B,
      const aslam::TransformationCovariance&
          T_G_B_fixed_localization_covariance,
      const std::vector<std::shared_ptr<Camera>>& cameras,
      const std::string& description);

  NCamera(const sm::PropertyTree& propertyTree);
  virtual ~NCamera() = default;

  NCamera(const NCamera&);
  void operator=(const NCamera&) = delete;

  NCamera* clone() const;
  NCamera* cloneWithNewIds() const;

  NCamera::Ptr cloneToShared() const {
    return aligned_shared<NCamera>(*this);
  }

  Sensor::Ptr cloneAsSensor() const override {
    return std::dynamic_pointer_cast<Sensor>(cloneToShared());
  }

  uint8_t getSensorType() const override {
    return SensorType::kNCamera;
  }

  std::string getSensorTypeString() const override {
    return static_cast<std::string>(kNCameraIdentifier);
  }

  size_t getNumCameras() const;

  const Transformation& get_T_C_B(size_t camera_index) const;

  Transformation& get_T_C_B_Mutable(size_t camera_index);

  const Transformation& get_T_C_B(const CameraId& camera_id) const;

  Transformation& get_T_C_B_Mutable(const CameraId& camera_id);

  void set_T_C_B(size_t camera_index, const Transformation& T_Ci_B);

  const TransformationVector& getTransformationVector() const;

  const Camera& getCamera(size_t camera_index) const;

  Camera& getCameraMutable(size_t camera_index);

  std::shared_ptr<Camera> getCameraShared(size_t camera_index);

  std::shared_ptr<const Camera> getCameraShared(size_t camera_index) const;

  void setCamera(size_t camera_index, std::shared_ptr<Camera> camera);

  size_t numCameras() const;

  const std::vector<std::shared_ptr<Camera>>& getCameraVector() const;

  const CameraId& getCameraId(size_t camera_index) const;

  bool hasCameraWithId(const CameraId& id) const;

  bool has_T_G_B_fixed_localization_covariance() const;

  // Get the 6DoF localization covariance matrix
  bool get_T_G_B_fixed_localization_covariance(
      aslam::TransformationCovariance* covariance) const;

  // Set the 6Dof localization covariance matrix
  void set_T_G_B_fixed_localization_covariance(
      const aslam::TransformationCovariance& covariance);

  int getCameraIndex(const CameraId& id) const;

  aslam::NCamera::Ptr cloneRigWithoutDistortion() const;

 private:
  bool isValidImpl() const override;

  void setRandomImpl() override;

  bool isEqualImpl(const Sensor& other, const bool verbose) const override;

  bool loadFromYamlNodeImpl(const YAML::Node&) override;
  void saveToYamlNodeImpl(YAML::Node*) const override;

  void initInternal();

  TransformationVector T_C_B_;

  std::vector<std::shared_ptr<Camera>> cameras_;

  std::unordered_map<CameraId, size_t> id_to_index_;

  TransformationCovariance T_G_B_fixed_localization_covariance_;
  bool has_T_G_B_fixed_localization_covariance_;
};

}  // namespace aslam

#endif /* ASLAM_NCAMERA_H_ */