Skip to content

Commit f9b60c2

Browse files
clssncassava
authored andcommitted
minimator: Provide lanes of a straight road
Hard coded to 100m 3 lanes each 4m wide.
1 parent fcb8731 commit f9b60c2

File tree

1 file changed

+60
-1
lines changed

1 file changed

+60
-1
lines changed

plugins/minimator/src/minimator.cpp

+60-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
#include <vector> // for vector<>
5555

5656
#include <cloe/component/ego_sensor.hpp> // for NopEgoSensor
57+
#include <cloe/component/lane_sensor.hpp> // for LaneBoundarySensor
5758
#include <cloe/component/latlong_actuator.hpp> // for LatLongActuator
5859
#include <cloe/component/object_sensor.hpp> // for NopObjectSensor
5960
#include <cloe/handler.hpp> // for ToJson
@@ -133,6 +134,60 @@ struct MinimatorConfiguration : public cloe::Confable {
133134
}
134135
};
135136

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+
136191
/**
137192
* `MinimatorVehicle` is the implementation of a vehicle that comes from
138193
* a `Minimator` simulator.
@@ -202,6 +257,10 @@ class MinimatorVehicle : public cloe::Vehicle {
202257
cloe::CloeComponent::GROUNDTRUTH_WORLD_SENSOR,
203258
cloe::CloeComponent::DEFAULT_WORLD_SENSOR);
204259

260+
this->new_component(new MinimatorLaneSensor(),
261+
cloe::CloeComponent::GROUNDTRUTH_LANE_SENSOR,
262+
cloe::CloeComponent::DEFAULT_LANE_SENSOR);
263+
205264
// The `LatLongActuator` component isn't exactly a dummy component, but we
206265
// won't be reading from it, so writing to it won't do much good.
207266
this->new_component(new cloe::LatLongActuator(), cloe::CloeComponent::DEFAULT_LATLONG_ACTUATOR);
@@ -454,7 +513,7 @@ class MinimatorSimulator : public cloe::Simulator {
454513
}
455514

456515
/**
457-
* Deserialize MinimatorSimulator into JSON.
516+
* Serialize MinimatorSimulator into JSON.
458517
*
459518
* This is required for the `ToJson` handler that is used in the `enroll`
460519
* method.

0 commit comments

Comments
 (0)