Apollo 10.0
自动驾驶开放平台
raw_stream.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 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
17#pragma once
18
19#include <fstream>
20#include <memory>
21#include <string>
22#include <thread>
23
24#include "cyber/cyber.h"
25
26#include "modules/common_msgs/chassis_msgs/chassis.pb.h"
27#include "modules/drivers/gnss/proto/config.pb.h"
28#include "modules/drivers/gnss/proto/gnss_status.pb.h"
29
33
34namespace apollo {
35namespace drivers {
36namespace gnss {
37
38class RawStream {
39 public:
40 RawStream(const config::Config& config,
41 const std::shared_ptr<apollo::cyber::Node>& node);
42 ~RawStream();
43 bool Init();
44
49
50 void Start();
51
52 private:
53 void DataSpin();
54 void RtkSpin();
55 bool Connect();
56 bool Disconnect();
57 bool Login();
58 bool Logout();
59 void StreamStatusCheck();
60 void PublishRtkData(size_t length);
61 void PushGpgga(size_t length);
62 void GpsbinSpin();
63 void GpsbinCallback(const std::shared_ptr<RawData const>& raw_data);
64 void OnWheelVelocityTimer();
65
66 std::unique_ptr<cyber::Timer> wheel_velocity_timer_ = nullptr;
67 std::shared_ptr<apollo::canbus::Chassis> chassis_ptr_ = nullptr;
68 static constexpr size_t BUFFER_SIZE = 2048;
69 uint8_t buffer_[BUFFER_SIZE] = {0};
70 uint8_t buffer_rtk_[BUFFER_SIZE] = {0};
71
72 std::shared_ptr<Stream> data_stream_;
73 std::shared_ptr<Stream> command_stream_;
74 std::shared_ptr<Stream> in_rtk_stream_;
75 std::shared_ptr<Stream> out_rtk_stream_;
76
77 std::shared_ptr<Status> data_stream_status_;
78 std::shared_ptr<Status> command_stream_status_;
79 std::shared_ptr<Status> in_rtk_stream_status_;
80 std::shared_ptr<Status> out_rtk_stream_status_;
81
82 bool rtk_software_solution_ = false;
83 bool push_location_ = false;
84 bool is_healthy_ = true;
85 config::Config config_;
86
87 const std::string raw_data_topic_;
88 const std::string rtcm_data_topic_;
89
90 StreamStatus stream_status_;
91 std::unique_ptr<std::thread> data_thread_ptr_;
92 std::unique_ptr<std::thread> rtk_thread_ptr_;
93 std::unique_ptr<DataParser> data_parser_ptr_;
94 std::unique_ptr<RtcmParser> rtcm_parser_ptr_;
95 std::unique_ptr<std::thread> gpsbin_thread_ptr_;
96 std::unique_ptr<std::ofstream> gpsbin_stream_ = nullptr;
97
98 std::shared_ptr<apollo::cyber::Node> node_ = nullptr;
99 std::shared_ptr<apollo::cyber::Writer<StreamStatus>> stream_writer_ = nullptr;
100 std::shared_ptr<apollo::cyber::Writer<RawData>> raw_writer_ = nullptr;
101 std::shared_ptr<apollo::cyber::Writer<RawData>> rtcm_writer_ = nullptr;
102 std::shared_ptr<apollo::cyber::Reader<RawData>> gpsbin_reader_ = nullptr;
103 std::shared_ptr<apollo::cyber::Reader<apollo::canbus::Chassis>>
104 chassis_reader_ = nullptr;
105};
106
107} // namespace gnss
108} // namespace drivers
109} // namespace apollo
static constexpr size_t NUM_STATUS
Definition stream.h:67
constexpr size_t BUFFER_SIZE
class register implement
Definition arena_queue.h:37
bool filter[Stream::NUM_STATUS]
Definition raw_stream.h:46