Skip to content

Commit

Permalink
Merge pull request #3 from ipa320/main
Browse files Browse the repository at this point in the history
Update readme and some pending commits
  • Loading branch information
hsd-dev authored Feb 24, 2022
2 parents 7b5d6a1 + 1ba03c5 commit 25314d2
Show file tree
Hide file tree
Showing 9 changed files with 183 additions and 16 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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}}
6 changes: 3 additions & 3 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: Docker Image CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# pull_request:
# branches: [ main ]

jobs:

Expand Down Expand Up @@ -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 }}
Expand Down
66 changes: 66 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -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/<org>/<repo>/)
<br/>

[![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&amp;utm_medium=referral&amp;utm_content=ramp-eu/THMHO_heatmap_generator&amp;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.
1 change: 0 additions & 1 deletion docs/index.md

This file was deleted.

3 changes: 3 additions & 0 deletions factory_sim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)
Expand Down
10 changes: 10 additions & 0 deletions factory_sim/config/costmap_params_sim.yaml
Original file line number Diff line number Diff line change
@@ -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"}
21 changes: 17 additions & 4 deletions factory_sim/launch/factory.launch
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<arg name="model" default="$(env TURTLEBOT3_MODEL)" doc="model type [burger, waffle, waffle_pi]"/>
<arg name="x_pos" default="0.0"/>
<arg name="y_pos" default="0.0"/>
<arg name="y_pos" default="1.0"/>
<arg name="z_pos" default="0.0"/>

<arg name="sim_map_file" default="$(find factory_sim)/maps/map.yaml"/>
Expand All @@ -26,14 +26,27 @@

<!--Sensor Description from URDF-->
<group ns="sensors">
<param name="robot_description" command="$(find xacro)/xacro --inorder $(find factory_sim)/urdf/lab.xacro"/>
<param name="sensor_description" command="$(find xacro)/xacro $(find factory_sim)/urdf/lab.xacro"/>
<param name="use_gui" value="true"/>
<node name="spawn_model" pkg="gazebo_ros" type="spawn_model" args="-urdf -param robot_description -model lab_model" output="screen"/>
<node name="spawn_model" pkg="gazebo_ros" type="spawn_model" args="-urdf -param sensor_description -model lab_model" output="screen"/>
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher">
<param name="tf_prefix" value="sensors" />
<remap from="robot_description" to="sensor_description" />
</node>
</group>

<!-- <group ns="robot"> -->
<param name="robot_description" command="$(find xacro)/xacro $(find turtlebot3_description)/urdf/turtlebot3_$(arg model).urdf.xacro" />
<node pkg="gazebo_ros" type="spawn_model" name="spawn_urdf" args="-urdf -model turtlebot3_$(arg model) -x $(arg x_pos) -y $(arg y_pos) -z $(arg z_pos) -param robot_description" />
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" />
<include file="$(find turtlebot3_navigation)/launch/amcl.launch" >
<arg name="initial_pose_x" value="$(arg x_pos) "/>
<arg name="initial_pose_y" value="$(arg y_pos) "/>
<arg name="initial_pose_a" value="$(arg z_pos) "/>
</include>
<!-- </group> -->



<!-- Map server -->
<node pkg="map_server" name="map_server" type="map_server" args="$(arg sim_map_file)"/>

Expand Down
61 changes: 61 additions & 0 deletions factory_sim/scripts/costmap_saver
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env python3
import rospy
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.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
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)
body = {
'name': 'base_mask',
'width': self.width,
'height': self.height,
'indices': self.mask.indices.tolist(),
'indptr': self.mask.indptr.tolist(),
}
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()

15 changes: 7 additions & 8 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
site_name: <site-name>
site_url: https://<site-url>
repo_url: https://github.com/<repo_url>
site_description: RAMP Documentation
site_name: 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
edit_uri: edit/master/doc/
markdown_extensions: [toc,fenced_code]
use_directory_urls: false
theme: readthedocs
pages:
- Home: 'index.md'
nav:
- Home: 'README.md'
- 'Getting Started' : 'getting-started.md'
- 'User & Programmers Manual':
- 'Architecture' : 'architecture.md'
- 'API' : 'api.md'
- 'User Guide': 'usermanual.md'
- 'Installation & Administration Manual':
- 'Installation Guide': 'installationguide.md'
- 'Installation Guide': 'installationguide.md'

0 comments on commit 25314d2

Please sign in to comment.