19 #include <core/sim/camera.h> 20 #include <core/sim/scene.h> 21 #include <core/sim/drone.h> 22 #include <core/properties.h> 34 PROPERTY(drone_x,
float, 0,
"Drone x coordinate");
35 PROPERTY(drone_y,
float, 0,
"Drone y coordinate");
36 PROPERTY(drone_vx,
float, 0,
"Drone velocity (x component)");
37 PROPERTY(drone_vy,
float, 0,
"Drone velocity (y component)");
38 PROPERTY(drone_dir,
float, 0,
"Heading angle");
39 PROPERTY(target_dist,
float, 0,
"Distance from target");
43 static constexpr
float kWidth = 20;
44 static constexpr
float kHeight = 20;
47 using Seed = std::random_device::result_type;
50 explicit Scene(Seed seed,
const DroneFollow* domain);
52 const SceneVariables* variables()
const override {
return &variables_; }
54 const Config* config()
const override {
return &domain_->config(); }
56 Drone* drone() {
return drone_.get(); }
57 Drone* targetDrone() {
return target_drone_.get(); }
59 const DroneFollow* domain()
const {
return domain_; }
62 float fitness()
const {
return fitness_; }
64 void preStep()
override;
65 void postStep(
float dt)
override;
68 unique_ptr<Drone> createTargetDrone();
69 void createLight(b2Body* body,
const b2Vec2& pos,
const b2Color& color);
71 void createRoundDebris(
const b2Vec2& pos,
float radius);
72 void createBoxDebris(
const b2Vec2& pos,
float width,
float height);
74 void createColumnFixture(b2Body* body,
const b2Vec2& pos,
const b2Color& color);
75 void updateVariables();
76 float targetDistance()
const;
78 void generateTargetPos();
82 unique_ptr<Drone> drone_;
84 default_random_engine rnd_;
85 unique_ptr<Drone> target_drone_;
89 SceneVariables variables_;
90 const DroneFollow* domain_ =
nullptr;
High-level physics scene abstraction.
Definition: scene.h:42
Definition: domain.cpp:27
Raytraced rendering of a 2d world.
Definition: camera.h:39
The foundation for data structures supporting runtime reflection.
Definition: properties.h:388