Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Lua and Databroker support #190

Merged
merged 22 commits into from
Jul 5, 2024
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ab2fc45
engine: Remove --distinct option from check command
cassava Mar 10, 2023
9a7a556
engine: Set stack options in own scope
cassava Mar 16, 2023
87d82bc
engine: Extract SimulationProgress into simulation_progress.hpp
cassava May 10, 2023
93b4d24
runtime: Add CallbackResult return value to all action operator()
cassava May 16, 2024
5ba0e6d
engine: Restructure code for better compilation times
cassava May 16, 2024
2bed94a
basic: Replace boost::optional with std::optional
cassava May 16, 2024
12b60b5
engine: Vendor linenoise library
cassava May 24, 2023
f06ce82
engine: Add Lua scripting support
cassava May 16, 2024
e014958
engine: Add LRDB debugging support
cassava May 16, 2024
a0b8569
all: Add DataBroker and Signals concepts
cassava May 16, 2024
2769fb2
engine: Replace boost::optional with std::optional
cassava Oct 26, 2023
2e847d3
runtime: Replace boost::filesystem with std::filesystem
cassava Nov 6, 2023
a155f8b
engine: Replace boost::filesystem with std::filesystem
cassava Nov 6, 2023
b4a84c7
engine: Add --output-path to cloe-engine
CzBalti Dec 14, 2023
26e43e2
tests: Add test for cloe-engine --write-output and --output-path
cassava Apr 30, 2024
79ec670
tooling: Add VS Code project configuration
CzBalti Jun 12, 2024
4e30255
tooling: Improve grep-uuids to better show duplicates
cassava Jun 13, 2024
13ad0fb
speedometer: Implement data broker
cassava Jun 13, 2024
a00f1d5
all: Improve DataBroker interface for common types
cassava Jun 26, 2024
9afe3a4
runtime: Fix duplicate definitions in set_action.hpp
cassava Jun 26, 2024
a4c0943
engine: Fix some findings from clang-tidy
cassava Jun 26, 2024
e206cb0
engine: Add probe subcommand
cassava Jun 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
speedometer: Implement data broker
cassava committed Jun 13, 2024
commit 13ad0fb1b5fc507fa0085296a94cfd07ccc23569
37 changes: 26 additions & 11 deletions plugins/speedometer/src/speedometer.cpp
Original file line number Diff line number Diff line change
@@ -19,42 +19,57 @@
* \file speedometer.cpp
*/

#include <memory> // for shared_ptr<>

#include <fable/confable.hpp> // for Confable, CONFABLE_FRIENDS
#include <fable/json.hpp> // for Json

#include <cloe/component.hpp> // for Component, ComponentFactory, ...
#include <cloe/component/utility/ego_sensor_canon.hpp> // for EgoSensorCanon
#include <cloe/data_broker.hpp> // for DataBroker
#include <cloe/plugin.hpp> // for EXPORT_CLOE_PLUGIN
#include <cloe/registrar.hpp> // for Registrar
#include <cloe/trigger/evaluate_event.hpp> // for EvaluateCallback
#include <cloe/vehicle.hpp> // for Vehicle
using namespace cloe;

