CARLA
Loading...
Searching...
No Matches
CachedSimpleWaypoint.h
Go to the documentation of this file.
1// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8
9#include <fstream>
10
12
13namespace carla {
14namespace traffic_manager {
15
16 using SimpleWaypointPtr = std::shared_ptr<SimpleWaypoint>;
17
19 public:
20 uint64_t waypoint_id;
21 uint32_t road_id;
22 uint32_t section_id;
23 int32_t lane_id;
24 float s;
25 std::vector<uint64_t> next_waypoints;
26 std::vector<uint64_t> previous_waypoints;
27 uint64_t next_left_waypoint = 0;
28 uint64_t next_right_waypoint = 0;
31 uint8_t road_option;
32
34 CachedSimpleWaypoint(const SimpleWaypointPtr& simple_waypoint);
35
36 void Read(const std::vector<uint8_t>& content, unsigned long& start);
37
38 /// Bytes of a record with empty next/previous lists: id (8), road/section/lane/s
39 /// (16), two u16 list sizes (4), left/right ids (16), grid id (4), junction (1),
40 /// road option (1). Lets InMemoryMap::Load bounds-check a cache before reading it.
41 static constexpr unsigned long MinimumSize() { return 50; }
42
43 void Read(std::ifstream &in_file);
44 void Write(std::ofstream &out_file);
45
46 private:
47 template <typename T>
48 void WriteValue(std::ofstream &out_file, const T &in_obj) {
49 out_file.write(reinterpret_cast<const char *>(&in_obj), sizeof(T));
50 }
51 template <typename T>
52 void ReadValue(std::ifstream &in_file, T &out_obj) {
53 in_file.read(reinterpret_cast<char *>(&out_obj), sizeof(T));
54 }
55 template <typename T>
56 void ReadValue(const std::vector<uint8_t>& content, unsigned long& start, T &out_obj) {
57 memcpy(&out_obj, &content[start], sizeof(T));
58 start += sizeof(T);
59 }
60 };
61
62} // namespace traffic_manager
63} // namespace carla
void ReadValue(std::ifstream &in_file, T &out_obj)
static constexpr unsigned long MinimumSize()
Bytes of a record with empty next/previous lists: id (8), road/section/lane/s (16),...
void ReadValue(const std::vector< uint8_t > &content, unsigned long &start, T &out_obj)
void Read(const std::vector< uint8_t > &content, unsigned long &start)
void WriteValue(std::ofstream &out_file, const T &in_obj)
std::shared_ptr< SimpleWaypoint > SimpleWaypointPtr
This file contains definitions of common data structures used in traffic manager.