This tutorial describes how to use elevators in Gazebo. An elevator in Gazebo consists of a car, that moves up and down, with a door. Primatic joints control the car and door.
The elevator functionality is implemented through an ElevatorPlugin. This plugin controls two prismatic joints:
During the plugin's update cycle, the lift joint will move the elevator to the requested floor, and the door joint will open or close the door depending on the elevator's current state. Movement to a particular floor can be requested by sending a string message with the floor number to the elevator's topic. Specification of these parameters is described in the following section.
The elevator's control logic is:
Floor requests are not queued, and the elevator will complete its movement before responding to a new request.
The lift joint, door joint, floor height, and control topic are all specified in SDF. The following is an example:
<plugin filename="libElevatorPlugin.so" name="elevator_plugin"> <lift_joint>elevator::lift</lift_joint> <door_joint>elevator::door</door_joint> <floor_height>3.075</floor_height> <topic>~/elevator</topic> </plugin>
In this example, an
elevator model exists elsewhere in the SDF file with
a joint for lifting called
lift, and a joint for the door called
The height of each floor is 3.075 meters, and the elevator plugin listens
for floor requests on the
A complete example world is distributed with Gazebo. You can run this world using the following command:
This world has two floors and a single elevator. Place a simple shape on the landing in front of the elevator to trigger a floor request. This floor request takes place thanks to the Occupied Region Event, described next.
The elevator plugin works well the OccupiedEvent component of the SimEventPlugin. The OccupiedEvent sends a message whenever a 3D region becomes occupied with a model. Refer to the OccupiedEvent tutorial for more information.