Gazebo Simulator : ROS plugin to control actors

April 7, 2023

Author : Animesh Singhal

Read time 4 mins

Gazebo simulator is easily the most popular simulator in the robotics world. It’s a versatile tool that provides the necessary physics, graphics, and transport mechanisms to model a range of kinematic chains, dynamics, sensors, and environments. One particularly interesting but often underused functionality that comes with the simulator is Actors. Primarily they provide a means to simulate human movement in a Gazebo world, but can also be used to simulate animals, robots, or any other object. In this article, I cover why they are useful and also provide a ROS plugin (which is now open source!) to control the motion of actors through ROS APIs.

Actors in Gazebo

In Gazebo, an animated model is known as an Actor. The key characteristic that sets Actors apart from other models is that they do not inherit any physics properties such as collisions or forces. Actors are ideal for representing objects in the environment that are visible and can report sensor data but do not necessarily need to come into direct physical contact with the robot. For example, they may not be affected by gravity or collide with other objects, but they will have a 3D visualisation that RGB cameras can capture and 3D meshes that GPU-based depth sensors can detect.

Actors can be particularly useful in robotics simulations where realistic crowd or human-robot interactions need to be modeled. For example, to simulate crowd behavior, you may want to make the actors move more realistically instead of hard-coding their paths. Researchers in the field of human and animal flocking behavior have developed various algorithms that can be used to simulate realistic patterns of motion, allowing the actors to move more closely to how real people would move. This can be useful for simulating scenarios like an airport, or a hotel.

Another use case for Actors is responding to dynamic changes in the environment. For example, imagine a human that needs to perform an action when a robot reaches its designated position. Since the robot’s arrival time is not certain, the human’s action needs to be time-synced with the robot’s motion. This can be achieved using an Actor and a custom plugin that responds to the robot’s position updates and triggers the human’s action at the right time.

Actor Movement in Gazebo: Default Method

In addition to the animations that account for the relative motion within an actor, actors in Gazebo can also move as a whole along a trajectory defined by way-points in the .sdf file. This means the user can configure a pre-determined path and the Actor will perform a realistic-looking motion along that path. While it is useful to have a pre-configured path, it is often insufficient to model complex scenarios described earlier. Thankfully, Gazebo allows for custom plugins to extend functionality.

ROS APIs for Actor movement: Velocity and Path

We have developed a custom plugin called gazebo_ros_actor_plugin that allows for dynamic control over actors in the simulation environment. This plugin is specifically designed to listen to velocity and path commands through ROS topics, enabling users to easily manipulate the motion of actors and helping you in creating complex and realistic simulations of human-robot interactions.

The gazebo_ros_actor_plugin is built to support Gazebo Classic Version 11 and ROS. When the plugin receives a velocity command, it instantly sets the actor’s velocity to the specified value. On the other hand, when a path command is received, the plugin generates a trajectory for the actor to follow, controlling its pose accordingly. You can clone the plugin in your workspace and conveniently use it in your world files using the following code block in the actor’s SDF model file:

<plugin name="actor_plugin" filename="libgazebo_ros_actor_command.so">
<!-- Mode can be set to either path or velocity -->
<!-- <follow_mode>path</follow_mode> -->
<follow_mode>velocity</follow_mode>
<!-- Topic to which velocity commands will be published.  (default /cmd_vel)-->
<vel_topic>/cmd_vel</vel_topic>
<!-- Topic to which path commands will be published. (default /cmd_path.-->
<path_topic>/cmd_path</path_topic>
<!-- Multiplier to base animation speed that adjusts the speed of  both the actor's animation and foot swinging. -->
<animation_factor>4.0</animation_factor>
<!-- Distance threshold between actor and target pose during path-following -->
<linear_tolerance>0.1</linear_tolerance>
<!-- Speed at which actor moves during path-following -->
<linear_velocity>1</linear_velocity>
<!-- Angular difference in orientation between actor and target orientation -->
<angular_tolerance>0.05</angular_tolerance>
<!-- Angular speed at which actor rotates to achieve desired orientation -->
<angular_velocity>2.5</angular_velocity>
</plugin>

Once you’ve attached the gazebo_ros_actor_plugin to an actor model, you can use ROS messages to control the actor’s movement and behavior. The gazebo_ros_actor_plugin package includes two example publishers that send velocity or path commands to the actor. You can use these examples, publishers, as a reference to create your own ROS node that sends commands to the actor.

Conclusion

Gazebo simulator actors are an essential component of robotics simulation, allowing users to create realistic environments to test and develop their robots. The gazebo_ros_actor_plugin extends the functionality of Gazebo actors by adding ROS APIs to enable path and velocity-based control. With this plugin, you can create more interactive Gazebo simulations that allow you to control actors using ROS messages.

Looking to create realistic simulations for your robotics applications? Reach out to us!

Want to reduce costs and time to market for your autonomous robots?