From 7aadb872dcb27efbfe6c4c6ab32f7d94f7359e7c Mon Sep 17 00:00:00 2001 From: Alex AUTERNAUD <alex.auternaud@inria.fr> Date: Tue, 4 Apr 2023 12:04:52 +0200 Subject: [PATCH] remove gcff from this git --- README.md | 33 +------ requirements.txt | 1 - social_mpc/controller.py | 6 -- social_mpc/goal.py | 7 -- .../ssn_model/group_detection/__init__.py | 13 --- .../group_detection/gcff/__init__.py | 12 --- .../ssn_model/group_detection/gcff/gcff.py | 94 ------------------- social_mpc/ssn_model/group_detection/utils.py | 19 ---- 8 files changed, 1 insertion(+), 184 deletions(-) delete mode 100644 social_mpc/ssn_model/group_detection/__init__.py delete mode 100644 social_mpc/ssn_model/group_detection/gcff/__init__.py delete mode 100644 social_mpc/ssn_model/group_detection/gcff/gcff.py delete mode 100644 social_mpc/ssn_model/group_detection/utils.py diff --git a/README.md b/README.md index 6bb3c40..30404ce 100644 --- a/README.md +++ b/README.md @@ -1,32 +1 @@ -# MPC-based Robot controller in social environments - -This library implements a model predictive controller for a robot in a crowded environment. -It is used in the Spring project that has received funding from the -European Union’s Horizon 2020 research and innovation programme -under grant agreement No 871245. - -## Installation - -Get and install [pygco](https://gitlab.inria.fr/spring/wp4_behavior/pygco.git) in your python environment. - -Install python requirements using - -``` -pip install -r requirements.txt -``` - -Install: - -``` -pip install . -``` - -## Demo - -To run the demo, you need to install the [2D simulator](https://gitlab.inria.fr/spring/wp6_robot_behavior/2D_Simulator) - -Run - -``` -./run_demo.sh -``` \ No newline at end of file +TODO \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index d13a2cc..9bf8118 100644 --- a/requirements.txt +++ b/requirements.txt @@ -37,7 +37,6 @@ Pygments>=2.10.0 pylint>=2.10.2 pyqtgraph==0.12.2 pyqt5==5.12 -pygco==0.1 python-dateutil>=2.8.2 PyWavelets>=1.1.1 PyYAML>=5.4.1 diff --git a/social_mpc/controller.py b/social_mpc/controller.py index d0f4417..07714e7 100644 --- a/social_mpc/controller.py +++ b/social_mpc/controller.py @@ -10,7 +10,6 @@ from multiprocessing import Process, Lock from multiprocessing.managers import SharedMemoryManager -import social_mpc.ssn_model.group_detection as gd import atexit import rospy import time @@ -514,10 +513,6 @@ class RobotController(): humans[j, :] = * \ local_position, local_angle, state.humans_velocity[i, 0], 0 if n_human > 1: - groups = gd.gcff.identify_groups(humans, stride=self.controller_config.group_detection_stride) - for group in groups: - rospy.loginfo('get_social_cost_map: groups from gcff: center :{} person_ids : {}'.format(group.center, group.person_ids)) - groups = [] for idx, group_id in enumerate(state.groups_id): if group_id != -1: @@ -525,7 +520,6 @@ class RobotController(): groups.append(Group(center=center, person_ids=np.where(state.humans_group_id == group_id)[0])) else: break - rospy.loginfo('get_social_cost_map: groups read from hri listener : center :{} person_ids : {}'.format(groups[-1].center, groups[-1].person_ids)) f_dsz = ssn.calc_dsz(humans, groups=groups) f_dsz = np.flip(f_dsz, axis=0) diff --git a/social_mpc/goal.py b/social_mpc/goal.py index ea94c39..8c46600 100644 --- a/social_mpc/goal.py +++ b/social_mpc/goal.py @@ -9,7 +9,6 @@ # timothee.wintz@inria.fr from social_mpc.ssn_model.social_spaces import SocialSpaces, Group -import social_mpc.ssn_model.group_detection as gd from social_mpc import utils import numpy as np @@ -95,15 +94,9 @@ class GoalFinder(): print("Target group not in sight") continue - groups = gd.gcff.identify_groups(humans, stride=stride) - for group in groups: - print('groups from gcff GOAL: center :{} person_ids : {}'.format(group.center, group.person_ids)) - groups = [] for idx, group_id in enumerate(group_ids): groups.append(Group(center=sh_groups[idx, :2], person_ids=np.where(humans[:, -2] == group_id)[0])) - for group in groups: - print('groups from hri listener GOAL: center :{} person_ids : {}'.format(group.center, group.person_ids)) humans_fdz = np.zeros((n_human, 5)) humans_fdz[:, :3] = humans[:, :3] diff --git a/social_mpc/ssn_model/group_detection/__init__.py b/social_mpc/ssn_model/group_detection/__init__.py deleted file mode 100644 index a28f7ea..0000000 --- a/social_mpc/ssn_model/group_detection/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# This file, part of Social MPC in the WP6 of the Spring project, -# is part of a project that has received funding from the -# European Union’s Horizon 2020 research and innovation programme -# under grant agreement No 871245. -# -# Copyright (C) 2020-2022 by Inria -# Authors : Chris Reinke, Alex Auternaud, Timothée Wintz -# chris.reinke@inria.fr -# alex.auternaud@inria.fr -# timothee.wintz@inria.fr - -from social_mpc.ssn_model.group_detection.gcff import * -from social_mpc.ssn_model.group_detection.utils import group_labels_to_lists diff --git a/social_mpc/ssn_model/group_detection/gcff/__init__.py b/social_mpc/ssn_model/group_detection/gcff/__init__.py deleted file mode 100644 index e81b7c4..0000000 --- a/social_mpc/ssn_model/group_detection/gcff/__init__.py +++ /dev/null @@ -1,12 +0,0 @@ -# This file, part of Social MPC in the WP6 of the Spring project, -# is part of a project that has received funding from the -# European Union’s Horizon 2020 research and innovation programme -# under grant agreement No 871245. -# -# Copyright (C) 2020-2022 by Inria -# Authors : Chris Reinke, Alex Auternaud, Timothée Wintz -# chris.reinke@inria.fr -# alex.auternaud@inria.fr -# timothee.wintz@inria.fr - -from social_mpc.ssn_model.group_detection.gcff.gcff import identify_groups, Group diff --git a/social_mpc/ssn_model/group_detection/gcff/gcff.py b/social_mpc/ssn_model/group_detection/gcff/gcff.py deleted file mode 100644 index 53f38f7..0000000 --- a/social_mpc/ssn_model/group_detection/gcff/gcff.py +++ /dev/null @@ -1,94 +0,0 @@ -# This file, part of Social MPC in the WP6 of the Spring project, -# is part of a project that has received funding from the -# European Union’s Horizon 2020 research and innovation programme -# under grant agreement No 871245. -# -# Copyright (C) 2020-2022 by Inria -# Authors : Chris Reinke, Alex Auternaud, Timothée Wintz -# chris.reinke@inria.fr -# alex.auternaud@inria.fr -# timothee.wintz@inria.fr - -import numpy as np -import pygco - - -class Group: - def __init__(self, center, person_ids): - self.center = center - self.person_ids = person_ids - - -def identify_groups(persons, **parameters): - stride = parameters.get('stride', - 1.0) # distance from to person to the center of its transactional space (aslo called D) - # minimum discription length parameter (also called sigma) - mdl = parameters.get('mdl', 1.0) - max_iter = parameters.get('max_iter', 100) - - n_persons = persons.shape[0] - - # calculate the center of the transactional space for each person and the initinal group centers - transaction_segments = np.full((n_persons, 2), np.nan) - group_centers = np.full((n_persons, 2), np.nan) - for p_idx in range(n_persons): - ts_x = persons[p_idx][0] + np.cos(persons[p_idx][2]) * stride - ts_y = persons[p_idx][1] + np.sin(persons[p_idx][2]) * stride - - transaction_segments[p_idx, :] = [ts_x, ts_y] - group_centers[p_idx, :] = [ts_x, ts_y] - - labels = np.arange(n_persons) - distances = np.zeros((n_persons, n_persons)) - - pairwise_cost = np.zeros_like(distances) - cost_v = np.zeros((0, n_persons)) - cost_h = np.zeros((1, n_persons - 1)) - label_cost = np.ones(n_persons) * mdl - - if n_persons == 1: - result = [Group(center=group_centers[0, :], person_ids=[0])] - return result - - iter_count = 0 - while iter_count < max_iter: - - # calculate distance of each person to each group center - for p_idx in range(n_persons): - distances[p_idx, :] = np.sqrt( - np.sum((transaction_segments[p_idx] - group_centers) ** 2, 1)) - - # perform graph cut for 1 iteration - old_labels = labels - labels = pygco.cut_grid_graph(np.array([distances]), - pairwise_cost=pairwise_cost, - cost_v=cost_v, - cost_h=cost_h, - label_cost=label_cost, - n_iter=-1) - - # stop if there is no change of labels - if np.all(old_labels == labels): - break - - # recalculate the group centers - for g_idx in range(group_centers.shape[0]): - # people in that group - people_in_group_inds = (labels == g_idx) - - if np.any(people_in_group_inds): - group_centers[g_idx, :] = np.mean( - transaction_segments[people_in_group_inds, :], 0) - - iter_count += 1 - - result = [] - - for g_idx in range(group_centers.shape[0]): - # people in that group - people_in_group = np.where(labels == g_idx)[0].tolist() - if len(people_in_group): - result.append( - Group(center=group_centers[g_idx, :], person_ids=people_in_group)) - - return result diff --git a/social_mpc/ssn_model/group_detection/utils.py b/social_mpc/ssn_model/group_detection/utils.py deleted file mode 100644 index 23d4418..0000000 --- a/social_mpc/ssn_model/group_detection/utils.py +++ /dev/null @@ -1,19 +0,0 @@ -import numpy as np - -def group_labels_to_lists(group_labels): - '''Converts a group labels (list with id of the group for each person) to a group list.''' - - group_labels = np.array(group_labels) - - group_list = [] - - group_ids = set(group_labels) - - for group_id in group_ids: - cur_group_inds = (group_labels == group_id) - - if np.sum(cur_group_inds) > 1: - group_list.append(np.where(cur_group_inds)[0]) - - return group_list - -- GitLab