Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class SmaccActionClientBase : public ISmaccActionClient
}

template <typename TOrthogonal, typename TSourceObject>
void onOrthogonalAllocation()
void onStateOrthogonalAllocation()
{
// we create here all the event factory functions capturing the TOrthogonal
postSuccessEvent = [this](auto msg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class SmaccSubscriberClient : public smacc2::ISmaccClient
}

template <typename TOrthogonal, typename TSourceObject>
void onOrthogonalAllocation()
void onStateOrthogonalAllocation()
{
// ros topic message received smacc event callback
this->postMessageEvent = [this](auto msg)
Expand Down
4 changes: 2 additions & 2 deletions smacc2/include/smacc2/client_behaviors/cb_ros_launch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ class CbRosLaunch : public smacc2::SmaccAsyncClientBehavior
virtual ~CbRosLaunch();

template <typename TOrthogonal, typename TSourceObject>
void onOrthogonalAllocation()
void onStateOrthogonalAllocation()
{
smacc2::SmaccAsyncClientBehavior::onOrthogonalAllocation<TOrthogonal, TSourceObject>();
smacc2::SmaccAsyncClientBehavior::onStateOrthogonalAllocation<TOrthogonal, TSourceObject>();
}

void onEntry() override;
Expand Down
4 changes: 2 additions & 2 deletions smacc2/include/smacc2/client_behaviors/cb_ros_launch_2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ class CbRosLaunch2 : public smacc2::SmaccAsyncClientBehavior
virtual ~CbRosLaunch2();

template <typename TOrthogonal, typename TSourceObject>
void onOrthogonalAllocation()
void onStateOrthogonalAllocation()
{
smacc2::SmaccAsyncClientBehavior::onOrthogonalAllocation<TOrthogonal, TSourceObject>();
smacc2::SmaccAsyncClientBehavior::onStateOrthogonalAllocation<TOrthogonal, TSourceObject>();
}

void onEntry() override;
Expand Down
4 changes: 2 additions & 2 deletions smacc2/include/smacc2/client_behaviors/cb_ros_stop_2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class CbRosStop2 : public smacc2::SmaccAsyncClientBehavior
virtual ~CbRosStop2();

template <typename TOrthogonal, typename TSourceObject>
void onOrthogonalAllocation()
void onStateOrthogonalAllocation()
{
smacc2::SmaccAsyncClientBehavior::onOrthogonalAllocation<TOrthogonal, TSourceObject>();
smacc2::SmaccAsyncClientBehavior::onStateOrthogonalAllocation<TOrthogonal, TSourceObject>();
}

void onEntry() override;
Expand Down
8 changes: 1 addition & 7 deletions smacc2/include/smacc2/client_behaviors/cb_sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ class CbSequence : public smacc2::SmaccAsyncClientBehavior

void onEntry() override;

// template <typename TOrthogonal, typename TSourceObject>
// void onOrthogonalAllocation()
// {
// smacc2::SmaccAsyncClientBehavior::onOrthogonalAllocation<TOrthogonal, TSourceObject>();
// }

void onExit() override { sequenceNodes_.clear(); }

template <typename TOrthogonal, typename TBehavior, typename... Args>
Expand All @@ -66,7 +60,7 @@ class CbSequence : public smacc2::SmaccAsyncClientBehavior
auto createdBh = std::shared_ptr<TBehavior>(new TBehavior(args...));

this->getCurrentState()->getOrthogonal<TOrthogonal>()->addClientBehavior(createdBh);
createdBh->template onOrthogonalAllocation<TOrthogonal, TBehavior>();
createdBh->template onStateOrthogonalAllocation<TOrthogonal, TBehavior>();

return createdBh;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class CbWaitActionServer : public smacc2::SmaccAsyncClientBehavior
virtual ~CbWaitActionServer();

template <typename TOrthogonal, typename TSourceObject>
void onOrthogonalAllocation()
void onStateOrthogonalAllocation()
{
SmaccAsyncClientBehavior::onOrthogonalAllocation<TOrthogonal, TSourceObject>();
SmaccAsyncClientBehavior::onStateOrthogonalAllocation<TOrthogonal, TSourceObject>();

// requires an action client
this->requiresClient(client_);
Expand Down
24 changes: 0 additions & 24 deletions smacc2/include/smacc2/component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,35 +51,11 @@ class ISmaccComponent
template <typename EventType>
void postEvent();

template <typename TOrthogonal, typename TSourceObject>
[[deprecated(
"Use onStateOrthogonalAllocation instead. onOrthogonalAllocation will be removed in future "
"versions.")]] void
onOrthogonalAllocation()
{
}

// New method: called when the component is allocated to a state (replaces onOrthogonalAllocation)
template <typename TOrthogonal, typename TSourceObject>
void onStateOrthogonalAllocation()
{
}

template <typename TComponent>
[[deprecated(
"Use requiresComponent with ComponentRequirement argument instead. This method will be removed "
"in future "
"versions.")]] void
requiresComponent(TComponent *& requiredComponentStorage, bool throwExceptionIfNotExist);

template <typename TComponent>
[[deprecated(
"Use requiresComponent with ComponentRequirement argument instead. This method will be removed "
"in future "
"versions.")]] void
requiresComponent(
std::string name, TComponent *& requiredComponentStorage, bool throwExceptionIfNotExist);

template <typename TComponent>
void requiresComponent(
TComponent *& requiredComponentStorage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,17 @@

namespace smacc2
{
template <typename TOrthogonal, typename TSourceObject>
void SmaccAsyncClientBehavior::onStateOrthogonalAllocation()
{
this->onOrthogonalAllocation<TOrthogonal, TSourceObject>();
}

template <typename TOrthogonal, typename TSourceObject>
void SmaccAsyncClientBehavior::onOrthogonalAllocation()
void SmaccAsyncClientBehavior::onStateOrthogonalAllocation()
{
if (postFinishEventFn_ || postSuccessEventFn_ || postFailureEventFn_)
{
RCLCPP_WARN(
getLogger(),
"SmaccAsyncClientBehavior already has event posting functions assigned. Skipping "
"re-assignment. This could be a problem if you are using the same behavior in multiple "
"states. This may be related with the deprecation of onOrthogonalAllocation in favor of "
"states. This may be related with the deprecation of onStateOrthogonalAllocation in favor of "
"onStateOrthogonalAllocation.");

return;
Expand Down
16 changes: 1 addition & 15 deletions smacc2/include/smacc2/impl/smacc_client_behavior_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,10 @@ void ISmaccClientBehavior::requiresComponent(
}
else
{
bool throwExceptionIfNotExist = (ComponentRequirement::HARD == requirementType);
stateMachine_->requiresComponent(storage, throwExceptionIfNotExist);
stateMachine_->requiresComponent(storage, requirementType);
}
}

template <typename SmaccComponentType>
void ISmaccClientBehavior::requiresComponent(
SmaccComponentType *& storage, bool throwExceptionIfNotExist)
{
this->requiresComponent(
storage, throwExceptionIfNotExist ? ComponentRequirement::HARD : ComponentRequirement::SOFT);
}

template <typename TOrthogonal, typename TSourceObject>
void ISmaccClientBehavior::onOrthogonalAllocation()
{
}

template <typename TOrthogonal, typename TSourceObject>
void ISmaccClientBehavior::onStateOrthogonalAllocation()
{
Expand Down
1 change: 0 additions & 1 deletion smacc2/include/smacc2/impl/smacc_client_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ SmaccComponentType * ISmaccClient::createNamedComponent(std::string name, TArgs.
ret = dynamic_pointer_cast<SmaccComponentType>(it->second);
}

ret->template onOrthogonalAllocation<TOrthogonal, TClient>();
ret->template onStateOrthogonalAllocation<TOrthogonal, TClient>();

return ret.get();
Expand Down
18 changes: 0 additions & 18 deletions smacc2/include/smacc2/impl/smacc_component_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,6 @@ void ISmaccComponent::postEvent()
stateMachine_->postEvent(ev);
}

template <typename TComponent>
void ISmaccComponent::requiresComponent(
TComponent *& requiredComponentStorage, bool throwExceptionIfNotExist)
{
this->requiresComponent(
requiredComponentStorage,
throwExceptionIfNotExist ? ComponentRequirement::HARD : ComponentRequirement::SOFT);
}

template <typename TComponent>
void ISmaccComponent::requiresComponent(
std::string name, TComponent *& requiredComponentStorage, bool throwExceptionIfNotExist)
{
this->requiresComponent(
name, requiredComponentStorage,
throwExceptionIfNotExist ? ComponentRequirement::HARD : ComponentRequirement::SOFT);
}

template <typename TComponent>
void ISmaccComponent::requiresComponent(
TComponent *& requiredComponentStorage, ComponentRequirement requirementType)
Expand Down
4 changes: 0 additions & 4 deletions smacc2/include/smacc2/impl/smacc_event_generator_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,4 @@ void SmaccEventGenerator::onStateOrthogonalAllocation()
{
}

template <typename TState, typename TSource>
void SmaccEventGenerator::onOrthogonalAllocation()
{
}
} // namespace smacc2
1 change: 0 additions & 1 deletion smacc2/include/smacc2/impl/smacc_orthogonal_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ void ISmaccOrthogonal::assignClientToOrthogonal(TClient * client)
client->setStateMachine(getStateMachine());
client->setOrthogonal(this);

client->template onOrthogonalAllocation<TOrthogonal, TClient>();
client->template onStateOrthogonalAllocation<TOrthogonal, TClient>();
}

Expand Down
1 change: 0 additions & 1 deletion smacc2/include/smacc2/impl/smacc_state_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ std::shared_ptr<TBehavior> ISmaccState::configure(Args &&... args)
std::shared_ptr<TBehavior>(new TBehavior(args...)); // is there an error here? are the
// behavior constructor parameters right?
orthogonal->addClientBehavior(clientBehavior);
clientBehavior->template onOrthogonalAllocation<TOrthogonal, TBehavior>();
clientBehavior->template onStateOrthogonalAllocation<TOrthogonal, TBehavior>();
return clientBehavior;
}
Expand Down
4 changes: 3 additions & 1 deletion smacc2/include/smacc2/impl/smacc_state_machine_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@ void ISmaccStateMachine::createOrthogonal()

//-------------------------------------------------------------------------------------------------------
template <typename SmaccComponentType>
void ISmaccStateMachine::requiresComponent(SmaccComponentType *& storage, bool throwsException)
void ISmaccStateMachine::requiresComponent(
SmaccComponentType *& storage, ComponentRequirement requirementType)
{
bool throwsException = requirementType == ComponentRequirement::HARD;
RCLCPP_DEBUG(
getLogger(), "component %s is required",
demangleSymbol(typeid(SmaccComponentType).name()).c_str());
Expand Down
44 changes: 42 additions & 2 deletions smacc2/include/smacc2/introspection/smacc_state_machine_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,28 @@ typename enable_if<boost::mpl::is_sequence<T>>::type processTransitions(
sourceState->fullStateName.c_str());
using boost::mpl::_1;
using wrappedList = typename boost::mpl::transform<T, add_type_wrapper<_1>>::type;
RCLCPP_INFO(
globalNh_->get_logger(), "[DIAG] About to call boost::mpl::for_each for state %s",
sourceState->fullStateName.c_str());
boost::mpl::for_each<wrappedList>(AddTransition(sourceState));
RCLCPP_INFO(
globalNh_->get_logger(), "[DIAG] Completed boost::mpl::for_each for state %s",
sourceState->fullStateName.c_str());
}

template <typename Ev, typename Dst, typename Tag>
void processTransition(
smacc2::Transition<Ev, boost::statechart::deep_history<Dst>, Tag> *,
std::shared_ptr<SmaccStateInfo> & sourceState)
{
RCLCPP_INFO(
globalNh_->get_logger(), "[DIAG] processTransition [deep_history] START for state %s",
sourceState->toShortName().c_str());
auto transitionTypeInfo = TypeInfo::getTypeInfoFromType<
smacc2::Transition<Ev, boost::statechart::deep_history<Dst>, Tag>>();
RCLCPP_INFO(
globalNh_->get_logger(), "[DIAG] processTransition [deep_history] got TypeInfo for state %s",
sourceState->toShortName().c_str());
smacc2::Transition<Ev, Dst, Tag> * mock = nullptr;
processTransitionAux(mock, sourceState, true, transitionTypeInfo);
}
Expand All @@ -183,7 +195,13 @@ template <typename Ev, typename Dst, typename Tag>
void processTransition(
smacc2::Transition<Ev, Dst, Tag> * t, std::shared_ptr<SmaccStateInfo> & sourceState)
{
RCLCPP_INFO(
globalNh_->get_logger(), "[DIAG] processTransition START for state %s",
sourceState->toShortName().c_str());
auto transitionTypeInfo = TypeInfo::getTypeInfoFromType<smacc2::Transition<Ev, Dst, Tag>>();
RCLCPP_INFO(
globalNh_->get_logger(), "[DIAG] processTransition got TypeInfo for state %s",
sourceState->toShortName().c_str());
RCLCPP_INFO(
globalNh_->get_logger(), "State %s Walker transition: %s", sourceState->toShortName().c_str(),
demangleSymbol(typeid(Ev).name()).c_str());
Expand Down Expand Up @@ -338,10 +356,14 @@ template <typename T>
typename disable_if<boost::mpl::is_sequence<T>>::type processTransitions(
std::shared_ptr<SmaccStateInfo> & sourceState)
{
// RCLCPP_INFO_STREAM(getLogger(),"state transition from: " << sourceState->demangledStateName <<
// " of type: " << demangledTypeName<T>());
RCLCPP_INFO(
globalNh_->get_logger(), "[DIAG] processTransitions [single/leaf] called for state %s",
sourceState->fullStateName.c_str());
T * dummy = nullptr;
processTransition(dummy, sourceState);
RCLCPP_INFO(
globalNh_->get_logger(), "[DIAG] processTransitions [single/leaf] completed for state %s",
sourceState->fullStateName.c_str());
}

template <typename T>
Expand Down Expand Up @@ -396,7 +418,13 @@ template <
template <typename> typename EvType, typename Tag, typename DestinyState>
void AddTransition::operator()(TTransition<EvType<TevSource>, DestinyState, Tag>)
{
RCLCPP_INFO(
globalNh_->get_logger(), "[DIAG] AddTransition::operator() [3-param] called for state %s",
currentState_->fullStateName.c_str());
processTransitions<TTransition<EvType<TevSource>, DestinyState, Tag>>(currentState_);
RCLCPP_INFO(
globalNh_->get_logger(), "[DIAG] AddTransition::operator() [3-param] completed for state %s",
currentState_->fullStateName.c_str());
}

//--------------------------------------------
Expand All @@ -406,14 +434,26 @@ template <
template <typename> typename EvType, typename DestinyState>
void AddTransition::operator()(TTransition<EvType<TevSource>, DestinyState>)
{
RCLCPP_INFO(
globalNh_->get_logger(), "[DIAG] AddTransition::operator() [2-param] called for state %s",
currentState_->fullStateName.c_str());
processTransitions<TTransition<EvType<TevSource>, DestinyState>>(currentState_);
RCLCPP_INFO(
globalNh_->get_logger(), "[DIAG] AddTransition::operator() [2-param] completed for state %s",
currentState_->fullStateName.c_str());
}

template <typename TTrans>
void AddTransition::operator()(TTrans)
{
RCLCPP_INFO(
globalNh_->get_logger(), "[DIAG] AddTransition::operator() [generic] called for state %s",
currentState_->fullStateName.c_str());
using type_t = typename TTrans::type;
processTransitions<type_t>(currentState_);
RCLCPP_INFO(
globalNh_->get_logger(), "[DIAG] AddTransition::operator() [generic] completed for state %s",
currentState_->fullStateName.c_str());
}

/*
Expand Down
3 changes: 0 additions & 3 deletions smacc2/include/smacc2/smacc_asynchronous_client_behavior.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ struct EvCbFailure : sc::event<EvCbFailure<AsyncCB, Orthogonal>>
class SmaccAsyncClientBehavior : public ISmaccClientBehavior
{
public:
template <typename TOrthogonal, typename TSourceObject>
void onOrthogonalAllocation();

template <typename TOrthogonal, typename TSourceObject>
void onStateOrthogonalAllocation();

Expand Down
10 changes: 0 additions & 10 deletions smacc2/include/smacc2/smacc_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,6 @@ class ISmaccClient
{
}

// it is called after the client initialization, provides information about the orthogonal it is located in
template <typename TOrthogonal, typename TSourceObject>
[[deprecated(
"Use onStateOrthogonalAllocation instead. onOrthogonalAllocation will be removed in future "
"versions.")]] void
onOrthogonalAllocation()
{
}

// New method: called when the client is allocated to a state (replaces onOrthogonalAllocation)
template <typename TOrthogonal, typename TSourceObject>
void onStateOrthogonalAllocation()
{
Expand Down
13 changes: 0 additions & 13 deletions smacc2/include/smacc2/smacc_client_behavior_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ class ISmaccClientBehavior
template <typename SmaccClientType>
void requiresClient(SmaccClientType *& storage);

template <typename SmaccComponentType>
[[deprecated(
"Use requiresClient with the ComponentRequirement argument. This method will be removed in "
"future versions.")]] void
requiresComponent(SmaccComponentType *& storage, bool throwExceptionIfNotExist);

template <typename SmaccComponentType>
void requiresComponent(
SmaccComponentType *& storage,
Expand Down Expand Up @@ -80,13 +74,6 @@ class ISmaccClientBehavior
virtual rclcpp::Logger getLogger() const;

private:
template <typename TOrthogonal, typename TSourceObject>
[[deprecated(
"Use onStateOrthogonalAllocation instead. onOrthogonalAllocation will be removed in future "
"versions.")]] void
onOrthogonalAllocation();

// New method: called when the client behavior is allocated to a state (replaces onOrthogonalAllocation)
template <typename TOrthogonal, typename TSourceObject>
void onStateOrthogonalAllocation();

Expand Down
Loading