Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 3d mesh and occ. grid generation from DSL repo #11

Merged
merged 43 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
79ab82d
Add 3d mesh and occ. grid generation from DSL repo
argenos Nov 7, 2024
9f9aa96
Change 3d mesh generation to function
argenos Nov 7, 2024
d983a2c
Convert occ. grid generation to function
argenos Nov 7, 2024
5a1ac43
Refactor duplicated code into functions
argenos Nov 8, 2024
3a66be0
Move image code close to where it's used
argenos Nov 8, 2024
201cb3b
Move args to metadata function
argenos Nov 8, 2024
fed623b
Move point queries to graph
argenos Jan 7, 2025
c8964bd
Minor fixes
argenos Jan 7, 2025
fba5a21
Move and refactor coord path positions
argenos Jan 7, 2025
fe2afdc
Fix task queries
argenos Jan 14, 2025
1e49b5f
Fix prefixes/namespaces not resolving
argenos Jan 14, 2025
ff5a8cd
Convert degrees to radians for occ_grid
argenos Jan 14, 2025
d978bc0
Upgrade rfdlib for lists of lists
argenos Jan 16, 2025
4dd75b9
Add z and beta attributes to coords
argenos Jan 16, 2025
2413b64
Add occ grid generation from json-ld model
argenos Jan 16, 2025
48766c8
Remove rounding of coords
argenos Jan 16, 2025
efeddb4
Lint code with Black
argenos Jan 16, 2025
3d7efdc
Move pgm write to utils
argenos Jan 16, 2025
0cac138
Move file save for 3d mesh to utils
argenos Jan 16, 2025
ea0fce0
Add 3d mesh generation to cli
argenos Jan 16, 2025
fb8f818
Move get_waypoint_coords to graph
argenos Jan 16, 2025
f05d7b1
Add 3d mesh generation
argenos Jan 17, 2025
27cf245
Lint with Black
argenos Jan 17, 2025
2e94580
Add z coords for opening transform
argenos Jan 20, 2025
caf89b2
Add threshold to openings for boolean difference to walls
argenos Jan 20, 2025
da71dd6
Fix: Quick fix to skip inv transform for openings in T
argenos Jan 20, 2025
6e6ab29
Lint graph.py
argenos Jan 20, 2025
f3817f0
Add dist to corner for tasks to CLI args
argenos Jan 22, 2025
c1e3345
Add map generation params to CLI args
argenos Jan 22, 2025
9215c6c
Lint with Black
argenos Jan 22, 2025
ee68673
Add help text to all options
argenos Jan 22, 2025
15c0aed
Lint with Black
argenos Jan 23, 2025
b9565d8
Move output path function to utils
argenos Jan 28, 2025
0f7ce4e
Move mesh function to generator
argenos Jan 28, 2025
3df40ce
Move occ. grid function to generator
argenos Jan 28, 2025
ad50499
Move task function to generator
argenos Jan 28, 2025
e1ac7bb
Move gazebo and launch file cli functions to generators
argenos Jan 28, 2025
d43b1e8
Remove config file from gen command
argenos Jan 28, 2025
4d1e401
Fix main for script call from blender
argenos Jan 28, 2025
3281108
Update dependencies
argenos Jan 28, 2025
87bfb49
Add Docker file
argenos Jan 28, 2025
ea0f523
Update README
argenos Jan 28, 2025
b1e2709
Remove unused args and imports
argenos Jan 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.git
.github
.idea
build
output
test
*.egg-info
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# syntax=docker/dockerfile:1
FROM ubuntu:24.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt update
RUN apt install -y software-properties-common
RUN apt install -y python3 python3-pip
RUN apt install -y blender


WORKDIR /usr/src/app/modules
WORKDIR /tmp
COPY . .
RUN pip install . -t /usr/src/app/modules

ENV BLENDER_USER_SCRIPTS=/usr/src/app

WORKDIR /usr/src/app/

ENTRYPOINT ["blender", "-b", "--python", "modules/fpm/cli.py", "--", "generate"]

CMD ["-i", "/usr/src/app/models/", "--output-path", "/usr/src/app/output/"]
91 changes: 86 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@

## Installation

Install all the requirements:

```shell
sudo apt-get install blender python3-pip python3-venv -y
```

First, create a virtual environment and activate it:

```shell
python -m venv .venv
source .venv/bin/activate
```

For Blender to regonize the virtual environment, add it to your `PYTHONPATH`:

