Apollo 10.0
自动驾驶开放平台
nav_msg_converter.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2023 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 *****************************************************************************/
16
18#include <cmath>
19
20namespace apollo {
21namespace cyber {
22
26#ifdef ENABLE_ROS_MSG
27 auto ros_nav_ptr = std::get<0>(in.values);
28 auto& ros_nav = (*ros_nav_ptr);
29
30 auto best_pose_msg = std::get<0>(out.values);
31 auto ins_stat_msg = std::get<1>(out.values);
32
33 auto unix_msg_time =
34 ros_nav.header.stamp.sec + ros_nav.header.stamp.nanosec / 1e9;
35 best_pose_msg->mutable_header()->set_timestamp_sec(unix_msg_time);
36 best_pose_msg->mutable_header()->set_module_name("gnss");
37
38 ins_stat_msg->mutable_header()->set_timestamp_sec(unix_msg_time);
39 ins_stat_msg->mutable_header()->set_module_name("gnss");
40
41 best_pose_msg->set_measurement_time(unix_msg_time);
42 best_pose_msg->set_latitude(ros_nav.latitude);
43 best_pose_msg->set_longitude(ros_nav.longitude);
44 best_pose_msg->set_height_msl(ros_nav.altitude);
45 best_pose_msg->set_undulation(0);
46 best_pose_msg->set_datum_id(apollo::drivers::gnss::DatumId::WGS84);
47 best_pose_msg->set_latitude_std_dev(sqrt(ros_nav.position_covariance[4]));
48 best_pose_msg->set_longitude_std_dev(sqrt(ros_nav.position_covariance[0]));
49 best_pose_msg->set_height_std_dev(sqrt(ros_nav.position_covariance[8]));
50 if (ros_nav.status.status == -1) {
51 best_pose_msg->set_sol_status(
53 best_pose_msg->set_sol_type(apollo::drivers::gnss::SolutionType::NONE);
54 ins_stat_msg->set_pos_type(0);
55 } else if (ros_nav.status.status == 0) {
56 best_pose_msg->set_sol_status(
58 best_pose_msg->set_sol_type(apollo::drivers::gnss::SolutionType::SINGLE);
59 ins_stat_msg->set_pos_type(1);
60 } else if (ros_nav.status.status == 1) {
61 best_pose_msg->set_sol_status(
63 best_pose_msg->set_sol_type(apollo::drivers::gnss::SolutionType::WAAS);
64 ins_stat_msg->set_pos_type(2);
65 } else if (ros_nav.status.status == 2) {
66 best_pose_msg->set_sol_status(
68 best_pose_msg->set_sol_type(
70 ins_stat_msg->set_pos_type(2);
71 }
72
73#endif
74 return true;
75}
76
77} // namespace cyber
78} // namespace apollo
virtual bool ConvertMsg(InputTypes< RosNavMsgPtr > &, OutputTypes< BestPoseMsgPtr, InsStatMsgPtr > &)
convert the message between ros and apollo
class register implement
Definition arena_queue.h:37
std::tuple< Types... > values
std::tuple< Types... > values