Skip to content

Commit 22fb91f

Browse files
committed
models: Use fable namespace for fable types
1 parent baa35ee commit 22fb91f

21 files changed

+107
-90
lines changed

models/include/cloe/component/actuator.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Actuator : public Component {
3838
virtual bool is_set() { return static_cast<bool>(target_); }
3939
virtual T get() { return *target_; }
4040

41-
Json active_state() const override { return Json{{"target", target_}}; }
41+
fable::Json active_state() const override { return fable::Json{{"target", target_}}; }
4242

4343
Duration process(const Sync& sync) override {
4444
auto t = Component::process(sync);

models/include/cloe/component/brake_sensor.hpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121

2222
#pragma once
2323

24-
#include <cloe/component.hpp> // for Component, Json
24+
#include <cloe/component.hpp> // for Component
25+
#include <fable/json.hpp> // for Json
2526

2627
namespace cloe {
2728

@@ -33,16 +34,16 @@ class BrakeSensor : public Component {
3334

3435
/**
3536
* Return the position of the brake pedal with no unit.
36-
*
37+
*
3738
* The range goes from 0 (unpressed) to 1 (fully pressed).
3839
*/
3940
virtual double pedal_position_brake() const = 0;
4041

4142
/**
4243
* Return sensor state as JSON.
4344
*/
44-
Json active_state() const override {
45-
return Json{{"pedal_position_brake", pedal_position_brake()}};
45+
fable::Json active_state() const override {
46+
return fable::Json{{"pedal_position_brake", pedal_position_brake()}};
4647
}
4748
};
4849

models/include/cloe/component/driver_request.hpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121

2222
#pragma once
2323

24-
#include <cloe/component.hpp> // for Component, Json
24+
#include <fable/json.hpp> // for Json
2525
#include <fable/utility/boost_optional.hpp>
2626

27+
#include <cloe/component.hpp> // for Component
28+
2729
namespace cloe {
2830

2931
class DriverRequest : public Component {
@@ -55,8 +57,8 @@ class DriverRequest : public Component {
5557
/**
5658
* Return sensor state as JSON.
5759
*/
58-
Json active_state() const override {
59-
return Json{
60+
fable::Json active_state() const override {
61+
return fable::Json{
6062
{"acceleration", acceleration()},
6163
{"steering_angle", steering_angle()},
6264
};

models/include/cloe/component/ego_sensor.hpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121

2222
#pragma once
2323

24-
#include <cloe/component.hpp> // for Component, Json
24+
#include <cloe/component.hpp> // for Component
2525
#include <cloe/component/object.hpp> // for Object
2626

27+
#include <fable/json.hpp> // for Json
28+
2729
namespace cloe {
2830

2931
class EgoSensor : public Component {
@@ -58,8 +60,8 @@ class EgoSensor : public Component {
5860
/**
5961
* Return sensor state as JSON.
6062
*/
61-
Json active_state() const override {
62-
return Json{
63+
fable::Json active_state() const override {
64+
return fable::Json{
6365
{"sensed_state", this->sensed_state()},
6466
{"wheel_steering_angle", this->wheel_steering_angle()},
6567
};

models/include/cloe/component/frustum.hpp

+9-7
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323

2424
#include <cmath> // for M_PI
2525

26-
#include <cloe/core.hpp> // for Confable
26+
#include <fable/confable.hpp> // for Confable
27+
#include <fable/json.hpp> // for Json
28+
#include <fable/schema.hpp> // for Schema, Struct, make_schema
2729

2830
#define M_2X_PI (2 * M_PI)
2931

@@ -32,22 +34,22 @@ namespace cloe {
3234
/**
3335
* This class describes the frustum of a sensor.
3436
*/
35-
struct Frustum : public Confable {
37+
struct Frustum : public fable::Confable {
3638
double fov_h{M_2X_PI};
3739
double offset_h{0.0};
3840
double fov_v{M_2X_PI};
3941
double offset_v{0.0};
4042
double clip_near{0.0};
4143
double clip_far{480.0};
4244

43-
void to_json(Json& j) const override {
44-
j = Json{
45+
void to_json(fable::Json& j) const override {
46+
j = fable::Json{
4547
{"fov_h", fov_h}, {"offset_h", offset_h}, {"fov_v", fov_v},
4648
{"offset_v", offset_v}, {"clip_near", clip_near}, {"clip_far", clip_far},
4749
};
4850
}
4951

50-
void from_conf(const Conf& c) override {
52+
void from_conf(const fable::Conf& c) override {
5153
assert(clip_near < clip_far);
5254
Confable::from_conf(c);
5355
if (clip_near >= clip_far) {
@@ -57,9 +59,9 @@ struct Frustum : public Confable {
5759
}
5860

5961
protected:
60-
Schema schema_impl() override {
62+
fable::Schema schema_impl() override {
6163
// clang-format off
62-
using namespace schema; // NOLINT
64+
using namespace fable::schema; // NOLINT
6365
return Struct{
6466
{"fov_h", make_schema(&fov_h, "horizontal field of view [rad]").bounds(0, M_2X_PI)},
6567
{"offset_h", make_schema(&offset_h, "horizontal field-of-view offset [rad]").bounds(-M_2X_PI, M_2X_PI)},

models/include/cloe/component/gearbox_actuator.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
namespace cloe {
2828

2929
struct GearboxRequest {
30-
/*
31-
* Holds the requested gear selector position.
30+
/*
31+
* Holds the requested gear selector position.
3232
*
3333
* The sign of this field is linked to the mode of the gear
3434
* - positive: driving forward (e.g. a value of 3 means to request the third gear in driving forward mode)
@@ -38,8 +38,8 @@ struct GearboxRequest {
3838
*/
3939
int8_t gear_selector{0};
4040

41-
friend void to_json(Json& j, const GearboxRequest& g) {
42-
j = Json{{"gear_selector", g.gear_selector}};
41+
friend void to_json(fable::Json& j, const GearboxRequest& g) {
42+
j = fable::Json{{"gear_selector", g.gear_selector}};
4343
}
4444
};
4545

models/include/cloe/component/lane_boundary.hpp

+11-9
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,31 @@
2727

2828
#include <Eigen/Geometry> // for Vector3d
2929

30-
#include <cloe/core.hpp> // for Confable, Json, Schema
30+
#include <fable/confable.hpp> // for Confable
31+
#include <fable/fable_fwd.hpp> // for Schema
32+
#include <fable/enum.hpp> // for ENUM_SERIALIZATION
3133

3234
namespace cloe {
3335

34-
class LaneBoundary : public Confable {
36+
class LaneBoundary : public fable::Confable {
3537
public:
3638
/**
3739
* Type of lane boundary.
3840
*/
3941
enum class Type { Unknown, Solid, Dashed, Grass, Curb };
40-
friend void to_json(Json& j, const LaneBoundary::Type& t);
41-
friend void from_json(const Json& j, LaneBoundary::Type& t);
42+
friend void to_json(fable::Json& j, const LaneBoundary::Type& t);
43+
friend void from_json(const fable::Json& j, LaneBoundary::Type& t);
4244

4345
/**
4446
* Color of the lane boundary.
4547
*/
4648
enum class Color { Unknown, White, Yellow, Red, Green, Blue };
47-
friend void to_json(Json& j, const LaneBoundary::Color& t);
48-
friend void from_json(const Json& j, LaneBoundary::Color& t);
49+
friend void to_json(fable::Json& j, const LaneBoundary::Color& t);
50+
friend void from_json(const fable::Json& j, LaneBoundary::Color& t);
4951

5052
public:
51-
Schema schema_impl() override;
52-
void to_json(Json& j) const override;
53+
fable::Schema schema_impl() override;
54+
void to_json(fable::Json& j) const override;
5355

5456
CONFABLE_FRIENDS(LaneBoundary)
5557

@@ -71,7 +73,7 @@ class LaneBoundary : public Confable {
7173
};
7274

7375
using LaneBoundaries = std::map<int, LaneBoundary>;
74-
void to_json(Json& j, const LaneBoundaries& lbs);
76+
void to_json(fable::Json& j, const LaneBoundaries& lbs);
7577

7678
// clang-format off
7779
ENUM_SERIALIZATION(LaneBoundary::Type, ({

models/include/cloe/component/lane_sensor.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#pragma once
2323

24-
#include <Eigen/Geometry> // for Isometry3d
24+
#include <Eigen/Geometry> // for Isometry3d
2525

2626
#include <cloe/component.hpp> // for Component
2727
#include <cloe/component/frustum.hpp> // for Frustum
@@ -51,8 +51,8 @@ class LaneBoundarySensor : public Component {
5151
*/
5252
virtual const Eigen::Isometry3d& mount_pose() const = 0;
5353

54-
Json active_state() const override {
55-
return Json{
54+
fable::Json active_state() const override {
55+
return fable::Json{
5656
{"mount_pose", this->mount_pose()},
5757
{"frustum", this->frustum()},
5858
{"sensed_lane_boundaries", sensed_lane_boundaries()},

models/include/cloe/component/latlong_actuator.hpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525
#pragma once
2626

2727
#include <boost/optional.hpp> // for optional<>
28+
#include <fable/json.hpp> // for Json
2829
#include <fable/utility/boost_optional.hpp> // for to_json
2930

30-
#include <cloe/component.hpp> // for Component, Json
31+
#include <cloe/component.hpp> // for Component
3132
#include <cloe/component/actuator.hpp> // for Actuator
3233
#include <cloe/utility/actuation_level.hpp> // for ActuationLevel
3334

@@ -86,8 +87,8 @@ class LatLongActuator : public Component {
8687
* Currently, the API is unstable, because we don't have access to any real
8788
* data.
8889
*/
89-
Json active_state() const override {
90-
return Json{
90+
fable::Json active_state() const override {
91+
return fable::Json{
9192
{"target_acceleration", target_acceleration_},
9293
{"target_steering_angle", target_steering_angle_},
9394
{"actuation_label", level_.to_human_cstr()},

models/include/cloe/component/object.hpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
#include <memory> // for shared_ptr<>
2525
#include <vector> // for vector<>
2626

27-
#include <Eigen/Geometry> // for Isometry3d, Vector3d
28-
#include <cloe/core.hpp> // for Json
27+
#include <Eigen/Geometry> // for Isometry3d, Vector3d
28+
#include <fable/enum.hpp> // for ENUM_SERIALIZATION
29+
#include <fable/json.hpp> // for Json
2930
#include <fable/utility/eigen.hpp> // for to_json
3031

3132
namespace cloe {
@@ -82,8 +83,8 @@ struct Object {
8283

8384
Object() = default;
8485

85-
friend void to_json(Json& j, const Object& o) {
86-
j = Json{
86+
friend void to_json(fable::Json& j, const Object& o) {
87+
j = fable::Json{
8788
{"id", o.id},
8889
{"exist_prob", o.exist_prob},
8990
{"type", o.type},
@@ -107,8 +108,8 @@ struct Object {
107108
*/
108109
using Objects = std::vector<std::shared_ptr<Object>>;
109110

110-
inline void to_json(Json& j, const Objects& os) {
111-
j = Json::array();
111+
inline void to_json(fable::Json& j, const Objects& os) {
112+
j = fable::Json::array();
112113
for (const auto& o : os) {
113114
assert(o != nullptr);
114115
j.push_back(*o);

models/include/cloe/component/object_sensor.hpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222

2323
#pragma once
2424

25-
#include <cloe/component.hpp> // for Component, Json
25+
#include <cloe/component.hpp> // for Component
2626
#include <cloe/component/frustum.hpp> // for Frustum
2727
#include <cloe/component/object.hpp> // for Object, Isometry3d
28+
#include <fable/json.hpp> // for Json
2829
#include <fable/utility/eigen.hpp>
2930

3031
namespace cloe {
@@ -58,8 +59,8 @@ class ObjectSensor : public Component {
5859
/**
5960
* Writes JSON representation into j.
6061
*/
61-
Json active_state() const override {
62-
return Json{
62+
fable::Json active_state() const override {
63+
return fable::Json{
6364
{"mount_pose", this->mount_pose()},
6465
{"frustum", this->frustum()},
6566
{"sensed_objects", this->sensed_objects()},

models/include/cloe/component/pedal_actuator.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@
2727
namespace cloe {
2828

2929
struct PedalRequest {
30-
/*
30+
/*
3131
* Requested status of the gas pedal with no unit.
3232
*
3333
* The range goes from 0 (unpressed) to 1 (fully pressed).
3434
*/
3535
double gas_pedal_position{0.0};
3636

37-
/*
37+
/*
3838
* Requested status of the brake pedal with no unit.
3939
*
4040
* The range goes from 0 (unpressed) to 1 (fully pressed).
4141
*/
4242
double brake_pedal_position{0.0};
4343

44-
friend void to_json(Json& j, const PedalRequest& p) {
45-
j = Json{
44+
friend void to_json(fable::Json& j, const PedalRequest& p) {
45+
j = fable::Json{
4646
{"gas_pedal_position", p.gas_pedal_position},
4747
{"brake_pedal_position", p.brake_pedal_position},
4848
};

models/include/cloe/component/powertrain_sensor.hpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121

2222
#pragma once
2323

24-
#include <cloe/component.hpp> // for Component, Json
24+
#include <cloe/component.hpp> // for Component
25+
#include <fable/json.hpp> // for Json
2526

2627
namespace cloe {
2728

@@ -33,14 +34,14 @@ class PowertrainSensor : public Component {
3334

3435
/**
3536
* Return the position of the acceleration pedal with no unit.
36-
*
37+
*
3738
* The range goes from 0 (unpressed) to 1 (fully pressed).
3839
*/
3940
virtual double pedal_position_acceleration() const = 0;
4041

4142
/**
4243
* Return the gear transmission.
43-
*
44+
*
4445
* The sign of this field is linked to the mode of the gear
4546
* - positive: driving forward (e.g. a value of 3 means the third gear in driving forward mode)
4647
* - 0: means that the gear lever is in neutral position
@@ -52,8 +53,8 @@ class PowertrainSensor : public Component {
5253
/**
5354
* Return sensor state as JSON.
5455
*/
55-
Json active_state() const override {
56-
return Json{
56+
fable::Json active_state() const override {
57+
return fable::Json{
5758
{"pedal_position_acceleration", pedal_position_acceleration()},
5859
{"gear_transmission", gear_transmission()},
5960
};

models/include/cloe/component/steering_actuator.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ struct SteeringRequest {
3232
*/
3333
double steering_angle_front{0.0};
3434

35-
/**
35+
/**
3636
* Rear center wheel angle with regards to z-Axis in [radians].
3737
*/
3838
double steering_angle_rear{0.0};
3939

40-
friend void to_json(Json& j, const SteeringRequest& s) {
41-
j = Json{
40+
friend void to_json(fable::Json& j, const SteeringRequest& s) {
41+
j = fable::Json{
4242
{"steering_angle_front", s.steering_angle_front},
4343
{"steering_angle_rear", s.steering_angle_rear},
4444
};

0 commit comments

Comments
 (0)