```shell
export PYTHONPATH=<Path to .venv directory>/lib/python3.11/site-packages
```

From the root directory of the repo, install the python packages by running:

```shell
pip install -e .
```
Expand All @@ -18,22 +39,82 @@ Where the input folder must contain:
- the composable models generated from the [FloorPlan DSL](https://github.com/secorolab/FloorPlan-DSL)
- `coordinate.json`
- `floorplan.json`
- `polyhedron.json`
- `shape.json`
- `skeleton.json`
- `spatial_relations.json`
- the door object models
- the door object models (optional)
- `object-door.json`
- `object-door-states.json`
- any object instance models, e.g. `object-door-instance-X.json` where `X` is a unique numeric ID.
- any object instance models (optional), e.g. `object-door-instance-X.json` where `X` is a unique numeric ID.

For more information on the parameters that can be used to customize the generation simply call

```bash
floorplan generate --help
```

The command above currently generates the following artefacts:
- 3D mesh in `.stl` format
- Gazebo models and worlds (`.sdf`, `.config`)
- Launch files for ROS1 and/or ROS2 (`.launch`)
- Occupancy grid map for the ROS map_server (`.pgm` and `.yaml`)
- Tasks with a list of waypoints in `.yaml`

### Docker

To use the scenery_builder via Docker, simply mount the input and output paths as volumes and pass any arguments to the container:

```bash
docker run -v <local input path>:/usr/src/app/models -v <local output path>:/usr/src/app/output -it scenery_builder:latest <optional arguments>
```

## Example

![3D asset generated from the environment description](docs/images/hospital_no_brackground.png)

An example model for a building is available [here](https://github.com/secorolab/FloorPlan-DSL/blob/devel/models/examples/hospital.fpm2). After transforming the floorplan model into its composable representation, generate the artefacts by passing the folder with the JSON-LD models as inputs:


```sh
floorplan generate -i hospital/json-ld --output-path hospital/gen
```

That should generate the following files:

```bash
.
├── 3d-mesh
│   └── hospital.stl
├── gazebo
│   ├── models
│   │   └── hospital
│   │   ├── model.config
│   │   └── model.sdf
│   └── worlds
│   └── hospital.sdf
├── maps
│   ├── hospital.pgm
│   └── hospital.yaml
├── ros
│   └── launch
│   └── hospital.ros2.launch
└── tasks
├── hallway_task.yaml
├── reception_task.yaml
├── room_A_task.yaml
└── room_B_task.yaml
```


## Task generator

It uses the FloorPlan insets to generate a task specification.
The inset width -- a float value representing the distance between the sides of the inset and original shapes -- can be configured in the [config](config/config.toml)
It uses the FloorPlan corners to generate a task specification to visit all corners in a space.
The option `--waypoint-dist-to-corner` is a float value representing the distance between the corner of a space and its center.

## Object placing

This tool places objects in indoor environments.
This tool places objects (e.g. doors) in indoor environments.
By using the composable modelling approach, a scenery can compose the static FloorPlan models with objects such as doors.

![](docs/images/gazebo-screenshot.png)
Expand Down
18 changes: 18 additions & 0 deletions config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,21 @@ inset_width = 0.7

[roslaunch]
ros_pkg = "floorplan_models"

[model]
format = "stl"
output_folder = "../output/{{model_name}}/mesh"

[map_yaml]
resolution = 0.05
occupied_thresh = 0.65
free_thresh = 0.196
negate = 0

[map]
unknown = 200
occupied = 0
free = 255
laser_height = 0.7
output_folder = "../output/{{model_name}}/map"
border = 50
Binary file added docs/images/hospital_no_brackground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ dependencies = [
"Jinja2>=3.0.3",
"matplotlib>=3.7.2",
"numpy>=1.24.4,<2.0.0",
"PyLD==2.0.3",
"rdflib==6.2.0",
"PyLD>=2.0.3",
"rdflib>=7.1.0",
"click>=8.1.7",
"pyyaml",
]
requires-python = ">= 3.11"
readme = "README.md"
Expand All @@ -26,5 +27,8 @@ dev = ["black>=24.4.2"]
[project.scripts]
floorplan = "fpm.cli:floorplan"

[tool.setuptools.packages.find]
where = ["src"] # list of folders that contain the packages (["."] by default)

[tool.setuptools.package-data]
"*" = ["*.jinja"]
Loading