AUTh-ARL Core Stack  0.7
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
arl::viz::RosStatePublisher Class Reference

A class which implements a controller for robot visualization in RViz. More...

#include <ros_state_publisher.h>

Inheritance diagram for arl::viz::RosStatePublisher:
Collaboration diagram for arl::viz::RosStatePublisher:

Public Member Functions

 RosStatePublisher (std::shared_ptr< robot::Robot > r, const std::string &joint_state_topic="/autharl_joint_state", double rate=50, const std::string &frame="world", const std::string &topic="/autharl_viz")
 The default constructor. More...
 
 RosStatePublisher (std::shared_ptr< robot::Robot > r, std::shared_ptr< robot::Sensor > s, const std::string &joint_state_topic="/autharl_joint_state", double rate=50, const std::string &frame="world", const std::string &topic="/autharl_viz")
 The default constructor. More...
 
void measure ()
 Measures the current state of the robot (Joint Positions). More...
 
void command ()
 Publishes the measured joint positions and other data in RViz. More...
 
virtual void update ()
 Updates ROS data structures with the readings from the robot. More...
 
bool stop ()
 The stop condition of the controller which is that ROS is ok. More...
 
void setFrame (const std::vector< arma::mat > &f)
 Sets a number of frames for visualization. More...
 
void setVector (const std::vector< std::pair< arma::vec, arma::vec >> &v)
 
void waitNextCycle ()
 Sets a new reference for the controller. More...
 
- Public Member Functions inherited from arl::robot::Controller
 Controller (std::shared_ptr< Robot > r, const std::string &name, Timing timing=FIXED)
 Constructor which initializes the robot controller. More...
 
 ~Controller ()
 
bool run ()
 The main function that runs the controller. More...
 
bool runRT ()
 Runs the controller with real time priority. More...
 
void setExternalStop (bool arg)
 Sets an external stop to the controller. Another external thread can use this function to stop the controller. More...
 
std::string getName ()
 Returns the name of the controller. More...
 
double getTime () const
 Returns the current time since the start of the controller in seconds. More...
 
virtual void enableLogging (const std::string &log_path="/home/user/autharl_logfiles/")
 Enables the logging by opening files for log benchmarking times and data. More...
 
virtual void reference (const arma::mat &ref)
 

Protected Attributes

viz::RVisualizer rviz
 
ros::Rate loop_rate
 
- Protected Attributes inherited from arl::robot::Controller
std::string name
 The name of the controller. More...
 
bool external_stop
 The external stopped setted by Controller::setExternalStop() More...
 
std::shared_ptr< Robotrobot
 The pointer to the robot to be controlled. More...
 
double t
 The current time t, with t = 0 when the controller is created. Alternatively the user can initialize time durint the init() function of its derived controller. More...
 
double dt
 The cycle time of the control loop, obtained by the robot. More...
 
bool stop_flag_
 
utils::Timer timer
 Used for measuring the current time of the controller. More...
 
utils::Timer benchmark_total_timer_
 
utils::Timer benchmark_timer_
 
io::Logger benchmark_logger_
 
io::Logger logger_
 
Timing timing_
 

Additional Inherited Members

- Public Types inherited from arl::robot::Controller
enum  Timing { FIXED, DYNAMIC }
 
- Protected Member Functions inherited from arl::robot::Controller
virtual void init ()
 Initializes the controller. More...
 
virtual bool success ()
 Implements the success condition of your controller. More...
 

Detailed Description

A class which implements a controller for robot visualization in RViz.

Constructor & Destructor Documentation

arl::viz::RosStatePublisher::RosStatePublisher ( std::shared_ptr< robot::Robot r,
const std::string &  joint_state_topic = "/autharl_joint_state",
double  rate = 50,
const std::string &  frame = "world",
const std::string &  topic = "/autharl_viz" 
)
explicit

The default constructor.

Parameters
rA pointer to the robot for visualization
rateThe rate for the visualization in Hz. Defaults to 50 Hz.
frameThe base frame that which data will be expressed. Defaults to "world".
topicThe topic that RViz reads for the data. Defaults to "/autharl_viz".
arl::viz::RosStatePublisher::RosStatePublisher ( std::shared_ptr< robot::Robot r,
std::shared_ptr< robot::Sensor s,
const std::string &  joint_state_topic = "/autharl_joint_state",
double  rate = 50,
const std::string &  frame = "world",
const std::string &  topic = "/autharl_viz" 
)
explicit

The default constructor.

Parameters
rA pointer to the robot for visualization
rateThe rate for the visualization in Hz. Defaults to 50 Hz.
frameThe base frame that which data will be expressed. Defaults to "world".
topicThe topic that RViz reads for the data. Defaults to "/autharl_viz".

Member Function Documentation

void arl::viz::RosStatePublisher::command ( )
virtual

Publishes the measured joint positions and other data in RViz.

Reimplemented from arl::robot::Controller.

Here is the call graph for this function:

void arl::viz::RosStatePublisher::measure ( )
virtual

Measures the current state of the robot (Joint Positions).

Reimplemented from arl::robot::Controller.

void arl::viz::RosStatePublisher::setFrame ( const std::vector< arma::mat > &  f)

Sets a number of frames for visualization.

Another thread can use this function in order to visualize a set of frames in the given loop rate.

Parameters
fThe frames for visualization
void arl::viz::RosStatePublisher::setVector ( const std::vector< std::pair< arma::vec, arma::vec >> &  v)
bool arl::viz::RosStatePublisher::stop ( )
virtual

The stop condition of the controller which is that ROS is ok.

Reimplemented from arl::robot::Controller.

void arl::viz::RosStatePublisher::update ( )
virtual

Updates ROS data structures with the readings from the robot.

Implements arl::robot::Controller.

void arl::viz::RosStatePublisher::waitNextCycle ( )
virtual

Sets a new reference for the controller.

Implemented according to your controller needs. The data has the form of an armadillo matrix which can contain any reference signal.

Parameters
refThe data reference in the form of a matrix

Reimplemented from arl::robot::Controller.

Member Data Documentation

ros::Rate arl::viz::RosStatePublisher::loop_rate
protected
viz::RVisualizer arl::viz::RosStatePublisher::rviz
protected