Skip to content

Fix segfault after loading posegraph#527

Merged
SteveMacenski merged 2 commits intoSteveMacenski:ros2from
samiamlabs:fix-segfault-after-loading-posegraph
Aug 24, 2022
Merged

Fix segfault after loading posegraph#527
SteveMacenski merged 2 commits intoSteveMacenski:ros2from
samiamlabs:fix-segfault-after-loading-posegraph

Conversation

@samiamlabs
Copy link
Contributor

@samiamlabs samiamlabs commented Aug 24, 2022

Basic Info

I was getting a segfault in in localization_slam_toolbox_node after loading a posegraph from a file here in the code:

auto edges = mapper_->GetGraph()->GetEdges();

The problem is that the LoopClosureAssistant was created with a raw pointer to a karto::Mapper instance from a unique pointer. The raw pointer is not replaced when a new serialized pose graph is loaded. Trying to call functions on the mapper_ pointer in the LoopClosureAssistant after that will cause a segfault.

| Primary OS tested on | Ubuntu |
| Robotic platform tested on | gazebo simulation of Husky |


Description of contribution in a few bullet points

  • Added a setter for the mapper_ pointer to LoopClosureAssistant
  • Updated the mapper used by LoopClosureAssistant in loadSerializedPoseGraph

Future work that may be required

It seems a bit strange to me that LoopClosureAssistant is using raw pointers rather that smart pointers. I suspect there is a reason for this thought... If not, it not we should probably change it so it uses smart pointers and avoid segfaults like this.

Copy link
Owner

@SteveMacenski SteveMacenski left a comment

Choose a reason for hiding this comment

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

Thanks!

@SteveMacenski SteveMacenski merged commit aa75a4f into SteveMacenski:ros2 Aug 24, 2022
@SteveMacenski
Copy link
Owner

SteveMacenski commented Aug 24, 2022

It seems a bit strange to me that LoopClosureAssistant is using raw pointers rather that smart pointers. I suspect there is a reason for this thought...

At the time of writing, I had just gotten out of several months working in the core of lib KartoSDK which has raw pointers galore for the graph-SLAM representations so it was just the headspace I was in. Plus,

SteveMacenski pushed a commit that referenced this pull request Aug 24, 2022
* Assign mapper to closure_assistant after loading posgraph

* Fix linting
SteveMacenski added a commit that referenced this pull request Aug 24, 2022
* Publish pose with covariance in localization mode. (#511)

* Visualize localization nodes and edges with different colors in the pose graph marker message. (#513)

* Fix edge marker id to not conflict with the localization edge marker. (#515)

* Stop ceres problem from freeing loss function (#519)

* Add map_and_localization node that supports toggling between mapping and localization modes with a service. (#512)

* resolve API change from galactic (#524)

* Fix segfault after loading posegraph (#527)

* Assign mapper to closure_assistant after loading posgraph

* Fix linting

* Midigate spamming for 50Hz lidar (#526)

* Increase scan filter queue_size

* Add scan_queue_size as parameter

Co-authored-by: Marc Alban <marcalban@hatchbed.com>
Co-authored-by: john-maidbot <78750993+john-maidbot@users.noreply.github.com>
Co-authored-by: Samuel Lindgren <samuel@dynorobotics.se>
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