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

Request with zero size return full costmap #19

Merged
merged 2 commits into from
Nov 28, 2016

Conversation

AlexReimann
Copy link
Contributor

@AlexReimann AlexReimann commented Nov 8, 2016

Partly fixes issue #15.


This change is Reviewable

@AlexReimann
Copy link
Contributor Author

@stonier
@bit-pirate fyi

float subwindow_bottom_left_x = position.x() - geometry.x() / 2.0;
float subwindow_bottom_left_y = position.y() - geometry.y() / 2.0;
double subwindow_bottom_left_x = (position.x() - geometry.x()) * 0.5;
double subwindow_bottom_left_y = (position.y() - geometry.y()) * 0.5;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be a bug

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also use floats where it's not important to be a double. While you don't see any difference on the PC, the difference is significant if using the code on an arm core.

I used to be the other way around...

if((geometry.x() == original_size_x && geometry.y() == original_size_y)
|| geometry.x() == 0.0 || geometry.y() == 0.0) {
is_subwindow = true;
costmap_subwindow = costmap_2d::Costmap2D(*(ros_costmap.getCostmap())); //be aware of some black magic in here
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it actually necessary to do a copy in this case?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the tradeoff here is about whether it's large (e.g. global costmap) and the copy will be a large cost, or the or if the iteration over it locks the costmap for a significant time

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the copy constructor does not do a copy (that's the black magic, yay navi stack) and I forgot to lock it farther downwards.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, we are doing a copy anyway, so whether we do it early and lock around that, or do it late, and lock around the whole thing...much the same thing. So, let's just lock late.

Also as you pointed out, a block copy (memcopy style) might be much faster than iterating.

@AlexReimann
Copy link
Contributor Author

Is it intended that the costmap always has the full size but only copies the requested part?

See here

double subwindow_bottom_left_y = (position.y() - geometry.y()) * 0.5;

double original_size_x = ros_costmap.getCostmap()->getSizeInMetersX();
double original_size_y = ros_costmap.getCostmap()->getSizeInMetersX();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be getSizeInMetersY()


// std::cout << "From ROS Costmap2D" << std::endl;
// std::cout << " Robot Pose : " << position.x() << "," << position.y() << std::endl;
// std::cout << " Bottom Left Corner: " << subwindow_bottom_left_x << "," << subwindow_bottom_left_y << std::endl;
// std::cout << " Resolution : " << resolution << std::endl;
// std::cout << " Size : " << geometry.x() << "x" << geometry.y() << std::endl;
// std::cout << " Original Size : " << original_size_x << "x" << original_size_y << std::endl;

bool is_subwindow = false;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this is a confusing name I wrote here...it's not about whether its a subwindow or not, but whether it lands inside the original boundaries or not.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe should be is_valid_window or something.

@stonier
Copy link
Owner

stonier commented Nov 20, 2016

Is it intended that the costmap always has the full size but only copies the requested part? See here

Cost map doesn't have the full size..it is determined by the passed in geometry. The copied part size is also determined by the passed in geometry. Should be the same.

@AlexReimann AlexReimann force-pushed the fix_max_resolution_request branch 5 times, most recently from 7a522f9 to 19c3dfe Compare November 21, 2016 01:34
@AlexReimann
Copy link
Contributor Author

Not tested yet!

@AlexReimann
Copy link
Contributor Author

Ready for checking. Already rebased / squashed

@AlexReimann
Copy link
Contributor Author

Added some fixed for fromROSCostMap2D and toOccupancyGrid which basically just copies code from the occupancy grid converter from the original grid_map

I'll add my test program tomorrow as it is a bit messy right now.

@AlexReimann
Copy link
Contributor Author

Fixed up the alignment test, but still a bit ugly ._.

@stonier
Copy link
Owner

stonier commented Nov 28, 2016

Ran out of time to check on this, but will push it through so you've something to work with. Keep the PR's coming as you need them - I'll keep pushing them and really go over it once I get a good day or two free :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants