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

simple command costmap api - first few functions #3159

Merged
merged 5 commits into from
Aug 31, 2022
Merged
Changes from 2 commits
Commits
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
33 changes: 33 additions & 0 deletions nav2_simple_commander/nav2_simple_commander/costmap_2d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#! /usr/bin/env python3
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
from nav_msgs.msg import OccupancyGrid
import numpy as np

class PyCostmap2D:
def __init__(self, map):
self.size_x_ = map.info.width;
self.size_y_ = map.info.height;
self.resolution_ = map.info.resolution;
self.origin_x_ = map.info.origin.position.x
self.origin_y_ = map.info.origin.position.y
self.global_frame_id_ = map.header.frame_id
self.costmap_timestamp_= map.header.stamp
# Extract costmap
self.costmap_ = np.array(map.data, dtype=np.int8).reshape(self.size_y_, self.size_x_)
def getSizeInCellsX(self):
return self.size_x_
def getSizeInCellsY(self):
return self.size_y_
def getSizeInMetersX(self):
return (self.size_x_ - 1 + 0.5) * self.resolution_
def getSizeInMetersY(self):
return (self.size_y_ - 1 + 0.5) * self.resolution_
def getOriginX(self):
return self.origin_x_
def getOriginY(self):
return self.origin_y_
def getResolution(self):
return self.resolution_
def getGlobalFrameID(self):
return self.global_frame_id_
def getCostmapTimestamp(self):
return self.costmap_timestamp_