Connect: Fix segfault when accessing solutions from multiple plan() calls

Connect::init() was resetting its dynamically created JMG merged_jmg_,
thus invalidating all previous solutions. Only reset the JMG in reset().
This commit is contained in:
Robert Haschke 2020-10-23 15:21:43 +02:00
parent c7151dcc48
commit 3a7a4eb953

View File

@ -86,9 +86,8 @@ void Connect::init(const core::RobotModelConstPtr& robot_model) {
} }
} }
if (!errors && groups.size() >= 2) { // enable merging? if (!errors && groups.size() >= 2 && !merged_jmg_) { // enable merging?
try { try {
merged_jmg_.reset();
merged_jmg_.reset(task_constructor::merge(groups)); merged_jmg_.reset(task_constructor::merge(groups));
} catch (const std::runtime_error& e) { } catch (const std::runtime_error& e) {
ROS_INFO_STREAM_NAMED("Connect", this->name() << ": " << e.what() << ". Disabling merging."); ROS_INFO_STREAM_NAMED("Connect", this->name() << ": " << e.what() << ". Disabling merging.");