auv_control
Classes | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
auv_control::Base Class Referenceabstract

#include <Base.hpp>

Inheritance diagram for auv_control::Base:

Classes

struct  InputPortInfo
 

Public Member Functions

 Base (std::string const &name="auv_control::Base")
 
 Base (std::string const &name, RTT::ExecutionEngine *engine)
 
 ~Base ()
 
bool configureHook ()
 The following lines are template definitions for the various state machine. More...
 
bool startHook ()
 
void updateHook ()
 
void errorHook ()
 
void stopHook ()
 
void cleanupHook ()
 
States performOneLoop ()
 

Protected Types

typedef RTT::InputPort< base::LinearAngular6DCommand > InputPortType
 

Protected Member Functions

void registerInput (std::string const &name, base::Time timeout, InputPortType *input_port)
 
InputPortTypederegisterInput (std::string const &name)
 
bool verifyTimeout (const base::Time &newest_command)
 
bool verifyMissingData (const auv_control::ExpectedInputs &expected, const base::LinearAngular6DCommand &command)
 
bool checkConnectedPorts (std::vector< Base::InputPortInfo > &input_ports, std::vector< Base::InputPortInfo * > &connected_input_ports)
 
States gatherInputCommand (LinearAngular6DCommandStatus &merged_command, std::vector< Base::InputPortInfo * > &connected_ports)
 
virtual bool addCommandInput (::std::string const &name,::base::Time const &timeout)
 
virtual void keepPosition ()
 
virtual bool calcOutput (const LinearAngular6DCommandStatus &merged_command)=0
 

Protected Attributes

std::vector< InputPortInfoinput_ports
 
std::vector< Base::InputPortInfo * > connected_input_ports
 
base::Time newestCommandTime
 

Friends

class BaseBase
 

Member Typedef Documentation

typedef RTT::InputPort<base::LinearAngular6DCommand> auv_control::Base::InputPortType
protected

Constructor & Destructor Documentation

Base::Base ( std::string const &  name = "auv_control::Base")

TaskContext constructor for Base

Parameters
nameName of the task. This name needs to be unique to make it identifiable via nameservices.
Base::Base ( std::string const &  name,
RTT::ExecutionEngine *  engine 
)

TaskContext constructor for Base

Parameters
nameName of the task. This name needs to be unique to make it identifiable for nameservices.
engineThe RTT Execution engine to be used for this task, which serialises the execution of all commands, programs, state machines and incoming events for a task.
Base::~Base ( )

Default deconstructor of Base

Member Function Documentation

bool Base::addCommandInput ( ::std::string const &  name,
::base::Time const &  timeout 
)
protectedvirtual

Creates a new input port called cmd_name of the type LinearAngular6DCommand. Once defined, this input port will be merged into the merged_command command before the controller calculates the corresponding output

virtual bool auv_control::Base::calcOutput ( const LinearAngular6DCommandStatus merged_command)
protectedpure virtual

Computes the output based on the value received in merged_command (command and status)

As calcOutput is defined in the derived class, the class Base can not handle the States of derived class. In that case, any state transition in DerivedClass::calcOutput should return a false. Like that there would not a interference with Base's states.

Parameters
merging_command,Thecommand itself and its status
Returns
bool. TRUE if there is NO state transition in derived class, FALSE otherwise.
bool Base::checkConnectedPorts ( std::vector< Base::InputPortInfo > &  input_ports,
std::vector< Base::InputPortInfo * > &  connected_input_ports 
)
protected

Check for connected ports

Parameters
input_portsvector of input ports to be verified
connected_input_portsvector of address of connected input_ports to be assigned
Returns
bool. TRUE if at least one port is connected, FALSE otherwise
void Base::cleanupHook ( )

This hook is called by Orocos when the state machine transitions from Stopped to PreOperational, requiring the call to configureHook() before calling start() again.

bool Base::configureHook ( )

The following lines are template definitions for the various state machine.

This hook is called by Orocos when the state machine transitions from PreOperational to Stopped. If it returns false, then the component will stay in PreOperational. Otherwise, it goes into Stopped.

It is meaningful only if the #needs_configuration has been specified in the task context definition with (for example):

task_context "TaskName" do
  needs_configuration
  ...
end
Base::InputPortType * Base::deregisterInput ( std::string const &  name)
protected
void Base::errorHook ( )

This hook is called by Orocos when the component is in the RunTimeError state, at each activity step. See the discussion in updateHook() about triggering options.

Call recover() to go back in the Runtime state.

Base::States Base::gatherInputCommand ( LinearAngular6DCommandStatus merged_command,
std::vector< Base::InputPortInfo * > &  connected_ports 
)
protected

Gather input from connected input ports

Parameters
merged_command,wherethe commands will be safe all together with its RTT:FlowStatus
connected_portsto be analyzed.
Returns
States of wich it should go
void Base::keepPosition ( )
protectedvirtual

Send a "do not move" command to the next level

This is called if the keep_position_on_exception property is set and the component goes into an exception state

Base::States Base::performOneLoop ( )

Do one loop of read inputs and computing output

It will be called in updateHook() and errorHook(), and it can transit in both states, according its return.

Returns
States which it should go.
void Base::registerInput ( std::string const &  name,
base::Time  timeout,
InputPortType input_port 
)
protected
bool Base::startHook ( )

This hook is called by Orocos when the state machine transitions from Stopped to Running. If it returns false, then the component will stay in Stopped. Otherwise, it goes into Running and updateHook() will be called.

void Base::stopHook ( )

This hook is called by Orocos when the state machine transitions from Running to Stopped after stop() has been called.

void Base::updateHook ( )

This hook is called by Orocos when the component is in the Running state, at each activity step. Here, the activity gives the "ticks" when the hook should be called.

The error(), exception() and fatal() calls, when called in this hook, allow to get into the associated RunTimeError, Exception and FatalError states.

In the first case, updateHook() is still called, and recover() allows you to go back into the Running state. In the second case, the errorHook() will be called instead of updateHook(). In Exception, the component is stopped and recover() needs to be called before starting it again. Finally, FatalError cannot be recovered.

bool Base::verifyMissingData ( const auv_control::ExpectedInputs expected,
const base::LinearAngular6DCommand &  command 
)
protected

Check if all expected data field are present

In case of missing any data field, switch to INPUT_MISSING state

Parameters
expect,theexpected fields that need to present
commandto be verified return bool. True if there is no missing data. False in that case
bool Base::verifyTimeout ( const base::Time &  newest_command)
protected

Check for timeout in input ports

Check both in system time (time.now()) and sample time (newest_command) In case of Timeout, switch to exception state TIMEOUT

Parameters
newest_command.Time of last command in all ports
Returns
bool. True if there is no Timeout. False in Timeout case

Friends And Related Function Documentation

friend class BaseBase
friend

Member Data Documentation

std::vector<Base::InputPortInfo*> auv_control::Base::connected_input_ports
protected
std::vector<InputPortInfo> auv_control::Base::input_ports
protected
base::Time auv_control::Base::newestCommandTime
protected

The documentation for this class was generated from the following files: