Skip to content

Commit

Permalink
[Costmap] Probabilistic costmap parameters are now robot dependent.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsch420 committed Nov 21, 2024
1 parent 9eac9b8 commit 40c5e23
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
12 changes: 12 additions & 0 deletions src/pycram/datastructures/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,18 @@ def get_max(self) -> List[float]:
"""
return [self.max_x, self.max_y, self.max_z]

@property
def width(self) -> float:
return self.max_x - self.min_x

@property
def height(self) -> float:
return self.max_z - self.min_z

@property
def depth(self) -> float:
return self.max_y - self.min_y


@dataclass
class CollisionCallbacks:
Expand Down
17 changes: 9 additions & 8 deletions src/pycram/pose_generator_and_validator.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import numpy as np
import tf
from typing_extensions import Tuple, List, Union, Dict, Iterable

from .datastructures.world import World
from .world_concepts.world_object import Object
from .world_reasoning import contact
from .costmaps import Costmap
from .local_transformer import LocalTransformer
from .datastructures.pose import Pose, Transform
from .robot_description import RobotDescription
from .datastructures.world import World
from .external_interfaces.ik import request_ik
from .failures import IKError
from typing_extensions import Tuple, List, Union, Dict, Iterable
from .local_transformer import LocalTransformer
from .robot_description import RobotDescription
from .world_concepts.world_object import Object
from .world_reasoning import contact


class PoseGenerator:
"""
Crates pose candidates from a given costmap. The generator
selects the highest values, amount is given by number_of_sample, and returns the corresponding positions.
Creates pose candidates from a given costmap.
The generator selects the highest values, amount is given by number_of_sample, and returns the corresponding
positions.
Orientations are calculated such that the Robot faces the center of the costmap.
"""

Expand Down
13 changes: 8 additions & 5 deletions src/pycram/probabilistic_costmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
from typing_extensions import Optional, Type
from visualization_msgs.msg import Marker, MarkerArray

from . import World
from .datastructures.world import World
from .costmaps import Costmap, OccupancyCostmap, VisibilityCostmap
import matplotlib.colorbar
from .datastructures.pose import Pose
from .ros.data_types import Duration
from .ros.publisher import create_publisher
from .units import meter, centimeter
from .robot_description import RobotDescription

from pint import Unit, Quantity
from probabilistic_model.probabilistic_circuit.nx.helper import uniform_measure_of_event, fully_factorized
Expand Down Expand Up @@ -80,20 +81,22 @@ def __init__(self, origin: Pose,
resolution = self.size.to(meter) / number_of_cells

if costmap_type == OccupancyCostmap:
robot_bounding_box = self.world.robot.get_axis_aligned_bounding_box()
distance_to_obstacle = max(robot_bounding_box.width, robot_bounding_box.depth) / 2
self.costmap = OccupancyCostmap(
origin=self.origin,
distance_to_obstacle=0.2,
distance_to_obstacle=distance_to_obstacle,
size=number_of_cells,
resolution=resolution.magnitude,
from_ros=False,
world = self.world)
elif costmap_type == VisibilityCostmap:
camera = list(self.world.robot_description.cameras.values())[0]
self.costmap = VisibilityCostmap(
min_height=0, max_height=2, size=number_of_cells, resolution=resolution.magnitude,
origin=self.origin, world=self.world)
min_height=camera.minimal_height, max_height=camera.maximal_height, size=number_of_cells,
resolution=resolution.magnitude, origin=self.origin, world=self.world)
else:
raise NotImplementedError(f"Unknown costmap type {costmap_type}")

self.create_distribution()

@cached_property
Expand Down
2 changes: 1 addition & 1 deletion test/test_costmaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_iterate(self):

class ProbabilisticCostmapTestCase(BulletWorldTestCase):

origin = Pose([0, 1, 0], [0, 0, 0, 1])
origin = Pose([1.5, 1, 0], [0, 0, 0, 1])

def setUp(self):
super().setUp()
Expand Down

0 comments on commit 40c5e23

Please sign in to comment.