From 84b1c67d3537a97346df2e451292335a79791db4 Mon Sep 17 00:00:00 2001 From: Harsh Deshpande Date: Mon, 20 Sep 2021 16:46:41 +0200 Subject: [PATCH 01/13] correct docker image name (#12) --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 5cf1497..da17e9e 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -40,7 +40,7 @@ jobs: uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 with: images: | - ragesh18/thmho-lidar-node + ipahsd/thmho-heatmap-gen ghcr.io/${{ github.repository }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From a11188fba0cedaeeb08cf614896d56d3c163194e Mon Sep 17 00:00:00 2001 From: Harsh Deshpande Date: Mon, 20 Sep 2021 17:21:41 +0200 Subject: [PATCH 02/13] update readthedocs (#13) --- mkdocs.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mkdocs.yml b/mkdocs.yml index 88f840f..7263592 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,7 +1,7 @@ -site_name: -site_url: https:// -repo_url: https://github.com/ -site_description: RAMP Documentation +site_name: THMHO Heatmap Generator +site_url: https://github.com/ramp-eu/THMHO_heatmap_generator +repo_url: https://github.com/ramp-eu/THMHO_heatmap_generator +site_description: THMHO Heatmap Generator Documentation docs_dir: docs site_dir: html edit_uri: edit/master/doc/ @@ -9,7 +9,7 @@ markdown_extensions: [toc,fenced_code] use_directory_urls: false theme: readthedocs pages: - - Home: 'index.md' + - Home: 'README.md' - 'Getting Started' : 'getting-started.md' - 'User & Programmers Manual': - 'Architecture' : 'architecture.md' From f909d2c6408ec7faa988ae30a836507472d7dac5 Mon Sep 17 00:00:00 2001 From: Harsh Deshpande Date: Mon, 20 Sep 2021 17:39:17 +0200 Subject: [PATCH 03/13] update repo link (#14) --- mkdocs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkdocs.yml b/mkdocs.yml index 7263592..bcfe5f8 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,6 +1,6 @@ site_name: THMHO Heatmap Generator -site_url: https://github.com/ramp-eu/THMHO_heatmap_generator -repo_url: https://github.com/ramp-eu/THMHO_heatmap_generator +site_url: https://github.com/ipa320/THMHO_heatmap_generator +repo_url: https://github.com/ipa320/THMHO_heatmap_generator site_description: THMHO Heatmap Generator Documentation docs_dir: docs site_dir: html From d8e2abe773769698740bb31bc167d1e78a646c21 Mon Sep 17 00:00:00 2001 From: Harsh Deshpande Date: Mon, 20 Sep 2021 18:03:02 +0200 Subject: [PATCH 04/13] removed index.md (#15) --- docs/index.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 docs/index.md diff --git a/docs/index.md b/docs/index.md deleted file mode 100644 index fc0ab8a..0000000 --- a/docs/index.md +++ /dev/null @@ -1 +0,0 @@ -index.md From 058ade1e7c65eb235490be1f1a388f4b8381452c Mon Sep 17 00:00:00 2001 From: Harsh Deshpande Date: Mon, 20 Sep 2021 18:12:50 +0200 Subject: [PATCH 05/13] Readthedocs (#16) * removed index.md * update readme link --- mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs.yml b/mkdocs.yml index bcfe5f8..abe0da8 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -9,7 +9,7 @@ markdown_extensions: [toc,fenced_code] use_directory_urls: false theme: readthedocs pages: - - Home: 'README.md' + - Home: '../README.md' - 'Getting Started' : 'getting-started.md' - 'User & Programmers Manual': - 'Architecture' : 'architecture.md' From e596764eaf7292b53e228affb24593dc0066a5f0 Mon Sep 17 00:00:00 2001 From: Harsh Deshpande Date: Mon, 20 Sep 2021 18:24:40 +0200 Subject: [PATCH 06/13] re-add readme to docs (#17) --- docs/README.md | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ mkdocs.yml | 2 +- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 docs/README.md diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..7d2a815 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,66 @@ +# Temporal Heat Map for Human Occupancy - Heatmap generation + +[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) +[![Docker badge](https://img.shields.io/docker/pulls/ramp-eu/TTE.project1.svg)](https://hub.docker.com/r///) +
+ +[![Documentation Status](https://readthedocs.org/projects/thmho-lidar-node/badge/?version=latest)](https://thmho-heatmap-generator.readthedocs.io/en/latest/?badge=latest) +[![CI](https://github.com/ramp-eu/TTE.project1/workflows/CI/badge.svg)](https://github.com/ramp-eu/TTE.project1/actions?query=workflow%3ACI) +[![Coverage Status](https://coveralls.io/repos/github/ramp-eu/TTE.project1/badge.svg?branch=master)](https://coveralls.io/github/ramp-eu/TTE.project1?branch=master) +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/fce8e4a4dfe140bb9963b88aaf1a2b03)](https://www.codacy.com/gh/ramp-eu/THMHO_heatmap_generator/dashboard?utm_source=github.com&utm_medium=referral&utm_content=ramp-eu/THMHO_heatmap_generator&utm_campaign=Badge_Grade) +[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/5132/badge)](https://bestpractices.coreinfrastructure.org/projects/5132) + +This project is part of [DIH^2](http://www.dih-squared.eu/). For more information check the RAMP Catalogue entry for the +[components](https://github.com/ramp-eu). + +| :books: [Documentation](https://thmho-lidar-node.readthedocs.io/en/latest/README.html) | :whale: [Docker Hub](https://hub.docker.com) | +| --------------------------------------------- | ------------------------------------------------------------- | + +## Contents + +- [Background](#background) +- [Install](#install) +- [Usage](#usage) +- [API](#api) +- [Testing](#testing) +- [Feedback](#feedback) +- [Contribution](#contribution) +- [License](#license) + +## Background +### Objective +The objective of the package is to create the temporal heatmaps that show for each 1 m2, and each 1 hour of each workday the rate of human occupancy. + +## Install + +Information about how to install the `THMHO_heatmap_generator` can be found at the corresponding section of the [Installation & Administration Guide](docs/installationguide.md). + +## Usage + +Information about how to use the `THMHO_heatmap_generator` can be found in the [User & Programmers Manual](docs/usermanual.md). + +## Testing + +### Troubleshooting + +- Message `Requesting the map...` on terminal or `No map received` in RViz + + The file pointed by `sim_map_file` (for simulation) or `real_map_file` (for real laser scanners) in `factory_sim/launch/factory.launch` may not exist in the workspace. + +- No heatmap is vizualized in `RViz` + + If `Costmap` is not visualized as well, verify if the laser scan `topic` names specified in `factory_sim/config/costmap_params.yaml` are correct, and if the `tf` tree is published correctly. + If `Costmap` is visualized, it should be noted that the first heatmap is published after the time specified by `aggregation_time` argument for `heatmap_generator` node in `factory_sim/launch/factory.launch`. The default value is 3600, i.e. 1 hour. + + +## Feedback + +Any feedback and suggestions can be submitted by creating New issue in the Issues tab or by emailing the team. + +## Contribution + +In order to contribute you will have to request to be added to the project. + +## License + +The project is licensed under the [Apache-2](https://opensource.org/licenses/Apache-2.0) license. diff --git a/mkdocs.yml b/mkdocs.yml index abe0da8..bcfe5f8 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -9,7 +9,7 @@ markdown_extensions: [toc,fenced_code] use_directory_urls: false theme: readthedocs pages: - - Home: '../README.md' + - Home: 'README.md' - 'Getting Started' : 'getting-started.md' - 'User & Programmers Manual': - 'Architecture' : 'architecture.md' From 6c74f4c39e253d363ad3701416b36e2c0cdb6200 Mon Sep 17 00:00:00 2001 From: Harsh Deshpande Date: Mon, 20 Sep 2021 18:32:14 +0200 Subject: [PATCH 07/13] Update mkdocs.yml --- mkdocs.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mkdocs.yml b/mkdocs.yml index bcfe5f8..c562d1d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -4,7 +4,6 @@ repo_url: https://github.com/ipa320/THMHO_heatmap_generator site_description: THMHO Heatmap Generator Documentation docs_dir: docs site_dir: html -edit_uri: edit/master/doc/ markdown_extensions: [toc,fenced_code] use_directory_urls: false theme: readthedocs @@ -16,4 +15,4 @@ pages: - 'API' : 'api.md' - 'User Guide': 'usermanual.md' - 'Installation & Administration Manual': - - 'Installation Guide': 'installationguide.md' \ No newline at end of file + - 'Installation Guide': 'installationguide.md' From 74d18e548ae253def54482dd202f6305215605da Mon Sep 17 00:00:00 2001 From: Harsh Deshpande Date: Mon, 20 Sep 2021 18:39:35 +0200 Subject: [PATCH 08/13] Update mkdocs.yml --- mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkdocs.yml b/mkdocs.yml index c562d1d..53ae07b 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -7,7 +7,7 @@ site_dir: html markdown_extensions: [toc,fenced_code] use_directory_urls: false theme: readthedocs -pages: +nav: - Home: 'README.md' - 'Getting Started' : 'getting-started.md' - 'User & Programmers Manual': From af9b543df809cf2ea8a29e7f76b3b265785c969b Mon Sep 17 00:00:00 2001 From: Harsh Deshpande Date: Mon, 15 Nov 2021 11:27:08 +0100 Subject: [PATCH 09/13] Docker build (#19) * no need to build docker on PRs * add CI config to build repo --- .github/workflows/build.yml | 16 ++++++++++++++++ .github/workflows/docker-image.yml | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..bf66607 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,16 @@ +name: CI + +on: [push, pull_request] + +jobs: + industrial_ci: + strategy: + matrix: + env: + - {ROS_DISTRO: melodic, ROS_REPO: main} + - {ROS_DISTRO: noetic, ROS_REPO: main} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: 'ros-industrial/industrial_ci@master' + env: ${{matrix.env}} \ No newline at end of file diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index da17e9e..0f78b12 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -3,8 +3,8 @@ name: Docker Image CI on: push: branches: [ main ] - pull_request: - branches: [ main ] + # pull_request: + # branches: [ main ] jobs: From cbbdd2650a60f99187b3b6e8f8691f4d8b53ab78 Mon Sep 17 00:00:00 2001 From: Harsh Deshpande Date: Mon, 15 Nov 2021 11:33:59 +0100 Subject: [PATCH 10/13] Add robot to sim (#18) * change sensor description param name * add turtlebot3 to sim --- factory_sim/launch/factory.launch | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/factory_sim/launch/factory.launch b/factory_sim/launch/factory.launch index b9c5f56..e5a8ae6 100644 --- a/factory_sim/launch/factory.launch +++ b/factory_sim/launch/factory.launch @@ -8,7 +8,7 @@ - + @@ -26,14 +26,27 @@ - + - + - + + + + + + + + + + + + + + From 6cfe74d59f9f3bf92160e242b47b9893fcb533b5 Mon Sep 17 00:00:00 2001 From: Harsh Deshpande Date: Mon, 15 Nov 2021 14:28:08 +0100 Subject: [PATCH 11/13] add missing sim config --- factory_sim/config/costmap_params_sim.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 factory_sim/config/costmap_params_sim.yaml diff --git a/factory_sim/config/costmap_params_sim.yaml b/factory_sim/config/costmap_params_sim.yaml new file mode 100644 index 0000000..6e0af13 --- /dev/null +++ b/factory_sim/config/costmap_params_sim.yaml @@ -0,0 +1,10 @@ +observation_sources: scan scan_2 scan_3 +scan: {sensor_frame: sensor_laser, data_type: LaserScan, topic: /sensors/laser_scan, marking: true, clearing: true, + expected_update_rate: 0.4, max_obstacle_height: 1.0, min_obstacle_height: 0.0, obstacle_range: 10.0} + +scan_2: {sensor_frame: sensor_laser_2, data_type: LaserScan, topic: /sensors/laser_scan_2, marking: true, clearing: true, + expected_update_rate: 0.4, max_obstacle_height: 1.0, min_obstacle_height: 0.0, obstacle_range: 10.0} + +plugins: + - {name: static_map, type: "costmap_2d::StaticLayer"} + - {name: obstacles, type: "costmap_2d::ObstacleLayer"} From 144f6dfa5ab4c80af529febabdb690115725edde Mon Sep 17 00:00:00 2001 From: Harsh Deshpande Date: Mon, 15 Nov 2021 14:28:38 +0100 Subject: [PATCH 12/13] install costmap_saver script --- factory_sim/CMakeLists.txt | 3 +++ factory_sim/scripts/costmap_saver | 43 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 factory_sim/scripts/costmap_saver diff --git a/factory_sim/CMakeLists.txt b/factory_sim/CMakeLists.txt index c0667f8..0417de4 100644 --- a/factory_sim/CMakeLists.txt +++ b/factory_sim/CMakeLists.txt @@ -27,6 +27,9 @@ target_link_libraries(heatmap_generator ${catkin_LIBRARIES} ) +catkin_install_python(PROGRAMS scripts/costmap_saver + DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) + install(TARGETS costmap_generator costmap_generator RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} ) diff --git a/factory_sim/scripts/costmap_saver b/factory_sim/scripts/costmap_saver new file mode 100644 index 0000000..54dd682 --- /dev/null +++ b/factory_sim/scripts/costmap_saver @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 +import rospy +from nav_msgs.msg import OccupancyGrid +from scipy.sparse import csr_matrix +import numpy as np +import requests +from datetime import datetime +import sys + + +class HeatmapSaver(object): + def __init__(self): + # self.url = 'http://localhost:5000/insert' + + self.heatmap_subscriber = rospy.Subscriber( + "/costmap_generator/costmap/costmap", OccupancyGrid, self.save_heatmap) + + costmap = rospy.wait_for_message("/map", OccupancyGrid, timeout=100) + self.width = costmap.info.width # map_width : Width, + self.height = costmap.info.height # map_height : Height + self.mask = np.array(costmap.data).astype(bool) + print(self.mask) + self.mask = (~self.mask).astype(int) + # self.mask = csr_matrix(self.mask) + # self.mask = self.mask.toarray() + + def save_heatmap(self, msg): + data = np.array(msg.data) + masked_data = csr_matrix(data * self.mask) + body = { + 'date': datetime.now().isoformat(), + 'indices': masked_data.indices, + 'indptr': masked_data.indptr, + 'width': msg.info.width, + 'height': msg.info.height + } + print("size: " + str(sys.getsizeof(body))) + print("orig size: " + str(sys.getsizeof(msg.data))) + +if __name__ == '__main__': + rospy.init_node('heatmap_saver', anonymous=True) + heatmap = HeatmapSaver() + rospy.spin() From 1ba03c55f634118d9712e5f877e8fc696e0b7d09 Mon Sep 17 00:00:00 2001 From: ipa-rar-sg <87696993+ipa-rar-sg@users.noreply.github.com> Date: Tue, 30 Nov 2021 18:17:40 +0100 Subject: [PATCH 13/13] Sparse costmap saver (#20) * install costmap_saver script * Python script costmap saver for sparse matrix instead of dense * Working version to work with the two mongo dbs version of the dashboard repo Co-authored-by: Harsh Deshpande --- factory_sim/scripts/costmap_saver | 56 ++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/factory_sim/scripts/costmap_saver b/factory_sim/scripts/costmap_saver index 54dd682..ac8bfec 100644 --- a/factory_sim/scripts/costmap_saver +++ b/factory_sim/scripts/costmap_saver @@ -4,40 +4,58 @@ from nav_msgs.msg import OccupancyGrid from scipy.sparse import csr_matrix import numpy as np import requests +import time from datetime import datetime import sys - class HeatmapSaver(object): def __init__(self): - # self.url = 'http://localhost:5000/insert' + self.url = 'http://localhost:5000/insert' + self.urlsparse = 'http://localhost:5000/insparse' self.heatmap_subscriber = rospy.Subscriber( "/costmap_generator/costmap/costmap", OccupancyGrid, self.save_heatmap) costmap = rospy.wait_for_message("/map", OccupancyGrid, timeout=100) - self.width = costmap.info.width # map_width : Width, - self.height = costmap.info.height # map_height : Height - self.mask = np.array(costmap.data).astype(bool) - print(self.mask) + self.width = costmap.info.width + self.height = costmap.info.height + self.size = (self.height, self.width) + self.mask = np.array(costmap.data).reshape(self.size).astype(bool) self.mask = (~self.mask).astype(int) - # self.mask = csr_matrix(self.mask) - # self.mask = self.mask.toarray() - - def save_heatmap(self, msg): - data = np.array(msg.data) - masked_data = csr_matrix(data * self.mask) + self.mask = csr_matrix(self.mask) body = { - 'date': datetime.now().isoformat(), - 'indices': masked_data.indices, - 'indptr': masked_data.indptr, - 'width': msg.info.width, - 'height': msg.info.height + 'name': 'base_mask', + 'width': self.width, + 'height': self.height, + 'indices': self.mask.indices.tolist(), + 'indptr': self.mask.indptr.tolist(), } - print("size: " + str(sys.getsizeof(body))) - print("orig size: " + str(sys.getsizeof(msg.data))) + requests.post(self.urlsparse, json = body) + self.mask = self.mask.toarray() + + def save_heatmap(self, msg): + data = np.array(msg.data).reshape(self.size) + try: + masked_data = csr_matrix(data * self.mask) + date = datetime.now().isoformat() + body = { + 'date': date, + 'data': msg.data + } + body_csr = { + 'date': date, + 'indices': masked_data.indices.tolist(), + 'indptr': masked_data.indptr.tolist(), + } + requests.post(self.url, json = body) + requests.post(self.urlsparse, json = body_csr) + print(f"Inserted registry in both databases at {date}") + except Exception as e: + print(e) if __name__ == '__main__': rospy.init_node('heatmap_saver', anonymous=True) heatmap = HeatmapSaver() + time.sleep(5) rospy.spin() +