dynamic_graph_manager
dynamic_graph_manager::SimpleDGM Class Reference

This class is a simple dynamic graph manager with a fake hardware interface used for unittesting. More...

#include <simple_dgm.hpp>

Inheritance diagram for dynamic_graph_manager::SimpleDGM:
Collaboration diagram for dynamic_graph_manager::SimpleDGM:

Public Member Functions

 SimpleDGM ()
 Construct a new SimpleDGM object.
 
 ~SimpleDGM ()
 Destroy the SimpleDGM object.
 
void initialize_hardware_communication_process ()
 Simple overload doing nothing. More...
 
void get_sensors_to_map (dynamic_graph::VectorDGMap &map)
 Get the sensors to the map object. More...
 
void set_motor_controls_from_map (const dynamic_graph::VectorDGMap &map)
 Set the motor controls from map object to no hardware. More...
 
bool get_has_user_command_been_executed ()
 Get the has_user_command_been_executed_ object.
 
bool user_command_callback (dynamic_graph_manager::TestUserCmdBool::Request &req, dynamic_graph_manager::TestUserCmdBool::Response &res)
 This service callback parse the ros messages and register and internal method for further call using the data from the ros message. More...
 
bool is_in_safety_mode ()
 is_in_safety_mode check if the dynamic graph is still alive and sending commands at a descent frequency. More...
 
void compute_safety_controls ()
 compute_safety_controls computes safety controls very fast in case the dynamic graph is taking to much computation time or has crashed.
 
- Public Member Functions inherited from dynamic_graph::DynamicGraphManager
 DynamicGraphManager ()
 DynamicGraphManager, constructor of the class.
 
virtual ~DynamicGraphManager ()
 DynamicGraphManager, destructor of the class.
 
void initialize (YAML::Node param)
 initialize the basic variables
 
void run ()
 run() splits the process in the dynamic_graph process and the hadware_communication process. More...
 
void wait_start_dynamic_graph ()
 wait_start_dynamic_graph put the current thread to sleep until the user start the dynamic graph
 
void wait_stop_dynamic_graph ()
 wait_stop_dynamic_graph put the current thread to sleep until the user stop the dynamic graph
 
void wait_stop_hardware_communication ()
 wait_stop_hardware_communication put the current thread to sleep until the user stop the hardware communication. More...
 
void initialize_dynamic_graph_process ()
 initialize_dynamic_graph_process instanciates all variables related to the dynamic_graph and user interface.
 
void run_python_command (std::ostream &file, const std::string &command)
 run_python_command More...
 
void python_prologue ()
 python_prologue get the pointer of the device in the the python interpretor.
 
virtual void run_dynamic_graph_process ()
 run_dynamic_graph_process spawns the real time thread and becomes a ros spinner (thread in charge of the ros::service callbacks). More...
 
virtual void run_hardware_communication_process ()
 run_hardware_communication_process spawns the real time thread. More...
 
virtual void run_single_process ()
 run_single_process spawns the real time thread. More...
 
void stop_dynamic_graph ()
 stop_dynamic_graph stop the DynamicGraph. More...
 
void start_dynamic_graph ()
 start_dynamic_graph start the DynamicGraph. More...
 
bool is_dynamic_graph_stopped ()
 get the status of the dynamic graph (is running or not) More...
 
void stop_hardware_communication ()
 stop_hardware_communication stops the hardware communication. More...
 
void start_hardware_communication ()
 start_hardware_communication starts the hardware communication. More...
 
bool is_hardware_communication_stopped ()
 get the status of the hardware communication (is running or not). More...
 
pid_t pid_dynamic_graph_process ()
 pid_dynamic_graph_process is an accessor on the pid of the process More...
 
pid_t pid_hardware_communication_process ()
 pid_hardware_communication_process is an accessor on the pid of the process More...
 
Devicedevice ()
 device is a getter method on the Device internal pointer. More...
 
bool has_dynamic_graph_process_died ()
 has_dynamic_graph_process_died check if the process of the DynamicGraph has died or not. More...
 

Private Member Functions

void user_command (bool user_input)
 The actuall user command called in the real time thread. More...
 

Private Attributes

std::atomic_bool boolean_set_by_user_cmd_
 
dynamicgraph::Vector desired_torques_
 
dynamicgraph::Vector desired_positions_
 

Additional Inherited Members

- Static Public Attributes inherited from dynamic_graph::DynamicGraphManager
static const std::string dg_ros_node_name_ = "dynamic_graph"
 dg_ros_node_name_ this is the ros node name of the dynamic graph process
 
