-
Notifications
You must be signed in to change notification settings - Fork 211
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
Added Tf publisher #30
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See below a possible reason for your crashes. As always with multi-threaded code I would advise you to run it with thread sanitizer to check possible problems.
@@ -60,11 +60,14 @@ MapMerge::MapMerge() : subscriptions_size_(0) | |||
robot_map_updates_topic_, "map_updates"); | |||
private_nh.param<std::string>("robot_namespace", robot_namespace_, ""); | |||
private_nh.param<std::string>("merged_map_topic", merged_map_topic, "map"); | |||
private_nh.param<std::string>("world_frame", world_frame_, "world"); | |||
private_nh.param<std::string>("world_frame", world_frame_, "map"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but it is because in my opinion each robot map should have the namespace of the robot, and then, the global map, just be called map.
But it is just how I imagine it. I can revert this change before the pull request.
map_merge/src/map_merge.cpp
Outdated
{ | ||
if (!tf_current_flag_.test_and_set()) { | ||
// need to recalculate stored transforms | ||
auto transforms = pipeline_.getTransforms(); // this is thread-safe access |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not a thread-safe access AFAIK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It think this may be the cause of the crash you experienced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok! I'll have a look to this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have checked with TSan, and as you said, there was an issue there.
I have added a mutex to protect it.
With TSan I still have other warnings, however, I can't find the issue and I haven't experienced any other crashes.
map_merge/src/map_merge.cpp
Outdated
@@ -387,6 +433,15 @@ void MapMerge::spin() | |||
std::thread merging_thr([this]() { executemapMerging(); }); | |||
std::thread subscribing_thr([this]() { executetopicSubscribing(); }); | |||
std::thread estimation_thr([this]() { executeposeEstimation(); }); | |||
if (publish_tf) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we make this similar to those above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, I should have done it your way since the beginning.
map_merge/src/map_merge.cpp
Outdated
} | ||
} | ||
|
||
std::vector<geometry_msgs::TransformStamped> MapMerge::StampTransforms(const std::vector<geometry_msgs::Transform> transforms_, const std::string& frame) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
functions start with lowercase letter. this function should be static inline non-member or static member as it does not access any member variables. names with trailing underscore indicate member variables and should not be used as arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function actually uses two member variables, which allow proper map naming. I changed the name of the transforms parameter not to confuse.
So should I leave this function as a member function as it uses two member variables or should I keep it static and pass the variables as parameters?
…efinition as the previous.
Is there a way I can get a version of the map merger where I can freely control the merged map's origin, by changing the initial poses of the robots? because I tried this branch but the merged map still has an offset. |
This PR does not involve the initial poses of the robot nor the creation of the merged map. It is just to publish the transforms between maps. |
Is this feature ready to be merged? |
@andresjguevara It would need couple of adjustments. Would you be interested to contribute those? |
Hi, |
I have updated the PR with my last modifications. @hrnr I have commented the "adjuster" because it was misleading the results. I don't know if you have other experience with this but it helped a lot no to add it in the loop. @andresjguevara If the PR takes time or does not fit, you can use my fork of this work and try my branch called publish transforms, it should be working. However, take into account that no transform is given if the maps do not stitch and if the stitching is wrong it will provide wrong transforms. |
Thanks, I can take a look on Wednesday. I'm planing to release for Melodic, so it would be great to get your changes in. |
This looks awesome, exactly what I need. |
@Xvdgeest @hrnr |
@hrnr hi~! I`m still wait for this pr :) |
@hrnr Is this viable to use? Would be amazing if we can get this PR approved then |
Related to issue #29
I get an error "bad alloc" from the grid_compositor.cpp at line 66 when it tries to resize the "result_grid".
Thanks.