YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
scriptModule Class Reference
+ Inheritance diagram for scriptModule:

Public Member Functions

bool start () override
 Start (or resumes, if stopped) the currently selected action.
 
bool stop () override
 Stops the currently selected (running) action.
 
bool reset () override
 Rewinds the currently selected action.
 
bool forever () override
 Similar to play, but it will automatically restart the playback when the last frame is reached.
 
bool print_frames () override
 Prints all the frames of the currently selected action.
 
bool speed_factor (const double value) override
 Sets the playback speed factor for the currently selected action (default value: 1.0).
 
bool resample (const double value) override
 Resamples the currently selected action (in seconds, recommended value 0.010s).
 
bool choose_action (const std::string &action_name) override
 Choose the current action and wait for further commands.
 
bool play_action (const std::string &action_name) override
 Play an action one single time.
 
bool show_actions () override
 Prints all the loaded actions.
 
bool set_thread_period (const double value) override
 Sets the period of the sampling thread (for advanced use only, default value: 0.010s).
 
 scriptModule ()
 
 ~scriptModule ()
 
bool chooseActionByName (std::string id)
 
std::string string_list_actions ()
 
bool loadConfiguration (std::string filename, double resample_period)
 
void print_help ()
 
virtual bool configure (yarp::os::ResourceFinder &rf)
 Configure the module, pass a ResourceFinder object to the module.
 
virtual bool close ()
 Close function.
 
virtual double getPeriod ()
 You can override this to control the approximate periodicity at which updateModule() is called by runModule().
 
virtual bool updateModule ()
 Override this to do whatever your module needs to do.
 
- Public Member Functions inherited from yarp::os::RFModule
 RFModule ()
 Constructor.
 
virtual ~RFModule ()
 Destructor.
 
virtual int runModule ()
 Calls updateModule() until that returns false.
 
virtual int runModule (yarp::os::ResourceFinder &rf)
 Simple helper method to call configure() and then runModule().
 
virtual int runModuleThreaded ()
 Calls updateModule() on a separate thread until that returns false.
 
virtual int runModuleThreaded (yarp::os::ResourceFinder &rf)
 Simple helper method to call configure() and then runModule() on a separate thread.
 
virtual int getThreadKey ()
 return the Thread unique identifier
 
virtual bool respond (const Bottle &command, Bottle &reply)
 Respond to a message.
 
virtual bool attach (yarp::os::Port &source)
 Make any input from a Port object go to the respond() method.
 
virtual bool attach (yarp::os::RpcServer &source)
 Make any input from an RpcServer object go to the respond() method.
 
bool attachTerminal ()
 Make any input from standard input (usually the keyboard) go to the respond() method.
 
bool detachTerminal ()
 Detach terminal.
 
virtual bool interruptModule ()
 Try to halt any ongoing operations by threads managed by the module.
 
void stopModule (bool wait=false)
 Ask the module to stop.
 
bool isStopping ()
 Check if the module should stop.
 
bool joinModule (double seconds=-1)
 The function returns when the thread execution has completed.
 
std::string getName (const std::string &subName="")
 Return name of module, as set with setName().
 
void setName (const char *name)
 Set the name of the module.
 
bool safeRespond (const Bottle &command, Bottle &reply)
 Wrapper around respond() that is guaranteed to process system messages.
 
- Public Member Functions inherited from yarpActionsPlayer_IDL
virtual yarp::os::ApplicationNetworkProtocolVersion getLocalProtocolVersion ()
 
virtual yarp::os::ApplicationNetworkProtocolVersion getRemoteProtocolVersion ()
 
virtual bool checkProtocolVersion ()
 
 yarpActionsPlayer_IDL ()
 
virtual std::vector< std::string > help (const std::string &functionName="--all")
 
bool read (yarp::os::ConnectionReader &connection) override
 Read this object from a network connection.
 
- Public Member Functions inherited from yarp::os::Wire
yarp::os::WireLinkyarp ()
 Get YARP state associated with this object.
 
const yarp::os::WireLinkyarp () const
 Get YARP state associated with this object (const version).
 
- Public Member Functions inherited from yarp::os::PortReader
virtual ~PortReader ()
 Destructor.
 
virtual Type getReadType () const
 

Protected Attributes

yarp::os::Port m_rpcPort
 
std::string m_name
 
bool m_verbose
 
std::map< std::string, robotDriver * > m_robotControllers
 
std::map< std::string, action_classm_actions
 
ControlThreadm_wthread =nullptr
 
BroadcastingThreadm_bthread =nullptr
 
std::string m_current_action_id
 

Detailed Description

Definition at line 31 of file main.cpp.

Constructor & Destructor Documentation

◆ scriptModule()

scriptModule::scriptModule ( )
inline

Definition at line 58 of file main.cpp.

◆ ~scriptModule()

scriptModule::~scriptModule ( )
inline

Definition at line 63 of file main.cpp.

Member Function Documentation

◆ choose_action()

bool scriptModule::choose_action ( const std::string &  action_name)
overridevirtual

Choose the current action and wait for further commands.

Returns
true/false on success/failure

Reimplemented from yarpActionsPlayer_IDL.

Definition at line 439 of file main.cpp.

◆ chooseActionByName()

bool scriptModule::chooseActionByName ( std::string  id)
inline

Definition at line 88 of file main.cpp.

◆ close()

virtual bool scriptModule::close ( )
inlinevirtual

Close function.

This is called automatically when the module closes, after the last call to updateModule. Override this to cleanup memory allocated in the configure() function or perform other activities that ensure graceful shutdown.

Returns
true/false on success failure.

Reimplemented from yarp::os::RFModule.

Definition at line 373 of file main.cpp.

◆ configure()

virtual bool scriptModule::configure ( yarp::os::ResourceFinder rf)
inlinevirtual