struct SpeedometerConf : public Confable {
struct SpeedometerConf : public fable::Confable {
CONFABLE_FRIENDS(SpeedometerConf)
};

class Speedometer : public Component {
class Speedometer : public cloe::Component {
public:
Speedometer(const std::string& name, const SpeedometerConf&, std::shared_ptr<EgoSensor> ego)
Speedometer(const std::string& name, const SpeedometerConf&, std::shared_ptr<cloe::EgoSensor> ego)
: Component(name, "provides an event trigger to evaluate speed in km/h"), sensor_(ego) {}

virtual ~Speedometer() noexcept = default;

void enroll(Registrar& r) override {
void enroll(cloe::Registrar& r) override {
callback_kmph_ =
r.register_event<events::EvaluateFactory, double>("kmph", "vehicle speed in km/h");
r.register_event<cloe::events::EvaluateFactory, double>("kmph", "vehicle speed in km/h");

auto& db = r.data_broker();
{
std::string signal_name = fmt::format("components.{}.kmph", name());
auto signal = db.declare<double>(signal_name);
signal->set_getter<double>(
[this]() -> double { return cloe::utility::EgoSensorCanon(sensor_).velocity_as_kmph(); });
}
}

Duration process(const Sync& sync) override {
auto ego = utility::EgoSensorCanon(sensor_);
cloe::Duration process(const cloe::Sync& sync) override {
auto ego = cloe::utility::EgoSensorCanon(sensor_);
callback_kmph_->trigger(sync, ego.velocity_as_kmph());
return sync.time();
}

Json active_state() const override { return nullptr; }
fable::Json active_state() const override {
return fable::Json{{"kmph", utility::EgoSensorCanon(sensor_).velocity_as_kmph()}};
}

private:
// State:
std::shared_ptr<events::EvaluateCallback> callback_kmph_;
std::shared_ptr<EgoSensor> sensor_;
std::shared_ptr<cloe::events::EvaluateCallback> callback_kmph_;
std::shared_ptr<cloe::EgoSensor> sensor_;
};

DEFINE_COMPONENT_FACTORY(SpeedometerFactory, SpeedometerConf, "speedometer",

Unchanged files with check annotations Beta

- all: Bump required C++ standard from 14 to 17 `[fe678bca] <https://github.com/eclipse/cloe/commit/fe678bca4d50cea7b42a044caa07bbf1a487d434>`_
- all: Remove constraints on Boost version from cppnetlib `[2fabcaa9] <https://github.com/eclipse/cloe/commit/2fabcaa98ab7e7e4299355c561fd523d083b957f>`_
- ci: Improve performance of Github CI jobs `[b13c7182] <https://github.com/eclipse/cloe/commit/b13c7182fc427ee913e15b9bb6b5d7f57a1b2354>`_ ci: Remove ubuntu-18.04 from Github workflows `[47cec675] <https://github.com/eclipse/cloe/commit/47cec6755752ec62fe2e18f6b080d459c5a046b1>`_
- tests: Don't fail when *.so glob doesn't match anything `[88a92dca] <https://github.com/eclipse/cloe/commit/88a92dca75c47714ce5c7c2feea966ab49ea21fd>`_

Check warning on line 287 in docs/changelog.rst

GitHub Actions / sphinx

Inline emphasis start-string without end-string.
- tests: Depend on cloe-launch-profile >= 0.20 `[c6aaea2b] <https://github.com/eclipse/cloe/commit/c6aaea2bb731d64414e77552b5cdad26e541dc73>`_
- tests: Replace testname arg quotes with single quotes `[637f44cf] <https://github.com/eclipse/cloe/commit/637f44cfc5fdd001bb6b20a16665dd0234579e02>`_
- tooling: Add cloe-normal Conan profile `[1893b91f] <https://github.com/eclipse/cloe/commit/1893b91fe230632fb426791dd1a334791323b355>`_
Workflow
^^^^^^^^
#. | Draft new CDR proposal
[State: DRAFT]

Check warning on line 81 in docs/design/0001-cdr.rst

GitHub Actions / sphinx

Line block ends without a blank line.
Create a draft CDR by copying the :doc:`0000-template` (``0000-template.rst``)
to a new document alongside the other CDRs with the name ``proposal-topic``,
has a filename.
#. | Option I: Merge pull-request
[State: ACCEPTED - VERSION 1.0]

Check warning on line 98 in docs/design/0001-cdr.rst

GitHub Actions / sphinx

Line block ends without a blank line.
Before merging, update the pull-request with the following changes:
- Add the current date to the top section of metadata.
#. | Option II: Decline pull-request
[State: REJECTED]

Check warning on line 106 in docs/design/0001-cdr.rst

GitHub Actions / sphinx

Line block ends without a blank line.
#. | Update CDR with new pull-request
[State: ACCEPTED - VERSION X.Y]

Check warning on line 109 in docs/design/0001-cdr.rst

GitHub Actions / sphinx

Line block ends without a blank line.
#. | Retire CDR
[State: RETIRED]

Check warning on line 112 in docs/design/0001-cdr.rst

GitHub Actions / sphinx

Line block ends without a blank line.
Conclusion
.. image:: cloe-ui-components.png
.. todo::

Check warning on line 27 in docs/develop/cloe-ui/reference.rst

GitHub Actions / sphinx

TODO entry found: The following topics should be described:
The following topics should be described:
- Vision for Cloe UI
Now you can refer to cloe as a dependency library in your
``target_link_libararies`` statement like ``cloe::runtime``.
.. todo:: Write a section on how to specify a specific version of Cloe.

Check warning on line 46 in docs/develop/integrating-a-controller.rst

GitHub Actions / sphinx

TODO entry found: Write a section on how to specify a specific version of Cloe.
There are multiple use-cases here:
- Following HEAD
- Using an specific version of Cloe
.. runcmd:: make --no-print-directory -C ../fable help
.. todo::

Check warning on line 28 in docs/develop/makefile-package.rst

GitHub Actions / sphinx

TODO entry found: This file is a work-in-progress and will be extended as we find time.
This file is a work-in-progress and will be extended as we find time.
status
build a controller to Cloe. You can either clone the Cloe repository, or
install the Debian package `cloe`.
.. todo:: This section will be updated as soon as we have time.

Check warning on line 26 in docs/develop/new-controller.rst

GitHub Actions / sphinx

TODO entry found: This section will be updated as soon as we have time.