228 lines
20 KiB
Markdown
228 lines
20 KiB
Markdown
# Two-floor elevator simulation
|
|
|
|
This package provides an isolated Gazebo Classic world, two floor maps, a simulated elevator ROS API, and a test-only floor transition action for the T800 robot. It does not call a real elevator vendor API and does not publish `/cmd_vel`.
|
|
|
|
For ROS connection setup, complete service/action contracts, manual ride commands, fault scenarios, and troubleshooting, see [the detailed elevator API and test guide](docs/SIM_ELEVATOR_CONNECTION_API_GUIDE.md).
|
|
|
|
For the bundled model inventory, asset checks, regeneration order, and Git staging commands, see [the model portability guide](docs/MODEL_PORTABILITY_AND_WORLD_GUIDE.md).
|
|
|
|
For a runnable C++ service/topic client, see [the C++ client guide](docs/CPP_API_CLIENT_GUIDE.md) and `src/elevator_cpp_example.cpp`. The example builds as `elevator_cpp_example`; its default command reads status.
|
|
|
|

|
|
|
|

|
|
|
|
*Gazebo Classic screenshot from the standalone world launch, with the elevator at floor 1.*
|
|
|
|
The warehouse has 92 x 92 m floor plates in 102.4 x 102.4 m maps at 0.05 m/cell. Floor 2 is at z=28 m, with a 24 x 28 m atrium and a closed, collision-guarded stairwell opening. The warehouse has receiving, pallet storage, conveyors, work cells, QC stations, and four walking actors with bone collisions (two per floor). Gazebo opens synchronized paired elevator doors from the center. Car and door motion use eased kinematic animation for visibility, not a mechanical or certification model.
|
|
|
|
The cabin center is at `(39.0, 0.0)` near the positive X edge of each floor. The entrance faces negative X; the default exit point is `(35.5, 0.0)`. The 28 m rise uses a 2.2 m/s average travel setting (about 12.7 s between floors). All warehouse and walking-person meshes referenced by the world are under this package's `models/` directory; see [third-party asset provenance](THIRD_PARTY_ASSETS.md).
|
|
|
|
The world uses ambient lighting and one directional sun light. Its former 24 ceiling point lights were removed after a same-world Gazebo comparison showed much smoother camera orbit and zoom without them. The floor layout, collisions, actors, LiDAR behavior, and elevator API are unchanged by this lighting change.
|
|
|
|
The two floor decks have a level top surface at z=0 m and z=28 m. Their adjacent sections are merged into 4 and 10 collision boxes respectively, with the lift, atrium, and stair openings retained. Colored floor zones and warning stripes use visual-only planes just above that surface; they have no thickness, collision, or shadow casting, so they do not create raised patches for the robot.
|
|
|
|
The enclosed stairwell contains eight switchback flights and seven intermediate landings. Its footprint remains blocked in the 2D navigation maps, and the guarded floor-2 opening is not a robot route.
|
|
|
|
The green storage area has 25 shelves on each floor (2.5 times the previous 10). Both columns fit inside the painted area, including their collision footprints, and retain a 3.3 m gap between columns. Floor 2 has staggered intermediate shelves, a shifted and rotated northern workcell, a shifted northern production line, and an inspection bench. The floor maps are generated from the corresponding shelf and equipment positions.
|
|
|
|
Floor 2 uses the uniquely named `two_floor_workcell_open` model: its walls, pillars, staircase, attached doors/windows, raised floor, and overhead conveyor frame are removed. Its shelves, pallets, control panel, and low conveyor remain with collision. Floor 1 uses `two_floor_workcell_enclosed` with the original walls, pillars, staircase, doors and equipment inside the warehouse shell. Only the duplicate model floor and the parts outside the perimeter are removed. The unique `model://` names prevent Gazebo from resolving the different `workcell` model in `factory_ss_demo` or a Gazebo cache. To regenerate the assets after changing the original mesh, run `scripts/make_open_workcell_mesh.py`, then `scripts/clip_floor1_workcell.py`, then `scripts/generate_maps.py`. The generated navigation maps use the collision boxes of the corresponding floor's model, excluding walkable floor collision.
|
|
|
|
On floor 1, `assembly_workcell_f1_0` is at `(35.98, -36.74)` with yaw `+90` degrees in the south-east corner; `assembly_workcell_f1_1` is at `(36.74, 35.98)` with yaw `180` degrees in the north-east corner. The original workcell has two perpendicular walls. The north-east instance needs a 180-degree absolute yaw to put both walls against the north and east shell; the two floor-1 orientations differ by 90 degrees. The floor-1 workcell mesh and boxes are clipped at the shell's outer faces (`x/y = +/-46.15 m` in world coordinates), so no workcell geometry protrudes outside the map perimeter. The floor-1 shell height matches the original workcell wall top at 7.25 m. Floor-2 workcell positions and the elevator are unchanged.
|
|
|
|
Each walking actor travels along a clear aisle, rotates in place for four seconds at the endpoint, walks back facing the new direction, and rotates again before the route loops. The generator checks that every moving segment faces its travel direction. The turn waypoints follow the approach in the [warehouse simulation toolkit world](https://github.com/wh200720041/warehouse_simulation_toolkit/blob/master/worlds/warehouse.world). The walking mesh is the same `walk.dae` used by `factory_ss_demo`; the difference is that its people load `libPedestrianSFMPlugin.so` with collision scales for leg bones. This package supplies its own small `libtwo_floor_elevator_walking_actor_collision_plugin.so` to enable those actor bone collisions without taking over the scripted walking and turning.
|
|
|
|
All 17 warehouse model directories (including the derived floor-1 workcell) and the walking actor mesh are bundled in `models/`. Every world model URI now starts with `model://two_floor_`, so Gazebo does not need `factory_ss_demo` or select a same-named model from another search path. Before pushing a copy of this package, run `python3 scripts/check_model_assets.py` from the package directory. It checks the world, model metadata, mesh files, and texture references. The model source and license evidence are recorded in [THIRD_PARTY_ASSETS.md](THIRD_PARTY_ASSETS.md). The full navigation launch still needs the robot and navigation packages declared in `package.xml`.
|
|
|
|
The shaft footprint is occupied in both static floor maps. The active `/map` clears only the aligned cabin and doorway when the car is at that map's floor and its doors are fully open. Gazebo also has collision guardrails along the sides and rear of each landing opening, with the landing doors protecting the entrance.
|
|
|
|
The map switcher closes that access again if elevator state has not refreshed for 1 second (wall time). The world launch sets its shaft overlay shift to `(35.72, 0.0)` to match the relocated cabin.
|
|
|
|
## Build environment and common failures
|
|
|
|
The supported native build target is Ubuntu 20.04 (Focal, amd64) with ROS Noetic and Gazebo Classic 11. Install ROS, Gazebo, Ignition Messages/Transport, and Protobuf from the same Focal package repositories. Having Ubuntu 20.04 alone does not guarantee a matching toolchain: local installations under `/usr/local` or Conda can take precedence over the OS packages.
|
|
|
|
### Protobuf and Ignition header mismatch
|
|
|
|
Gazebo's `Actor.hh` includes Ignition Transport 8, which uses generated message headers from Ignition Messages 5. Those headers depend on Protobuf's C++ API. A common failure is compiling the Focal Ignition headers against a custom Protobuf under `/usr/local`; errors can mention `SerializationTable`, `InternalMetadataWithArena`, `ArenaStringPtr`, or methods marked `final` that do not override a virtual method. These are dependency-version errors in generated/system headers, not syntax errors in this package's plugin source.
|
|
|
|

|
|
|
|
For the Focal apt package set used by this package, the expected Protobuf toolchain reports `3.6.1`, and the compiler must resolve Protobuf headers from `/usr/include`. Check all three paths from a terminal before building:
|
|
|
|
```bash
|
|
source /opt/ros/noetic/setup.bash
|
|
command -v protoc
|
|
protoc --version
|
|
PKG_CONFIG_PATH= PKG_CONFIG_LIBDIR=/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig pkg-config --modversion protobuf
|
|
printf '#include <google/protobuf/stubs/common.h>\n' | g++ -E -H -x c++ - 2>&1 | head -n 1
|
|
```
|
|
|
|
Expected results are `/usr/bin/protoc`, `libprotoc 3.6.1`, `3.6.1`, and a header path beginning `/usr/include/google/protobuf/`. `command -v protoc` and `pkg-config` alone are not sufficient: GCC normally searches `/usr/local/include` before `/usr/include`, so a custom header there can still override the Focal header even when `/usr/bin/protoc` is selected. Remove or isolate the custom Protobuf installation for the build; do not mix it with the Focal `libignition-msgs5-dev` package. If using another Protobuf version intentionally, rebuild Ignition Messages, Ignition Transport, and Gazebo against that same version.
|
|
|
|
After correcting the dependency paths, run the build from the catkin workspace root. Remove only that workspace's generated `build/` and `devel/` directories first so CMake does not reuse cached paths to the old Protobuf installation:
|
|
|
|
```bash
|
|
# Run these commands from your catkin workspace root.
|
|
rm -rf build devel
|
|
source /opt/ros/noetic/setup.bash
|
|
catkin_make --pkg two_floor_elevator_sim
|
|
source devel/setup.bash
|
|
```
|
|
|
|
For repeatable builds across machines, use one container image pinned by digest and retain that image in a registry or local archive. This repository currently documents native builds and does not include a pinned build container. ROS Noetic and Ubuntu Focal reached end of life on May 31, 2025, so keep the build image and dependency versions available locally for future rebuilds ([ROS Noetic EOL notice](https://discourse.ros.org/t/ros-noetic-end-of-life-may-31-2025/43160)).
|
|
|
|
## Verify that the moving workers appear in LiDAR
|
|
|
|
From the workspace, build the package and source its setup file, then start a stationary T800 on the floor-1 dispatch aisle:
|
|
|
|
```bash
|
|
cd ~/T800_ws
|
|
source /opt/ros/noetic/setup.bash
|
|
catkin_make --pkg two_floor_elevator_sim
|
|
source devel/setup.bash
|
|
roslaunch two_floor_elevator_sim two_floor_elevator_world.launch robot_x:=31.0 robot_y:=0.0 start_amcl:=false
|
|
```
|
|
|
|
In another terminal, confirm the front scan is publishing, then display `/f_scan` in RViz:
|
|
|
|
```bash
|
|
cd ~/T800_ws
|
|
source /opt/ros/noetic/setup.bash
|
|
source devel/setup.bash
|
|
rostopic hz /f_scan
|
|
```
|
|
|
|
`worker_dispatch_f1` crosses roughly 3 m ahead of this pose on its trip along `(34, -12)` to `(34, 12)`. Watch for scan points to move with its lower legs; a single scan can miss the person before it reaches the beam. Check the Gazebo startup output for four `initialized ... bone collisions for ray LiDAR` messages. If Gazebo says that the plugin library cannot be loaded, source the rebuilt `devel/setup.bash` in the launch terminal and check `devel/lib/libtwo_floor_elevator_walking_actor_collision_plugin.so`.
|
|
|
|
This is a Gazebo ray-sensor test. The static floor maps do not contain moving people, and the worker positions are not published as a separate detection topic.
|
|
|
|
## Start the full navigation simulation
|
|
|
|
Build/source the workspace in the usual project environment, then run:
|
|
|
|
```bash
|
|
roslaunch two_floor_elevator_sim two_floor_elevator_nav.launch
|
|
```
|
|
|
|
The launch starts Gazebo, spawns the T800 at floor 1, loads the floor maps and active `/map`, starts AMCL and `amr_control`, then exposes the elevator action. Set `gazebo_gui:=false` or `rviz:=false` for a lighter run. `two_floor_elevator_world.launch` starts Gazebo, maps, map switching, and AMCL without the navigation host or transition manager.
|
|
|
|
## Start the map and elevator without a robot
|
|
|
|
```bash
|
|
roslaunch two_floor_elevator_sim two_floor_elevator_standalone.launch
|
|
```
|
|
|
|
This starts Gazebo, the elevator plugin, both map servers, and the active-map switcher. By default it does not spawn the T800 or start AMCL/navigation. To place the robot in the cabin for a manual ride, set `spawn_robot:=true`; the robot faces the doors and this launch still does not start AMCL or `amr_control`:
|
|
|
|
```bash
|
|
roslaunch two_floor_elevator_sim two_floor_elevator_standalone.launch spawn_robot:=true
|
|
```
|
|
|
|
Test floor-map switching with:
|
|
|
|
```bash
|
|
rosservice call /floor_map_switcher/switch "{floor_id: 'floor_2'}"
|
|
rostopic echo -n 1 /sim_elevator/active_floor
|
|
rosservice call /floor_map_switcher/switch "{floor_id: 'floor_1'}"
|
|
```
|
|
|
|
Without a robot, test elevator travel by calling the car at the other floor. The car arrives and opens its doors; close the doors, then call it back from the opposite floor. `select_floor` and the orchestrated `/sim_elevator/ride` action require a robot in the cabin and are not part of this standalone test.
|
|
|
|
With `spawn_robot:=true`, monitor `/sim_elevator/state`, open at floor 1, then select floor 2. The plugin carries the stationary Gazebo robot model while the car moves; no navigation goal is sent:
|
|
|
|
```bash
|
|
rosservice call /sim_elevator/call "{elevator_id: 'sim_elevator', pickup_floor: 'floor_1', direction: 'UP', request_id: 'visual-ride-1'}"
|
|
```
|
|
|
|
Wait until state is `WAITING_BOARDING`, `door_state: 2`, and `robot_boarded: true`. If you need more than the 12-second default open interval, hold the doors before selecting the destination:
|
|
|
|
```bash
|
|
rosservice call /sim_elevator/door_command "{elevator_id: 'sim_elevator', car_id: 'sim_car_1', command: 2, lease_seconds: 90.0, request_id: 'visual-ride-1'}"
|
|
```
|
|
|
|
Then select the destination:
|
|
|
|
```bash
|
|
rosservice call /sim_elevator/select_floor "{elevator_id: 'sim_elevator', car_id: 'sim_car_1', floor_id: 'floor_2', request_id: 'visual-ride-1'}"
|
|
```
|
|
|
|
The robot must be fully stopped in the cabin. The plugin carries the Gazebo robot model with the car, so the floor separation and car motion are visible without sending a navigation goal. This is a kinematic visual test; the robot is not autonomously driving into the elevator.
|
|
|
|
For example, monitor `/sim_elevator/state`, reset the empty car, and call it from floor 2:
|
|
|
|
```bash
|
|
rosservice call /sim_elevator/reset "{}"
|
|
rosservice call /sim_elevator/call "{elevator_id: 'sim_elevator', pickup_floor: 'floor_2', direction: 'DOWN', request_id: 'standalone-up-1'}"
|
|
```
|
|
|
|
When the state reports `current_floor: floor_2` and `door_state: 2` (open), test hold, release, and close:
|
|
|
|
```bash
|
|
rosservice call /sim_elevator/door_command "{elevator_id: 'sim_elevator', car_id: 'sim_car_1', command: 2, lease_seconds: 10.0, request_id: 'standalone-up-1'}"
|
|
rosservice call /sim_elevator/door_command "{elevator_id: 'sim_elevator', car_id: 'sim_car_1', command: 3, lease_seconds: 0.0, request_id: 'standalone-up-1'}"
|
|
rosservice call /sim_elevator/door_command "{elevator_id: 'sim_elevator', car_id: 'sim_car_1', command: 1, lease_seconds: 0.0, request_id: 'standalone-up-1'}"
|
|
```
|
|
|
|
After the state returns to `IDLE` with `door_state: 0`, call the car back to floor 1:
|
|
|
|
```bash
|
|
rosservice call /sim_elevator/call "{elevator_id: 'sim_elevator', pickup_floor: 'floor_1', direction: 'UP', request_id: 'standalone-down-1'}"
|
|
```
|
|
|
|
## Run a floor-to-floor ride
|
|
|
|
```bash
|
|
rosrun two_floor_elevator_sim send_ride_goal.py floor_1 floor_2 180 31.0 6.0 3.14
|
|
```
|
|
|
|
Run the reverse route with `floor_2 floor_1`. The final three numbers are an optional destination `(x, y, yaw)` on the destination floor; omit them to stop at the exit pose. The action drives the robot to the cabin, asks the simulated elevator to select the destination, switches `/map`, republishes `/initialpose`, waits for AMCL at the cabin pose, navigates out, and optionally continues to the final goal. Same-floor navigation remains a normal navigation goal and does not use the ride action.
|
|
|
|
## Simulated elevator API
|
|
|
|
The plugin exposes these ROS interfaces:
|
|
|
|
| Name | Type | Purpose |
|
|
|---|---|---|
|
|
| `/sim_elevator/call` | `two_floor_elevator_sim/CallElevator` | Call the car at a pickup floor (`direction` is `UP` or `DOWN`). |
|
|
| `/sim_elevator/select_floor` | `two_floor_elevator_sim/SelectFloor` | Select a destination from the stopped, open cabin after the robot boards. |
|
|
| `/sim_elevator/door_command` | `two_floor_elevator_sim/DoorCommand` | Request `OPEN`, `CLOSE`, `HOLD_OPEN`, or `RELEASE_HOLD`. |
|
|
| `/sim_elevator/reserve` | `two_floor_elevator_sim/ReserveElevator` | Reserve/release the car with a finite lease. |
|
|
| `/sim_elevator/state` | `two_floor_elevator_sim/SimElevatorState` | Latched elevator state, floor, door, alignment, reservation, and robot boarding status. |
|
|
| `/sim_elevator/ride` | `two_floor_elevator_sim/SimElevatorRideAction` | Orchestrated ride with state feedback, timeout, and action cancel. |
|
|
| `/sim_elevator/reset` | `two_floor_elevator_sim/ResetElevator` | Reset an empty car to floor 1; if a robot or detected cargo is inside, move the cabin to the nearest floor and open. |
|
|
| `/sim_elevator/inject_fault` | `two_floor_elevator_sim/InjectFault` | Inject or clear `BUSY`, `DOOR_BLOCKED`, `TRAVEL_TIMEOUT`, and `WRONG_FLOOR`. |
|
|
| `/sim_elevator/emergency_stop` | `two_floor_elevator_sim/EmergencyStop` | Latch an emergency stop; reset is required afterward. |
|
|
| `/floor_map_switcher/switch` | `two_floor_elevator_sim/SwitchFloorMap` | Publish the selected floor map on `/map`. |
|
|
|
|
Examples for isolated service testing (do not run concurrently with an action ride):
|
|
|
|
```bash
|
|
rosservice call /sim_elevator/call "elevator_id: 'sim_elevator' pickup_floor: 'floor_1' direction: 'UP' request_id: 'manual-1'"
|
|
rostopic echo /sim_elevator/state
|
|
rosservice call /sim_elevator/door_command "elevator_id: 'sim_elevator' car_id: 'sim_car_1' command: 0 lease_seconds: 0 request_id: 'manual-1'"
|
|
```
|
|
|
|
`select_floor` only accepts a stopped robot wholly inside the open car. The manager holds the car reservation and door while the robot boards/exits. Fault injection and reset are simulation-only operations. After a reset that evacuates a robot, switch `/map` to the reported current floor before resuming navigation.
|
|
|
|
For a test without a robot, call `/sim_elevator/call` with `pickup_floor` set to the floor where you want the cabin to arrive; use `/sim_elevator/state` to watch it travel and open. Select that floor on `/floor_map_switcher/switch` to publish its map. The map keeps the shaft blocked until the cabin is aligned there and the doors are fully open. `select_floor` is only needed for a ride with a robot already inside the car.
|
|
|
|
## Maps and configuration
|
|
|
|
`config/floors.yaml` holds elevator IDs, travel points, map topics, and manager tolerances. The two 2048 x 2048 `.pgm` maps match the static world fixtures; regenerate the world and maps together after editing `scripts/generate_maps.py`:
|
|
|
|
```bash
|
|
python3 "$(rospack find two_floor_elevator_sim)/scripts/generate_maps.py"
|
|
```
|
|
|
|
The world uses a kinematic carrier: Gazebo moves the cabin and carries the robot model while the elevator is travelling. It is intended to test command/state sequencing, map switching, localization handoff, timeout, and fault behavior. The walking actor collision plugin initializes Gazebo's animated bone collisions so the T800's Gazebo ray LiDAR (`/f_scan`, `/b_scan`) can intersect the moving legs when they are in the sensor's range and field of view. This requires a runtime Gazebo check after rebuilding the package. It does not model real elevator mechanics, safety certification, or friction/load performance.
|
|
|
|
Dynamic Gazebo models resting fully on the cabin floor are captured when travel begins and moved with the car. Models must have a valid collision bounding box, fit inside the cabin with an 8 cm margin, and have their bottom within 15 cm above the floor. Static models and objects outside these limits are not carried; this is kinematic placement, not a friction or payload physics simulation.
|
|
|
|
## Boundaries
|
|
|
|
- Only the new `two_floor_elevator_sim` package owns this world, maps, elevator plugin, and floor-transition manager.
|
|
- The real elevator/OEM API remains a future backend replacement; no network or hardware calls are made here.
|
|
- The transition manager sends navigation goals through `/move_base_simple/goal`, observes `/amcl_pose` and `/odom`, and never commands the robot velocity directly.
|
|
- A simulator run is not evidence of real-robot or real-elevator validation.
|