Description
Hi Davide,
I am facing this issue and can't seem to figure out a solution. I have two subtrees (TreeA and TreeB) as children of a parallel node. The main idea is that TreeA receives user input, processes it and outputs the results in an output variable "request_o".
XML of sub-TreeA:
<BehaviorTree ID="UserActivityT">
<ReactiveFallback>
<IsValidActivity request_i="{UserRequest}"
_onSuccess="hasTask:=true"/>
<RegisterActivity request_o="{UserRequest}"/>
<Continue/>
</ReactiveFallback>
</BehaviorTree>
TreeB uses the output from TreeA to decide the next cause of action.
XML of sub-TreeB:
<BehaviorTree ID="MapManagerT">
<ReactiveSequence>
<Script code=" isMapping:=false; hasTask:=false; UserRequest:='0;0;0;0;0;0;0;0;0' "/>
<IsMapActivity request="{UserRequest}"
trigger="{hasTask}"/>
</ReactiveSequence>
</BehaviorTree>
The the main tree containing the parallel node is composed as follows:
<BehaviorTree ID="GenericT">
<Parallel failure_count="2"
success_count="-1">
<Script code=" hasTask:=false; UserRequest:='0;0;0;0;0;0;0;0;0' "/>
<SubTree ID="UserActivityT" hasTask="{hasTask}" UserRequest="{UserRequest}"/>
<SubTree ID="MapManagerT" hasTask="{hasTask}" UserRequest="{UserRequest}" />
</Parallel>
</BehaviorTree>
The programs runs if I comment out either one of the subtrees but fails with this error (after ticking once) otherwise:
[ INFO] [1679304221.514799260]: Processing Request ...
terminate called after throwing an instance of 'std::runtime_error'
what(): Any::copyInto fails
This is my CPP structure being used:
struct RequestData_s
{
RequestData_s()
{
cmd = map_id = msn_id = num_captures = loop_count = delay = 0;
loop_once = false;
map_name = map_desc = "";
time = ros::Time::now();
}
RequestData_s(const RequestData_s &data)
{
cmd = data.cmd;
map_id = data.map_id;
msn_id = data.msn_id;
num_captures = data.num_captures;
loop_count = data.loop_count;
loop_once = data.loop_once;
delay = data.delay;
map_name = data.map_name;
map_desc = data.map_desc;
time = data.time;
}
int cmd, map_id, msn_id, num_captures, loop_count, delay;
bool loop_once;
std::string map_name, map_desc;
ros::Time time;
};
This is my BT Template definition for the corresponding structure:
namespace BT
{
template <> inline RequestData_s convertFromString(StringView str)
{//! cmd; map_id; map_name; map_desc; mission_id; loop_once; delay; num_capts; loop_count
auto parts = splitString(str, ';');
if(parts.size() != 9)
throw RuntimeError("invalid input - requires 9 data points");
else
{
RequestData_s output;
output.cmd = convertFromString<int>(parts[0]);
output.map_id = convertFromString<int>(parts[1]);
output.map_name = parts[2];
output.map_desc = parts[3];
output.msn_id = convertFromString<int>(parts[4]);
output.loop_once = convertFromString<bool>(parts[5]);
output.delay = convertFromString<int>(parts[6]);
output.num_captures = convertFromString<int>(parts[7]);
output.loop_count = convertFromString<int>(parts[8]);
return output;
}
}
} //end namespace BT`
I am not sure what I am doing wrong. It would be nice if you can shed some light on this issue since the error output is not very informative to aid in finding a solution.