181 {
182 CHECK_NOTNULL(data_parser_ptr_);
183 CHECK_NOTNULL(rtcm_parser_ptr_);
184 if (!data_parser_ptr_->Init()) {
185 AERROR <<
"Init data parser failed.";
186 return false;
187 }
188 if (!rtcm_parser_ptr_->Init()) {
189 AERROR <<
"Init rtcm parser failed.";
190 return false;
191 }
195 stream_writer_ = node_->CreateWriter<StreamStatus>(FLAGS_stream_status_topic);
196
197 common::util::FillHeader("gnss", &stream_status_);
198 stream_writer_->Write(stream_status_);
199
200
201 Stream *s = nullptr;
202 if (!config_.has_data()) {
203 AINFO <<
"Error: Config file must provide the data stream.";
204 return false;
205 }
207 if (s == nullptr) {
208 AERROR <<
"Failed to create data stream.";
209 return false;
210 }
211 data_stream_.reset(s);
212
214 if (!status) {
215 AERROR <<
"Failed to create data stream status.";
216 return false;
217 }
218 data_stream_status_.reset(status);
219
220 if (config_.has_command()) {
222 if (s == nullptr) {
223 AERROR <<
"Failed to create command stream.";
224 return false;
225 }
226 command_stream_.reset(s);
227
229 if (!status) {
230 AERROR <<
"Failed to create command stream status.";
231 return false;
232 }
233 command_stream_status_.reset(status);
234 } else {
235 command_stream_ = data_stream_;
236 command_stream_status_ = data_stream_status_;
237 }
238
239 if (config_.has_rtk_from()) {
241 if (s == nullptr) {
242 AERROR <<
"Failed to create rtk_from stream.";
243 return false;
244 }
245 in_rtk_stream_.reset(s);
246
247 if (config_.
rtk_from().has_push_location()) {
249 }
250
252 if (!status) {
253 AERROR <<
"Failed to create rtk_from stream status.";
254 return false;
255 }
256 in_rtk_stream_status_.reset(status);
257
258 if (config_.has_rtk_to()) {
260 if (s == nullptr) {
261 AERROR <<
"Failed to create rtk_to stream.";
262 return false;
263 }
264 out_rtk_stream_.reset(s);
265
267 if (!status) {
268 AERROR <<
"Failed to create rtk_to stream status.";
269 return false;
270 }
271 out_rtk_stream_status_.reset(status);
272 } else {
273 out_rtk_stream_ = data_stream_;
274 out_rtk_stream_status_ = data_stream_status_;
275 }
276
277 if (config_.has_rtk_solution_type()) {
280 rtk_software_solution_ = true;
281 }
282 }
283 }
284
286 AWARN <<
"No login_commands in config file.";
287 }
288
290 AWARN <<
"No logout_commands in config file.";
291 }
292
293
294 if (!Connect()) {
295 AERROR <<
"gnss driver connect failed.";
296 return false;
297 }
298
299 if (!Login()) {
300 AERROR <<
"gnss driver login failed.";
301 return false;
302 }
303
305 gpsbin_stream_.reset(new std::ofstream(
306 gpsbin_file, std::ios::app | std::ios::out | std::ios::binary));
307 stream_writer_ = node_->CreateWriter<StreamStatus>(FLAGS_stream_status_topic);
308 raw_writer_ = node_->CreateWriter<RawData>(FLAGS_gnss_raw_data_topic);
309 rtcm_writer_ = node_->CreateWriter<RawData>(FLAGS_rtcm_data_topic);
310 cyber::ReaderConfig reader_config;
311 reader_config.channel_name = FLAGS_gnss_raw_data_topic;
312 reader_config.pending_queue_size = 100;
313 gpsbin_reader_ = node_->CreateReader<RawData>(
314 reader_config, [&](const std::shared_ptr<RawData> &raw_data) {
315 GpsbinCallback(raw_data);
316 });
317 chassis_reader_ = node_->CreateReader<Chassis>(
318 FLAGS_chassis_topic,
319 [&](const std::shared_ptr<Chassis> &chassis) { chassis_ptr_ = chassis; });
320
321 return true;
322}
Stream * create_stream(const config::Stream &sd)
std::string getLocalTimeFileStr(const std::string &gpsbin_folder)
repeated bytes logout_commands
optional RtkSolutionType rtk_solution_type
repeated bytes login_commands
optional string gpsbin_folder
optional bool push_location