|
54 | 54 | #include <vector> // for vector<>
|
55 | 55 |
|
56 | 56 | #include <cloe/component/ego_sensor.hpp> // for NopEgoSensor
|
| 57 | +#include <cloe/component/lane_sensor.hpp> // for LaneBoundarySensor |
57 | 58 | #include <cloe/component/latlong_actuator.hpp> // for LatLongActuator
|
58 | 59 | #include <cloe/component/object_sensor.hpp> // for NopObjectSensor
|
59 | 60 | #include <cloe/handler.hpp> // for ToJson
|
@@ -133,6 +134,60 @@ struct MinimatorConfiguration : public cloe::Confable {
|
133 | 134 | }
|
134 | 135 | };
|
135 | 136 |
|
| 137 | +/** |
| 138 | + * MinimatorLaneSensor is a very static lane boundary sensor. |
| 139 | + * |
| 140 | + * It returns the 4 lane boundaries of a 3-lane 4m lane-width road of a total |
| 141 | + * length of 100m. The road is laterally centered at the origin. |
| 142 | + */ |
| 143 | +class MinimatorLaneSensor : public cloe::LaneBoundarySensor { |
| 144 | + public: |
| 145 | + MinimatorLaneSensor() : cloe::LaneBoundarySensor("minimator_lane_sensor") { |
| 146 | + const int n = 4; |
| 147 | + const double w = 4.0; |
| 148 | + const double l = 100.0; |
| 149 | + for (int i = 0; i != n; ++i) { |
| 150 | + cloe::LaneBoundary lb; |
| 151 | + lb.id = i; |
| 152 | + lb.prev_id = -1; |
| 153 | + lb.next_id = -1; |
| 154 | + lb.dx_start = 0; |
| 155 | + lb.dy_start = (n - 1) * w / 2.0 - w * i; |
| 156 | + lb.heading_start = 0.0; |
| 157 | + lb.curv_hor_start = 0.0; |
| 158 | + lb.curv_hor_change = 0.0; |
| 159 | + lb.dx_end = l; |
| 160 | + lb.type = i % (n - 1) ? cloe::LaneBoundary::Type::Dashed : cloe::LaneBoundary::Type::Solid; |
| 161 | + lb.color = cloe::LaneBoundary::Color::White; |
| 162 | + lb.points.push_back(Eigen::Vector3d(lb.dx_start, lb.dy_start, 0)); |
| 163 | + lb.points.push_back(Eigen::Vector3d(lb.dx_end, lb.dy_start, 0)); |
| 164 | + lane_boundaries_[i] = lb; |
| 165 | + } |
| 166 | + mount_pose_.setIdentity(); |
| 167 | + } |
| 168 | + virtual ~MinimatorLaneSensor() = default; |
| 169 | + |
| 170 | + /** |
| 171 | + * Return the static set of lane boundaries. |
| 172 | + */ |
| 173 | + const cloe::LaneBoundaries& sensed_lane_boundaries() const override { return lane_boundaries_; } |
| 174 | + |
| 175 | + /** |
| 176 | + * Return the frustum of the lane sensor. |
| 177 | + */ |
| 178 | + const cloe::Frustum& frustum() const override { return frustum_; } |
| 179 | + |
| 180 | + /** |
| 181 | + * Return the mounting position of the lane sensor. |
| 182 | + */ |
| 183 | + const Eigen::Isometry3d& mount_pose() const override { return mount_pose_; } |
| 184 | + |
| 185 | + private: |
| 186 | + cloe::LaneBoundaries lane_boundaries_; |
| 187 | + cloe::Frustum frustum_; |
| 188 | + Eigen::Isometry3d mount_pose_; |
| 189 | +}; |
| 190 | + |
136 | 191 | /**
|
137 | 192 | * `MinimatorVehicle` is the implementation of a vehicle that comes from
|
138 | 193 | * a `Minimator` simulator.
|
@@ -202,6 +257,10 @@ class MinimatorVehicle : public cloe::Vehicle {
|
202 | 257 | cloe::CloeComponent::GROUNDTRUTH_WORLD_SENSOR,
|
203 | 258 | cloe::CloeComponent::DEFAULT_WORLD_SENSOR);
|
204 | 259 |
|
| 260 | + this->new_component(new MinimatorLaneSensor(), |
| 261 | + cloe::CloeComponent::GROUNDTRUTH_LANE_SENSOR, |
| 262 | + cloe::CloeComponent::DEFAULT_LANE_SENSOR); |
| 263 | + |
205 | 264 | // The `LatLongActuator` component isn't exactly a dummy component, but we
|
206 | 265 | // won't be reading from it, so writing to it won't do much good.
|
207 | 266 | this->new_component(new cloe::LatLongActuator(), cloe::CloeComponent::DEFAULT_LATLONG_ACTUATOR);
|
@@ -454,7 +513,7 @@ class MinimatorSimulator : public cloe::Simulator {
|
454 | 513 | }
|
455 | 514 |
|
456 | 515 | /**
|
457 |
| - * Deserialize MinimatorSimulator into JSON. |
| 516 | + * Serialize MinimatorSimulator into JSON. |
458 | 517 | *
|
459 | 518 | * This is required for the `ToJson` handler that is used in the `enroll`
|
460 | 519 | * method.
|
|
0 commit comments