Apollo 10.0
自动驾驶开放平台
pose.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
17
18#include "cyber/common/log.h"
19
20namespace apollo {
21namespace perception {
22namespace camera {
23
24bool CarPose::Init(double ts, const Eigen::Matrix4d &pose) {
25 timestamp_ = ts;
26 pose_ = pose;
27 return true;
28}
29
30const Eigen::Matrix4d CarPose::getCarPose() const { return pose_; }
31
32const Eigen::Vector3d CarPose::getCarPosition() const {
33 Eigen::Vector3d p;
34 p[0] = pose_(0, 3);
35 p[1] = pose_(1, 3);
36 p[2] = pose_(2, 3);
37
38 return p;
39}
40
41void CarPose::SetCameraPose(const std::string &camera_name,
42 const Eigen::Matrix4d &c2w_pose) {
43 c2w_poses_[camera_name] = c2w_pose;
44}
45
46bool CarPose::GetCameraPose(const std::string &camera_name,
47 Eigen::Matrix4d *c2w_pose) const {
48 if (c2w_pose == nullptr) {
49 AERROR << "c2w_pose is not available";
50 return false;
51 }
52 if (c2w_poses_.find(camera_name) == c2w_poses_.end()) {
53 return false;
54 }
55 *c2w_pose = c2w_poses_.at(camera_name);
56
57 return true;
58}
59
60std::ostream &operator<<(std::ostream &os, const CarPose &pose) {
61 os << pose.pose_;
62 return os;
63}
64void CarPose::ClearCameraPose(const std::string &camera_name) {
65 auto it = c2w_poses_.find(camera_name);
66 if (it != c2w_poses_.end()) {
67 c2w_poses_.erase(it);
68 }
69}
70
71} // namespace camera
72} // namespace perception
73} // namespace apollo
const Eigen::Vector3d getCarPosition() const
Definition pose.cc:32
bool GetCameraPose(const std::string &camera_name, Eigen::Matrix4d *c2w_pose) const
Definition pose.cc:46
EigenMap< std::string, Eigen::Matrix4d > c2w_poses_
Definition pose.h:57
const Eigen::Matrix4d getCarPose() const
Definition pose.cc:30
void SetCameraPose(const std::string &camera_name, const Eigen::Matrix4d &c2w_pose)
Definition pose.cc:41
void ClearCameraPose(const std::string &camera_name)
Definition pose.cc:64
bool Init(double ts, const Eigen::Matrix4d &pose)
Definition pose.cc:24
#define AERROR
Definition log.h:44
std::ostream & operator<<(std::ostream &os, const CarPose &pose)
Definition pose.cc:60
class register implement
Definition arena_queue.h:37