static const std::string hw_com_ros_node_name_
 hw_com_ros_node_name_ this is the ros node name of the harware communication process More...
 
static const std::string shared_memory_name_ = "DGM_ShM"
 shared_memory_name is the name of the shared memory segment to be used
 
static const std::string sensors_map_name_ = "sensors_map"
 sensors_map_name is the name of the sensor map inside the shared memory segment
 
static const std::string motor_controls_map_name_
 motor_controls_map_name is the name of the motor controls map inside the shared memory segment More...
 
static const std::string cond_var_name_ = "cond_var"
 cond_var_sensors_name_ is the name of the condition variable in the shared memory
 
- Protected Member Functions inherited from dynamic_graph::DynamicGraphManager
void add_user_command (std::function< void(void)> func)
 Method inherited. More...
 
- Protected Attributes inherited from dynamic_graph::DynamicGraphManager
ros::ServiceServer ros_service_start_dg_
 ros_service_start_dg_ allows to start the dynamic graph on call. More...
 
ros::ServiceServer ros_service_stop_dg_
 ros_service_stop_dg_ allows to stop the dynamic graph on call. More...
 
std::atomic< bool > is_dynamic_graph_stopped_
 is_dynamic_graph_stopped_ is the flag reflecting the state of the dynamic graph. More...
 
std::atomic< bool > is_hardware_communication_stopped_
 is_hardware_communication_stopped_ is the flag reflecting the state of the hardware communication thread. More...
 
std::unique_ptr< dynamic_graph::RosPythonInterpreterros_python_interpreter_
 ros_python_interpreter_ptr_ is a ROS wrapper around a python interpreter.
 
std::unique_ptr< real_time_tools::RealTimeThread > thread_dynamic_graph_
 thread_dynamic_graph_ is the real time thread that runs the dynamic graph.
 
std::unique_ptr< real_time_tools::RealTimeThread > thread_hardware_communication_
 thread_hardware_communication_ is the real thread that communicate with the hardware.
 
pid_t pid_dynamic_graph_process_
 pid_dynamic_graph_process_ is the pid of the DynamicGraph process. More...
 
pid_t pid_hardware_communication_process_
 pid_hardware_communication_process_ is the pid of the hardware communication process. More...
 
std::unique_ptr< Devicedevice_
 device_ is the DynamicGraph device that manages the computation of the graph.
 
VectorDGMap sensors_map_
 sensors_map_ is a map of dynamicgraph::Vector. More...
 
VectorDGMap motor_controls_map_
 motor_controls_map_ is a map of dynamicgraph::Vector. More...
 
std::unique_ptr< shared_memory::LockedConditionVariable > cond_var_
 cond_var_sensors_ this condition variable allow the computation of the dynamic graph just after the acquisition of the sensors
 
bool has_been_waken_by_dg_
 has_been_waken_by_dg_ is a flag that indicates if the hardware communication process has been awaken by the dynamic_graph process or not.
 
unsigned missed_control_count_
 missed_control_count_ is counting the number of iteration when the dynamic_graph failed to provide data.
 
unsigned max_missed_control_
 max_missed_control_ if the missed_control_count_ reach the value of max_missed_control_ then we switch to safety mode.
 
clock::duration control_period_
 control_period_ this is the control period in nanoseconds.
 
clock::time_point hw_time_loop_before_sleep_
 hw_time_loop_before_sleep_ is the time measurement just before the hardware communication loop goes to sleep.
 
clock::time_point hw_time_loop_after_sleep_
 hw_time_loop_after_sleep_ is the time measurement just after the hardware communication loop goes to sleep.
 
clock::duration hw_meas_sleep_time_
 hw_measured_sleep_time_ is the time during which the hardware communication process actually slept.
 
clock::duration hw_ref_sleep_time_
 hw_ref_sleep_time_ is the time during which the hardware communication process is supposed to sleep.
 
clock::duration hw_meas_active_time_
 hw_meas_active_time_ is the time during which the hardware communication process is supposed to sleep.
 
bool is_real_robot_
 is_real_robot this boolean is a parameter to indicate if yes or no we are in simulation or in a real robot mode.
 
std::string dg_active_timer_file_
 dg_active_timer_file_ this is the path to the file that will contain the computation time of each of the dynamic graph complete execution.
 
std::string dg_sleep_timer_file_
 dg_sleep_timer_file_ this is the path to the file that will contain the sleep duration of the dynamic graph thread.
 
std::string dg_timer_file_
 dg_timer_file_ this is the path to the file that will contain the time of the dynamic graph loop.
 
std::string hwc_active_timer_file_
 hwc_active_timer_file_ this is the path to the file that will contain the computation time of each active period of the hardware communication loop.
 
