|
| 1 | +# RTC Interface |
| 2 | + |
| 3 | +## Purpose |
| 4 | + |
| 5 | +RTC Interface is an interface to publish the decision status of behavior planning modules and receive execution command from external of an autonomous driving system. |
| 6 | + |
| 7 | +## Inner-workings / Algorithms |
| 8 | + |
| 9 | +### Usage example |
| 10 | + |
| 11 | +```c++ |
| 12 | +// Generate instance (in this example, "intersection" is selected) |
| 13 | +rtc_interface::RTCInterface rtc_interface(node, "intersection"); |
| 14 | + |
| 15 | +// Generate UUID |
| 16 | +const unique_identifier_msgs::msg::UUID uuid = generateUUID(getModuleId()); |
| 17 | + |
| 18 | +// Repeat while module is running |
| 19 | +while (...) { |
| 20 | + // Get safety status of the module corresponding to the module id |
| 21 | + const bool safe = ... |
| 22 | + |
| 23 | + // Get distance to the object corresponding to the module id |
| 24 | + const double distance = ... |
| 25 | + |
| 26 | + // Get time stamp |
| 27 | + const rclcpp::Time stamp = ... |
| 28 | + |
| 29 | + // Update status |
| 30 | + rtc_interface.updateCooperateStatus(uuid, safe, distance, stamp); |
| 31 | + |
| 32 | + if (rtc_interface.isActivated(uuid)) { |
| 33 | + // Execute planning |
| 34 | + } else { |
| 35 | + // Stop planning |
| 36 | + } |
| 37 | + // Get time stamp |
| 38 | + const rclcpp::Time stamp = ... |
| 39 | + |
| 40 | + // Publish status topic |
| 41 | + rtc_interface.publishCooperateStatus(stamp); |
| 42 | +} |
| 43 | + |
| 44 | +// Remove the status from array |
| 45 | +rtc_interface.removeCooperateStatus(uuid); |
| 46 | +``` |
| 47 | +
|
| 48 | +## Inputs / Outputs |
| 49 | +
|
| 50 | +### RTCInterface (Constructor) |
| 51 | +
|
| 52 | +```c++ |
| 53 | +rtc_interface::RTCInterface(rclcpp::Node & node, const std::string & name); |
| 54 | +``` |
| 55 | + |
| 56 | +#### Description |
| 57 | + |
| 58 | +A constructor for `rtc_interface::RTCInterface`. |
| 59 | + |
| 60 | +#### Input |
| 61 | + |
| 62 | +- `node` : Node calling this interface |
| 63 | +- `name` : Name of cooperate status array topic and cooperate commands service |
| 64 | + - Cooperate status array topic name : `~/{name}/cooperate_status` |
| 65 | + - Cooperate commands service name : `~/{name}/cooperate_commands` |
| 66 | + |
| 67 | +#### Output |
| 68 | + |
| 69 | +An instance of `RTCInterface` |
| 70 | + |
| 71 | +### publishCooperateStatus |
| 72 | + |
| 73 | +```c++ |
| 74 | +rtc_interface::publishCooperateStatus(const rclcpp::Time & stamp) |
| 75 | +``` |
| 76 | +
|
| 77 | +#### Description |
| 78 | +
|
| 79 | +Publish registered cooperate status. |
| 80 | +
|
| 81 | +#### Input |
| 82 | +
|
| 83 | +- `stamp` : Time stamp |
| 84 | +
|
| 85 | +#### Output |
| 86 | +
|
| 87 | +Nothing |
| 88 | +
|
| 89 | +### updateCooperateStatus |
| 90 | +
|
| 91 | +```c++ |
| 92 | +rtc_interface::updateCooperateStatus(const unique_identifier_msgs::msg::UUID & uuid, const bool safe, const double distance, const rclcpp::Time & stamp) |
| 93 | +``` |
| 94 | + |
| 95 | +#### Description |
| 96 | + |
| 97 | +Update cooperate status corresponding to `uuid`. |
| 98 | +If cooperate status corresponding to `uuid` is not registered yet, add new cooperate status. |
| 99 | + |
| 100 | +#### Input |
| 101 | + |
| 102 | +- `uuid` : UUID for requesting module |
| 103 | +- `safe` : Safety status of requesting module |
| 104 | +- `distance` : Distance to the object from ego vehicle |
| 105 | +- `stamp` : Time stamp |
| 106 | + |
| 107 | +#### Output |
| 108 | + |
| 109 | +Nothing |
| 110 | + |
| 111 | +### removeCooperateStatus |
| 112 | + |
| 113 | +```c++ |
| 114 | +rtc_interface::removeCooperateStatus(const unique_identifier_msgs::msg::UUID & uuid) |
| 115 | +``` |
| 116 | +
|
| 117 | +#### Description |
| 118 | +
|
| 119 | +Remove cooperate status corresponding to `uuid` from registered statuses. |
| 120 | +
|
| 121 | +#### Input |
| 122 | +
|
| 123 | +- `uuid` : UUID for expired module |
| 124 | +
|
| 125 | +#### Output |
| 126 | +
|
| 127 | +Nothing |
| 128 | +
|
| 129 | +### clearCooperateStatus |
| 130 | +
|
| 131 | +```c++ |
| 132 | +rtc_interface::clearCooperateStatus() |
| 133 | +``` |
| 134 | + |
| 135 | +#### Description |
| 136 | + |
| 137 | +Remove all cooperate statuses. |
| 138 | + |
| 139 | +#### Input |
| 140 | + |
| 141 | +Nothing |
| 142 | + |
| 143 | +#### Output |
| 144 | + |
| 145 | +Nothing |
| 146 | + |
| 147 | +### isActivated |
| 148 | + |
| 149 | +```c++ |
| 150 | +rtc_interface::isActivated(const unique_identifier_msgs::msg::UUID & uuid) |
| 151 | +``` |
| 152 | +
|
| 153 | +#### Description |
| 154 | +
|
| 155 | +Return received command status corresponding to `uuid`. |
| 156 | +
|
| 157 | +#### Input |
| 158 | +
|
| 159 | +- `uuid` : UUID for checking module |
| 160 | +
|
| 161 | +#### Output |
| 162 | +
|
| 163 | +If received command is `ACTIVATED`, return `true`. |
| 164 | +If not, return `false`. |
| 165 | +
|
| 166 | +### isRegistered |
| 167 | +
|
| 168 | +```c++ |
| 169 | +rtc_interface::isRegistered(const unique_identifier_msgs::msg::UUID & uuid) |
| 170 | +``` |
| 171 | + |
| 172 | +#### Description |
| 173 | + |
| 174 | +Return `true` if `uuid` is registered. |
| 175 | + |
| 176 | +#### Input |
| 177 | + |
| 178 | +- `uuid` : UUID for checking module |
| 179 | + |
| 180 | +#### Output |
| 181 | + |
| 182 | +If `uuid` is registered, return `true`. |
| 183 | +If not, return `false`. |
| 184 | + |
| 185 | +## Assumptions / Known limits |
| 186 | + |
| 187 | +## Future extensions / Unimplemented parts |
0 commit comments