robot_hw_sim_latency
Custom gazebo_ros_control simulation plugin that can add latency to communication between ros_control and gazebo
Description
robot_hw_sim_latency
Modification of the default_robot_hw_sim plugin to allow loading custom plugins that can add latency between ros_control and gazebo.
latency_plugin_simple_queue
Simple example latency plugin using queues
Installation
I assume a catkin workspace is already set up, and gazebo_ros_pkgs is installed.
- Copy the two folders(robot_hw_sim_latency, latency_plugin_simple_queue) to your workspace
- Run
catkin_make
Usage
- To configure gazebo_ros_control to load robot_hw_sim_latency plugin instead of the default, modify your robot's urdf:
Example: If using UR robots, change https://github.com/ros-industrial/universal_robot/blob/kinetic-devel/ur_description/urdf/common.gazebo.xacro
<gazebo>
<plugin name="ros_control" filename="libgazebo_ros_control.so">
<!--robotNamespace>/</robotNamespace-->
<robotSimType>robot_hw_sim_latency/RobotHWSimLatency</robotSimType>
<!--robotSimType>gazebo_ros_control/DefaultRobotHWSim</robotSimType-->
</plugin>
</gazebo>
- To configure robot_hw_sim_latency to load a custom latency plugin (like latency_plugin_simple_queue) instead of the default, set the
/robot_hw_sim_latency/latency_plugin
parameter on the Parameter Server.
Example using roslaunch:
<rosparam param="/robot_hw_sim_latency/latency_plugin">latency_plugin_simple_queue/SimpleQueueLatencyPlugin</rosparam>
- To configure the length of queue in latency_plugin_simple_queue, set the
/latency_plugin_simple_queue/queue_length
parameter on the Parameter Server.
Example using roslaunch:
<rosparam param="/latency_plugin_simple_queue/queue_length">10</rosparam>
Detailed working mechanism of the system
The working mechanism of the system is the following:
- The gazebo_ros_control update function fires
- it calls the readSim function; the call is executed in the RobotHWSimLatency plugin which implements the readSim function
- the states are read from the gazebo internals
- the delayStates function is called in the Simple queue latency plugin that saves the state messages in a buffer
- the previously stored and now delayed states are returned from the Simple queue latency plugin to the RobotHWSimLatency plugin
- readSim writes the joint_states to the JointStateInterface of the Harware Resource Interface Layer
- gazebo_ros_control calls the update function of the controler_manager
- the joint_trajectory_controller in the controller manager executes the calculation of the PID-controllers
- the joint_trajectory_controller writes the calculated velocity commands to the VelocityInterface of the Hardware Resource Interface Layer
- the gazebo_ros_control calls the writeSim function which is implemented in the RobotHWSimLatency plugin
- the writeSim function reads the joint commands from the VelocityInterface of the Hardware Resource Interface Layer
- the writeSim function calls the delayCommands function of the Simple queue latency plugin
- the previously stored and now delayed commands are returned from the Simple queue latency plugin to the RobotHWSimLatency plugin
- the writeSim function writes the joint commands to the gazebo internals
- Gazebo calculate the internal states of the simulation loop
- a new simulation loop is started by calling the update function of the gazebo_ros_control plugin
How to cite?
@article{gazebopluginconf,
author = {G. Szabo and S. Racz and J. Peto and R. R. Aschoff},
title = {On The Effects of The Variations In Network Characteristics In Cyber Physical Systems},
journal = {In Proc., 31st European Simulation and Modelling Conference},
year = {2017},
month = {Oct.}
location = {Lisbon, Portugal}
}