Apollo  6.0
Open source self driving car software
ultrasonic_radar_canbus.h
Go to the documentation of this file.
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  *****************************************************************************/
16 
21 #pragma once
22 
23 #include <memory>
24 #include <string>
25 #include <utility>
26 #include <vector>
27 
28 #include "cyber/common/macros.h"
29 
30 #include "cyber/time/time.h"
38 #include "modules/drivers/canbus/proto/can_card_parameter.pb.h"
39 #include "modules/drivers/canbus/proto/sensor_canbus_conf.pb.h"
41 #include "modules/drivers/proto/ultrasonic_radar.pb.h"
42 #include "modules/drivers/radar/ultrasonic_radar/proto/ultrasonic_radar_conf.pb.h"
44 
49 namespace apollo {
50 namespace drivers {
51 namespace ultrasonic_radar {
52 
60 using apollo::common::ErrorCode;
62 using apollo::common::monitor::MonitorMessageItem;
68 using apollo::drivers::canbus::SensorCanbusConf;
69 
71  public:
74 
79  std::string Name() const;
80 
86  const std::string& config_path,
87  const std::shared_ptr<::apollo::cyber::Writer<Ultrasonic>>& writer);
88 
94 
95  private:
96  Status OnError(const std::string& error_msg);
97  void RegisterCanClients();
98 
99  UltrasonicRadarConf ultrasonic_radar_conf_;
100  std::shared_ptr<CanClient> can_client_;
101  CanReceiver<Ultrasonic> can_receiver_;
102  std::unique_ptr<UltrasonicRadarMessageManager> sensor_message_manager_;
103 
104  int64_t last_timestamp_ = 0;
105  apollo::common::monitor::MonitorLogBuffer monitor_logger_buffer_;
106 };
107 
108 } // namespace ultrasonic_radar
109 } // namespace drivers
110 } // namespace apollo
::apollo::cyber::Time Time
Definition: racobit_radar_message_manager.h:41
CanClientFactory inherites apollo::common::util::Factory.
Definition: can_client_factory.h:44
apollo::common::Status Init(const std::string &config_path, const std::shared_ptr<::apollo::cyber::Writer< Ultrasonic >> &writer)
module initialization function
std::string Name() const
obtain module name
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Defines the CanFrame struct and CanClient interface.
The class which defines the CAN client to send and receive message.
Definition: can_client.h:92
The class of MessageManager.
The class of UltrasonicRadarMessageManager.
Definition: writer.h:42
Defines SenderMessage class and CanSender class.
template of canbus-based sensor module main class (e.g., ultrasonic_radar).
Definition: ultrasonic_radar_canbus.h:70
Defines CanReceiver class.
The class of MonitorLogBuffer.
This class defines the message to send.
Definition: can_sender.h:55
A general class to denote the return status of an API call. It can either be an OK status for success...
Definition: status.h:43
Defines the CanClientFactory class.
apollo::common::Status Start()
module start function
This class help collect MonitorMessage pb to monitor topic. The messages can be published automatical...
Definition: monitor_log_buffer.h:60
CAN receiver.
Definition: can_receiver.h:55