Configure the module, pass a ResourceFinder object to the module.

This function can perform initialization including object creation and memory allocation; returns false to notify that initialization was not successful and that the module should not start. Cleanup should be performed by the function close(). In case of failure during the initialization and before returning false, the function configure() should cleanup memory and resources allocated.

Parameters
rfa previously initialized ResourceFinder
Returns
true/false upon success/failure
Note
attachTerminal() is no longer called automatically. You can call it in the configure function.

Reimplemented from yarp::os::RFModule.

Definition at line 248 of file main.cpp.

◆ forever()

bool scriptModule::forever ( )
overridevirtual

Similar to play, but it will automatically restart the playback when the last frame is reached.

Returns
true/false on success/failure

Reimplemented from yarpActionsPlayer_IDL.

Definition at line 419 of file main.cpp.

◆ getPeriod()

virtual double scriptModule::getPeriod ( )
inlinevirtual

You can override this to control the approximate periodicity at which updateModule() is called by runModule().

By default, it returns 1.0. Time here is in seconds.

Returns
the desired period between successive calls to updateModule()

Reimplemented from yarp::os::RFModule.

Definition at line 380 of file main.cpp.

◆ loadConfiguration()

bool scriptModule::loadConfiguration ( std::string  filename,
double  resample_period 
)
inline

Definition at line 123 of file main.cpp.

◆ play_action()

bool scriptModule::play_action ( const std::string &  action_name)
overridevirtual

Play an action one single time.

The call blocks untils the playback is complete.

Returns
true/false on success/failure

Reimplemented from yarpActionsPlayer_IDL.

Definition at line 444 of file main.cpp.

◆ print_frames()

bool scriptModule::print_frames ( )
overridevirtual

Prints all the frames of the currently selected action.

Returns
true/false on success/failure

Reimplemented from yarpActionsPlayer_IDL.

Definition at line 424 of file main.cpp.

◆ print_help()

void scriptModule::print_help ( )
inline

Definition at line 231 of file main.cpp.

◆ resample()

bool scriptModule::resample ( const double  value)
overridevirtual

Resamples the currently selected action (in seconds, recommended value 0.010s).

Returns
true/false on success/failure

Reimplemented from yarpActionsPlayer_IDL.

Definition at line 434 of file main.cpp.

◆ reset()

bool scriptModule::reset ( )
overridevirtual

Rewinds the currently selected action.

Returns
true/false on success/failure

Reimplemented from yarpActionsPlayer_IDL.

Definition at line 414 of file main.cpp.

◆ set_thread_period()

bool scriptModule::set_thread_period ( const double  value)
overridevirtual

Sets the period of the sampling thread (for advanced use only, default value: 0.010s).

Returns
true/false on success/failure

Reimplemented from yarpActionsPlayer_IDL.

Definition at line 466 of file main.cpp.

◆ show_actions()

bool scriptModule::show_actions ( )
overridevirtual

Prints all the loaded actions.

Returns
true/false on success/failure

Reimplemented from yarpActionsPlayer_IDL.

Definition at line 456 of file main.cpp.

◆ speed_factor()

bool scriptModule::speed_factor ( const double  value)
overridevirtual

Sets the playback speed factor for the currently selected action (default value: 1.0).

Returns
true/false on success/failure

Reimplemented from yarpActionsPlayer_IDL.

Definition at line 429 of file main.cpp.

◆ start()

bool scriptModule::start ( )
overridevirtual

Start (or resumes, if stopped) the currently selected action.

It will stop when the last frame is reached.

Returns
true/false on success/failure

Reimplemented from yarpActionsPlayer_IDL.

Definition at line 404 of file main.cpp.

◆ stop()

bool scriptModule::stop ( )
overridevirtual

Stops the currently selected (running) action.

Can be resumed by start.

Returns
true/false on success/failure

Reimplemented from yarpActionsPlayer_IDL.

Definition at line 409 of file main.cpp.

◆ string_list_actions()

std::string scriptModule::string_list_actions ( )
inline

Definition at line 112 of file main.cpp.

◆ updateModule()

virtual bool scriptModule::updateModule ( )
inlinevirtual

Override this to do whatever your module needs to do.

When your module wants to stop, return false. The module's actual work could be done during this call, or it could just check the state of a thread running in the background.

The thread calls the updateModule() function every <period> seconds. At the end of each run, the thread will sleep the amounth of time required, taking into account the time spent inside the loop function. Example: requested period is 10ms, the updateModule() function take 3ms to be executed, the thread will sleep for 7ms.

Note: after each run is completed, the thread will call a yield() in order to facilitate other threads to run.

Returns
true iff module should continue

Implements yarp::os::RFModule.

Definition at line 381 of file main.cpp.

Member Data Documentation

◆ m_actions

std::map<std::string,action_class> scriptModule::m_actions
protected

Definition at line 38 of file main.cpp.

◆ m_bthread

BroadcastingThread* scriptModule::m_bthread =nullptr
protected

Definition at line 40 of file main.cpp.

◆ m_current_action_id

std::string scriptModule::m_current_action_id
protected

Definition at line 42 of file main.cpp.

◆ m_name

std::string scriptModule::m_name
protected

Definition at line 35 of file main.cpp.

◆ m_robotControllers

std::map<std::string,robotDriver*> scriptModule::m_robotControllers
protected

Definition at line 37 of file main.cpp.

◆ m_rpcPort

yarp::os::Port scriptModule::m_rpcPort
protected

Definition at line 34 of file main.cpp.

◆ m_verbose

bool scriptModule::m_verbose
protected

Definition at line 36 of file main.cpp.

◆ m_wthread

ControlThread* scriptModule::m_wthread =nullptr
protected

Definition at line 39 of file main.cpp.


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