ROS node, getting sensors data and sending commands. More...
#include <ROS_node.hpp>
Public Types | |
typedef ::ros::console::Level | LogLevel |
Log severity levels, comming from ROS::console. More... | |
Signals | |
void | loggingUpdated () |
Signals the GUI for log's update. More... | |
Public Member Functions | |
bool | connected () const |
Indicates whether the node is connected to ROS. More... | |
void | end () |
Stops ROS if it has been started. More... | |
void | init (Controller &ctrl) |
Connects to ROS server with main arguments. More... | |
void | init (const std::string &master_url, const std::string &host_url, Controller &ctrl) |
Connects to ROS server with parameters. More... | |
void | log (const LogLevel &level, const std::string &msg) |
Writes a message at given level in the log. More... | |
QStringListModel & | loggingModel () |
The Qt object used to show the logs. More... | |
ROSnode (const int argc, char **argv) | |
The constructor requires main() 's arguments (they can be forwarded to ROS). More... | |
std::string | worldCommandFile (const bool empty=true) |
File name for the script starting the simulation. More... | |
Protected Member Functions | |
void | run () |
Main loop of the process (on a separate thread). More... | |
Private Member Functions | |
void | newOdometry (const nav_msgs::Odometry::ConstPtr &odom) |
Sends the odometry data to the controller. More... | |
void | ROSsetup (Controller &ctrl) |
Common part of the two initialisation methods. More... | |
Private Attributes | |
ros::Publisher | cmd_publisher |
ROS object used to send the velocities. More... | |
QStringListModel | log_model |
Qt object used to show the logs in the GUI. More... | |
Controller * | motion_ctrl |
A pointer to the controller of the motion. More... | |
ros::Subscriber | odom_subscriber |
ROS object used to get the odometry. More... | |
int | ROS_argc |
Main arguments' count, forwarded to ROS. More... | |
char ** | ROS_argv |
Main arguments' values, forwarded to ROS. More... | |
ROS node, getting sensors data and sending commands.
This class is the one in charge of the communication with ROS. It only sends commands through a publisher, for the moment. It is a QThread, i.e. a process which runs its main loop in a separate thread. This class is a slight modification of the one generated by catkin_create_qt_pkg
.
Definition at line 42 of file ROS_node.hpp.
typedef ::ros::console::Level ROSnode::LogLevel |
Log severity levels, comming from ROS::console.
Definition at line 112 of file ROS_node.hpp.
|
inline |
The constructor requires main()
's arguments (they can be forwarded to ROS).
argc | the arguments' count, |
argv | the arguments' value. |
Definition at line 122 of file ROS_node.hpp.
|
inline |
Indicates whether the node is connected to ROS.
Definition at line 135 of file ROS_node.hpp.
void ROSnode::end | ( | ) |
Stops ROS if it has been started.
See ROS Namespace, QThread.
Definition at line 17 of file ROS_node.cpp.
|
inline |
Connects to ROS server with main
arguments.
ctrl | the motion controller. See ROS Namespace, ROSsetup(). |
Definition at line 141 of file ROS_node.hpp.
void ROSnode::init | ( | const std::string & | master_url, |
const std::string & | host_url, | ||
Controller & | ctrl | ||
) |
Connects to ROS server with parameters.
master_url | the URI of the ROS master, |
host_url | the URI of the host, |
ctrl | the motion controller. |
See ROS Namespace, ROSsetup().
Definition at line 118 of file ROS_node.cpp.
void ROSnode::log | ( | const LogLevel & | level, |
const std::string & | msg | ||
) |
Writes a message at given level in the log.
level | the log's severity level, |
msg | the message. |
See ROS::console, ROS::Time, QStringListModel, connected(), loggingModel(), loggingUpdated().
Definition at line 135 of file ROS_node.cpp.
|
inline |
The Qt object used to show the logs.
Definition at line 158 of file ROS_node.hpp.
|
signal |
Signals the GUI for log's update.
See GUI and multi-thread.
|
private |
Sends the odometry data to the controller.
odom | the new odometry data. |
Definition at line 64 of file ROS_node.cpp.
|
private |
Common part of the two initialisation methods.
ctrl | the motion controller. See ROS Namespace, ROS::Publisher, QThread. |
Definition at line 34 of file ROS_node.cpp.
|
protected |
Main loop of the process (on a separate thread).
See QThread, ROS::Rate, stop(), geometry_msgs::Twist, ROS Namespace, log(const LogLevel&, const std::string&), ROS::Publisher, ROSshutdown().
Definition at line 89 of file ROS_node.cpp.
|
inline |
File name for the script starting the simulation.
empty | Wether an empty workspace is wanted. |
Definition at line 163 of file ROS_node.hpp.
|
private |
ROS object used to send the velocities.
See ROS::Publisher.
Definition at line 60 of file ROS_node.hpp.
|
private |
Qt object used to show the logs in the GUI.
See QStringListModel.
Definition at line 78 of file ROS_node.hpp.
|
private |
A pointer to the controller of the motion.
A NULL value indicates the node is not connected to ROS.
Definition at line 54 of file ROS_node.hpp.
|
private |
ROS object used to get the odometry.
While this object is not used outside of the constructor, it has to remain defined as long as the ROS node exists, as it is in charge of transmitting the odometry's data to the method which handle them.
See ROS::Subscriber.
Definition at line 71 of file ROS_node.hpp.
|
private |
Main arguments' count, forwarded to ROS.
Definition at line 45 of file ROS_node.hpp.
|
private |
Main arguments' values, forwarded to ROS.
Definition at line 46 of file ROS_node.hpp.