Skip to content

Commit

Permalink
Fix review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
mamaheux committed Jan 15, 2024
1 parent 5c077b9 commit cd6ac7a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ Also, it may have parameters used by the strategy.
A strategy represents a way to fulfill a desire. The strategy will accomplish the desire once the strategy is activated.
At least one strategy is required for each desire type.
If there are many strategies for a desire type, the strategy with the highest utility is prioritized.
A strategy has a list of filters to enable and a list resources required to be enabled.
A strategy has a list of filters to enable and a list of resources required to be enabled.
The resources can be used to prevent conflicts of actuators between strategies.
If resources are used to manage the processing time in percent, the strategy resources can contain the estimated processing time in percent.
So, HBBA will manage the processing time of the robot.

#### Desire Set
The desire set contains the current desires to fulfill. An observer pattern is implemented in the desire to get notified of changes.
The desire set contains the current desires to fulfill. An observer pattern is implemented in the desire set to get notified of changes.

#### Motivations
The motivations modify the content of the desire set to make the robot do something useful.
Expand Down Expand Up @@ -106,7 +106,7 @@ class TalkDesire : public Desire
public:
// Add the desire parameters as arguments of the constructor.
TalkDesire::TalkDesire(string text, uint16_t intensity) : Desire(intensity), m_text(move(text)) {}
explicit TalkDesire::TalkDesire(string text, uint16_t intensity = 1) : Desire(intensity), m_text(move(text)) {}
~TalkDesire() override = default;
// The following macro overrides the required methods to declare a Desire.
Expand Down Expand Up @@ -171,8 +171,6 @@ protected:
// Override the method to publish a message when the strategy is enabled.
void onEnabling(const TalkDesire& desire) override
{
Strategy<TalkDesire>::onEnabling(desire); // Enable the filters declared in the constructor.
// Publish the text to be said.
talk::Text msg;
msg.text = desire.text();
Expand Down
2 changes: 1 addition & 1 deletion include/hbba_lite/core/HbbaLite.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class HbbaLite : public DesireSetObserver
std::vector<std::unique_ptr<BaseStrategy>> strategies,
std::unordered_map<std::string, uint16_t> resourcesByNames,
std::unique_ptr<Solver> solver,
std::unique_ptr<StrategyStateLogger> strategyStateLogger = std::make_unique<DummyStrategyStateLogger>());
std::unique_ptr<StrategyStateLogger> strategyStateLogger = std::make_unique<NoOpStrategyStateLogger>());
~HbbaLite();

DECLARE_NOT_COPYABLE(HbbaLite);
Expand Down
2 changes: 1 addition & 1 deletion include/hbba_lite/core/Strategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,13 @@ inline StrategyType Strategy<T>::strategyType()
template<class T>
inline void Strategy<T>::onEnabling(const Desire& desire)
{
BaseStrategy::onEnabling(desire);
onEnabling(dynamic_cast<const T&>(desire));
}

template<class T>
inline void Strategy<T>::onEnabling(const T& desire)
{
BaseStrategy::onEnabling(desire);
}

#endif
10 changes: 5 additions & 5 deletions include/hbba_lite/core/StrategyStateLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ class StrategyStateLogger
virtual void log(DesireType desireType, StrategyType strategyType, bool enabled) = 0;
};

class DummyStrategyStateLogger : public StrategyStateLogger
class NoOpStrategyStateLogger : public StrategyStateLogger
{
public:
DummyStrategyStateLogger();
~DummyStrategyStateLogger() override = default;
NoOpStrategyStateLogger();
~NoOpStrategyStateLogger() override = default;

DECLARE_NOT_COPYABLE(DummyStrategyStateLogger);
DECLARE_NOT_MOVABLE(DummyStrategyStateLogger);
DECLARE_NOT_COPYABLE(NoOpStrategyStateLogger);
DECLARE_NOT_MOVABLE(NoOpStrategyStateLogger);

void log(DesireType desireType, StrategyType strategyType, bool enabled) override;
};
Expand Down
4 changes: 2 additions & 2 deletions src/hbba_lite_cpp/core/StrategyStateLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

StrategyStateLogger::StrategyStateLogger() {}

DummyStrategyStateLogger::DummyStrategyStateLogger() {}
NoOpStrategyStateLogger::NoOpStrategyStateLogger() {}

void DummyStrategyStateLogger::log(DesireType desireType, StrategyType strategyType, bool enabled) {}
void NoOpStrategyStateLogger::log(DesireType desireType, StrategyType strategyType, bool enabled) {}

0 comments on commit cd6ac7a

Please sign in to comment.