Apollo 10.0
自动驾驶开放平台
teleop.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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 <boost/thread/locks.hpp>
20#include <boost/thread/shared_mutex.hpp>
21
22#include "cyber/cyber.h"
23#include "nlohmann/json.hpp"
24
25#if WITH_TELEOP == 1
26#include "modules/common_msgs/planning_msgs/pad_msg.pb.h"
27#include "modules/common_msgs/planning_msgs/planning.pb.h"
28#include "modules/teleop/daemon/proto/daemon_cmd.pb.h"
29#include "modules/teleop/daemon/proto/daemon_rpt.pb.h"
30#include "modules/teleop/modem/proto/modem_info.pb.h"
31#endif
32
34
35namespace apollo {
36namespace dreamview {
37
39 public:
41
42 void Start();
43
44 private:
45 void RegisterMessageHandlers();
46 void SendStatus(WebSocketHandler::Connection *conn);
47
48#if WITH_TELEOP == 1
49 // send a command to the remote daemon to start or stop
50 // video encoders and voip encoders
51 void SendAudioStreamCmd(bool start_stop);
52 void SendMicStreamCmd(bool start_stop);
53 void SendVideoStreamCmd(bool start_stop);
54 // planner commands
55 void SendEstopCmd();
56 void SendPullOverCmd();
57 void SendResumeCruiseCmd();
58
59 void UpdateModemInfo(
60 const std::shared_ptr<modules::teleop::modem::ModemInfo> &modem_info);
61#endif
62
63 std::unique_ptr<cyber::Node> node_;
64
65 WebSocketHandler *websocket_;
66
67#if WITH_TELEOP == 1
68 // modem info readers and callback
69 std::shared_ptr<cyber::Reader<modules::teleop::modem::ModemInfo>>
70 modem0_info_reader_;
71 std::shared_ptr<cyber::Reader<modules::teleop::modem::ModemInfo>>
72 modem1_info_reader_;
73 std::shared_ptr<cyber::Reader<modules::teleop::modem::ModemInfo>>
74 modem2_info_reader_;
75 // modem info callback
76 void UpdateModem(
77 const std::string &modem_id,
78 const std::shared_ptr<modules::teleop::modem::ModemInfo> &modem_info);
79 // planning message reader
80 std::shared_ptr<cyber::Reader<apollo::planning::ADCTrajectory>>
81 planning_reader_;
82
83 // daemon report readers and callback
84 void UpdateCarDaemonRpt(
85 const std::shared_ptr<modules::teleop::daemon::DaemonRpt> &rpt);
86 void UpdateOperatorDaemonRpt(
87 const std::shared_ptr<modules::teleop::daemon::DaemonRpt> &rpt);
88 std::shared_ptr<cyber::Reader<modules::teleop::daemon::DaemonRpt>>
89 remote_daemon_rpt_reader_;
90 std::shared_ptr<cyber::Reader<modules::teleop::daemon::DaemonRpt>>
91 local_daemon_rpt_reader_;
92 // daemon commands writers
93 std::shared_ptr<cyber::Writer<modules::teleop::daemon::DaemonCmd>>
94 remote_daemon_cmd_writer_;
95 std::shared_ptr<cyber::Writer<modules::teleop::daemon::DaemonCmd>>
96 local_daemon_cmd_writer_;
97
98 // planning driving actions and feedback
99 std::shared_ptr<
102 action_command_client_;
103 void UpdatePlanning(
104 const std::shared_ptr<apollo::planning::ADCTrajectory> &msg);
105#endif
106
107 // Store teleop status
108 nlohmann::json teleop_status_;
109
110 // Mutex to protect concurrent access to teleop_status_.
111 // NOTE: Use boost until we upgrade to std version with rwlock support.
112 boost::shared_mutex mutex_;
113};
114
115} // namespace dreamview
116} // namespace apollo
Client get Response from a responding Service by sending a Request
Definition client.h:47
The WebSocketHandler, built on top of CivetWebSocketHandler, is a websocket handler that handles diff...
class register implement
Definition arena_queue.h:37