std::string hwc_sleep_timer_file_
 hwc_sleep_timer_file_ this is the path to the file that will contain the sleeping time of the hardware communication loop.
 
std::string hwc_timer_file_
 hwc_timer_file_ this is the path to the file that will contain the computation time of each of the hardware communication complete execution.
 
std::string log_dir_
 log_folder_ is the folder where all the data of the current experiment will be saved.
 
std::string python_log_file_
 This file will contain the python interpreter output.
 
std::string app_dir_
 This is the application directory in the home directory.
 
real_time_tools::Timer dg_active_timer_
 dg_active_timer_ is the timer measuring the computation time of the dynamic graph loop.
 
real_time_tools::Timer dg_sleep_timer_
 dg_sleep_timer_ is the timer measuring the time during which the dynamic graph loop sleeps.
 
real_time_tools::Timer dg_timer_
 dg_timer_ is the timer measuring the duration time of the dynamic graph loop.
 
real_time_tools::Timer hwc_active_timer_
 hwc_active_timer is measuring the active time of the hardware communication loop
 
real_time_tools::Timer hwc_sleep_timer_
 hwc_sleep_timer is measuring the sleeping time of the hardware communication loop
 
real_time_tools::Timer hwc_timer_
 hwc_timer is measuring the time of the hardware communication loop
 
unsigned memory_buffer_timers_
 memory_buffer_timers_ is the size of the memory buffers for the real_time_tools timers.
 
real_time_tools::Spinner hwc_spinner_
 This class allows us to time the real time thread for the hardware communication.
 
double hwc_predicted_sleeping_time_
 This corresponds to the predicted sleeping time for the hardware communication process. More...
 
double maximum_time_for_user_cmd_
 This the duration during which a user command can be executed.
 
std::deque< std::function< void(void)> > user_commands_
 This is the list of the user commands.
 
std::deque< ros::ServiceServer > ros_user_commands_
 Attribute shared with the daughter class. More...
 
double control_period_sec_
 control_period_sec_ this is the control period in Seconds (S.I. More...
 
YAML::Node params_
 params_ is the pool of parameters in a yaml tree
 
std::mutex hwc_mutex_
 

Detailed Description

This class is a simple dynamic graph manager with a fake hardware interface used for unittesting.

Examples:
main.cpp.

Member Function Documentation

◆ get_sensors_to_map()

void dynamic_graph_manager::SimpleDGM::get_sensors_to_map ( dynamic_graph::VectorDGMap map)
inlinevirtual

Get the sensors to the map object.

Parameters
mapof sensors

Reimplemented from dynamic_graph::DynamicGraphManager.

Examples:
simple_dgm.hpp.

◆ initialize_hardware_communication_process()

void dynamic_graph_manager::SimpleDGM::initialize_hardware_communication_process ( )
inlinevirtual

Simple overload doing nothing.

We have no hardware here for the unit tests.

initialize the user commands

Reimplemented from dynamic_graph::DynamicGraphManager.

Examples:
simple_dgm.hpp.

◆ is_in_safety_mode()

bool dynamic_graph_manager::SimpleDGM::is_in_safety_mode ( )
inlinevirtual

is_in_safety_mode check if the dynamic graph is still alive and sending commands at a descent frequency.

Inheriting this method is not mandatory but recommanded.

Returns
true if there is a problem

Reimplemented from dynamic_graph::DynamicGraphManager.

Examples:
simple_dgm.hpp.

◆ set_motor_controls_from_map()

void dynamic_graph_manager::SimpleDGM::set_motor_controls_from_map ( const dynamic_graph::VectorDGMap map)
inlinevirtual

Set the motor controls from map object to no hardware.

So nothing to be done here

Parameters
mapof controls

Reimplemented from dynamic_graph::DynamicGraphManager.

Examples:
simple_dgm.hpp.

◆ user_command()

void dynamic_graph_manager::SimpleDGM::user_command ( bool  user_input)
inlineprivate

The actuall user command called in the real time thread.

Parameters
user_inputis some boolean
Examples:
simple_dgm.hpp.

◆ user_command_callback()

bool dynamic_graph_manager::SimpleDGM::user_command_callback ( dynamic_graph_manager::TestUserCmdBool::Request &  req,
dynamic_graph_manager::TestUserCmdBool::Response &  res 
)
inline

This service callback parse the ros messages and register and internal method for further call using the data from the ros message.

Parameters
reqthis is the user argument
resthis is the feedback of the user command
Returns
true in case the service hase been properly executed
false in case of failure
Examples:
simple_dgm.hpp.

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