Class component. More...
#include <Component.h>
Public Member Functions | |
Component (double desired_hz) | |
Public constructor. | |
ReturnValue | CreateTask (int prio, double frec, void *(*start_routine)(void *)) |
Creates new tasks. | |
States | GetState () |
Returns the general state of the Component. | |
virtual char * | GetStateString () |
Returns the general state of the Component as string. | |
char * | GetStateString (States state) |
Returns the general state as string. | |
double | GetUpdateRate () |
Gets current update rate of the thread. | |
virtual ReturnValue | Setup () |
virtual ReturnValue | ShutDown () |
virtual ReturnValue | Start () |
virtual ReturnValue | Stop () |
virtual | ~Component () |
Public destructor. | |
Protected Member Functions | |
virtual ReturnValue | Allocate () |
virtual void | AllState () |
Actions performed in all states. | |
virtual ReturnValue | Close () |
virtual ReturnValue | Configure () |
virtual void | ControlThread () |
All core component functionality is contained in this thread. | |
virtual void | EmergencyState () |
Actions performed on the emergency state. | |
virtual void | FailureState () |
Actions performed on Failure state. | |
virtual ReturnValue | Free () |
ReturnValue | GetThreadData (thread_data *data) |
Gets the data of the current thread. | |
virtual void | InitState () |
Actions performed on initial state. | |
virtual ReturnValue | Open () |
virtual void | ReadyState () |
Actions performed on ready state. | |
virtual void | StandbyState () |
Actions performed on standby state. | |
virtual void | SwitchToState (States new_state) |
Switches between states. | |
Protected Attributes | |
bool | bInitialized |
Controls if has been initialized succesfully. | |
bool | bRunning |
Controls the execution of the Component's thread. | |
States | iOldState |
State before. | |
States | iState |
State of the Component. | |
string | sComponentName |
Almacenaremos el nombre del componente para personalizar el log a de cada una de las clases derivadas. | |
thread_data | threadData |
Contains data for the main thread. | |
vector< thread_data > | vThreadData |
Contains data for the secondary threads. | |
Private Attributes | |
pthread_mutex_t | mutexThread |
Mutex to manage the access to the thread's vector. | |
Friends | |
void * | AuxControlThread (void *threadParam) |
Main function to execute into the thread. |
Class component.
Definition at line 121 of file Component.h.
Component::Component | ( | double | desired_hz | ) |
Public constructor.
Constructor by default.
desired_hz | as double, sets the desired frequency of the controlthread |
Definition at line 31 of file Component.cc.
Component::~Component | ( | ) | [virtual] |
ReturnValue Component::Allocate | ( | ) | [protected, virtual] |
Allocates virtual memory if it's necessary
Allocates virtual memory if it's necessary
Definition at line 151 of file Component.cc.
void Component::AllState | ( | ) | [protected, virtual] |
Actions performed in all states.
Actions performed on all states.
Reimplemented in purepursuit_planner_node.
Definition at line 369 of file Component.cc.
ReturnValue Component::Close | ( | ) | [protected, virtual] |
Closes used devices
Closes used devices
Definition at line 180 of file Component.cc.
ReturnValue Component::Configure | ( | ) | [protected, virtual] |
Configures devices and performance of the component
Configures devices and performance of the component
Definition at line 142 of file Component.cc.
void Component::ControlThread | ( | ) | [protected, virtual] |
All core component functionality is contained in this thread.
All core component functionality is contained in this thread. All of the Component component state machine code can be found here.
Reimplemented in purepursuit_planner_node.
Definition at line 261 of file Component.cc.
ReturnValue Component::CreateTask | ( | int | prio, |
double | frec, | ||
void *(*)(void *) | start_routine | ||
) |
Creates new tasks.
Creates new thread executing specific tasks
prio | as int, Thread priority level ( 0[min]-80[max] ) |
frec | as double, thread frequency |
start_routine | as void*(*)(void*), function wich will execute the task |
Definition at line 500 of file Component.cc.
void Component::EmergencyState | ( | ) | [protected, virtual] |
Actions performed on the emergency state.
Actions performed on emergency state.
Reimplemented in purepursuit_planner_node.
Definition at line 355 of file Component.cc.
void Component::FailureState | ( | ) | [protected, virtual] |
Actions performed on Failure state.
Actions performed on failure state.
Reimplemented in purepursuit_planner_node.
Definition at line 362 of file Component.cc.
ReturnValue Component::Free | ( | ) | [protected, virtual] |
Frees allocated memory previously
Frees allocated memory previously
Definition at line 160 of file Component.cc.
Returns the general state of the Component.
returns the state of the component
Definition at line 384 of file Component.cc.
char * Component::GetStateString | ( | ) | [virtual] |
Returns the general state of the Component as string.
Gets the state of the component as string.
Definition at line 391 of file Component.cc.
char * Component::GetStateString | ( | States | state | ) |
Returns the general state as string.
Gets the state as a string.
Definition at line 420 of file Component.cc.
ReturnValue Component::GetThreadData | ( | thread_data * | data | ) | [protected] |
Gets the data of the current thread.
Gets the data of the current thread
Definition at line 467 of file Component.cc.
double Component::GetUpdateRate | ( | ) |
Gets current update rate of the thread.
Method to get current update rate of the thread
Definition at line 377 of file Component.cc.
void Component::InitState | ( | ) | [protected, virtual] |
Actions performed on initial state.
Reimplemented in purepursuit_planner_node.
Definition at line 334 of file Component.cc.
ReturnValue Component::Open | ( | ) | [protected, virtual] |
Opens used devices
Opens used devices
Definition at line 170 of file Component.cc.
void Component::ReadyState | ( | ) | [protected, virtual] |
Actions performed on ready state.
Reimplemented in purepursuit_planner_node.
Definition at line 348 of file Component.cc.
ReturnValue Component::Setup | ( | ) | [virtual] |
Configures and initializes the component
Configures and initializes the component
Reimplemented in purepursuit_planner_node.
Definition at line 63 of file Component.cc.
ReturnValue Component::ShutDown | ( | ) | [virtual] |
Closes and frees the reserved resources
Closes and frees the reserved resources
Definition at line 107 of file Component.cc.
void Component::StandbyState | ( | ) | [protected, virtual] |
Actions performed on standby state.
Actions performed on Standby state.
Reimplemented in purepursuit_planner_node.
Definition at line 341 of file Component.cc.
ReturnValue Component::Start | ( | ) | [virtual] |
Starts the control thread of the component and its subcomponents
Starts the control thread of the component and its subcomponents
Reimplemented in purepursuit_planner_node.
Definition at line 191 of file Component.cc.
ReturnValue Component::Stop | ( | ) | [virtual] |
Stops the main control thread of the component and its subcomponents
Stops the control thread of the Motors
Reimplemented in purepursuit_planner_node.
Definition at line 237 of file Component.cc.
void Component::SwitchToState | ( | States | new_state | ) | [protected, virtual] |
Switches between states.
function that switches the state of the component into the desired state
new_state | as an integer, the new state of the component |
Definition at line 451 of file Component.cc.
void* AuxControlThread | ( | void * | threadParam | ) | [friend] |
Main function to execute into the thread.
Definition at line 20 of file Component.cc.
bool Component::bInitialized [protected] |
Controls if has been initialized succesfully.
Definition at line 125 of file Component.h.
bool Component::bRunning [protected] |
Controls the execution of the Component's thread.
Definition at line 127 of file Component.h.
States Component::iOldState [protected] |
State before.
Definition at line 135 of file Component.h.
States Component::iState [protected] |
State of the Component.
Definition at line 133 of file Component.h.
pthread_mutex_t Component::mutexThread [private] |
Mutex to manage the access to the thread's vector.
Definition at line 140 of file Component.h.
string Component::sComponentName [protected] |
Almacenaremos el nombre del componente para personalizar el log a de cada una de las clases derivadas.
Definition at line 137 of file Component.h.
thread_data Component::threadData [protected] |
Contains data for the main thread.
Definition at line 129 of file Component.h.
vector<thread_data> Component::vThreadData [protected] |
Contains data for the secondary threads.
Definition at line 131 of file Component.h.