-
Notifications
You must be signed in to change notification settings - Fork 722
Parallel Node: Is not a registered node #523
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
Comments
I am in the process of merging the changes of 4.1 into master. |
also, I am not aware of any problem with ENUMS in master branch. Thanks a lot! |
In order to reproduce this issue: `<root BTCPP_format="4" >
<BehaviorTree ID="PowerManagerT">
<ReactiveSequence>
<Script code=" deviceA:=BATT; deviceB:=CONTROLLER; LOW_BATT:=20 "/>
<CheckLevel deviceType="{BATT}"
percentage="{LOW_BATT}"
isLowBattery="{isLowBattery}"/>
<SendWarning deviceType="{BATT}" deviceStatus="{isLowBattery}"/>
</ReactiveSequence>
</BehaviorTree>
</root> CPP Code #include <ros/ros.h>
#include <ros/package.h>
#include <behaviortree_cpp/behavior_tree.h>
#include <behaviortree_cpp/bt_factory.h>
#include <boost/bind.hpp>
enum DeviceType { BATT=1, CONTROLLER=2 };
BT::NodeStatus checkLevel(BT::TreeNode &self)
{
double percent = self.getInput<double>("percentage").value();
int devType = self.getInput<int>("deviceType").value();
if(devType == DeviceType::BATT)
{
self.setOutput<bool>("isLowBattery", ((100 < percent)? true : false));
}
ROS_INFO_STREAM("Device| " << devType << " Level| " << percent);
return BT::NodeStatus::SUCCESS;
}
BT::NodeStatus sendWarning(BT::TreeNode &self)
{
int devType = self.getInput<int>("deviceType").value();
bool devStatus = self.getInput<bool>("deviceStatus").value();
//! Publish device warning on dedicated topic
if(devType == DeviceType::BATT)
{
ROS_INFO("Processing warning update for battery ");
}
ROS_INFO_STREAM("Sending warning for | " << devType << " status: " << devStatus);
return BT::NodeStatus::SUCCESS;
}
void registerNodes(BT::BehaviorTreeFactory &factory)
{
factory.registerSimpleCondition("CheckLevel",
boost::bind(checkLevel, _1),
{ BT::InputPort<double>("percentage"),
BT::InputPort<int>("deviceType"),
BT::OutputPort<bool>("isLowBattery")});
factory.registerSimpleAction("SendWarning",
boost::bind(sendWarning, _1),
{ BT::InputPort<int>("deviceType"),
BT::InputPort<bool>("deviceStatus")});
factory.registerScriptingEnums<DeviceType>(); //registering ENUMS here
}
int main(int argc, char** argv)
{
ros::init(argc, argv, "robot_bt_cpp");
ros::NodeHandle gnh, pnh("~");
BT::BehaviorTreeFactory factory;
registerNodes(factory);
std::string bt_path = ros::package::getPath("mobrob_agent");
auto tree = factory.createTreeFromFile(bt_path + "/config/test_bt.xml");
BT::NodeStatus status = tree.tickOnce();
while(not ros::isShuttingDown() /*&& (status == BT::NodeStatus::RUNNING)*/)
{
status = tree.tickOnce();
tree.sleep(std::chrono::milliseconds(250));
}
return 0;
} Error Log Thread 1 "test_node" received signal SIGABRT, Aborted. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
I figured out the Parallel Node issue. My main xml file was being overwritten by the export from Groot2 and hence the issue. It's all good now. |
Totally unrelated issue (maybe deserves it own issue); I find that _skipIf doesn't work with ReactiveSequence <root BTCPP_format="4" >
<BehaviorTree ID="PowerManagerT">
<ReactiveSequence>
<Script code=" deviceA:=BATT; deviceB:=CONTROLLER; LOW_BATT:=20 "/>
<CheckLevel deviceType="1"
percentage="{LOW_BATT}"
isLowBattery="{isLowBattery}"/>
**<SendWarning deviceType="1" deviceStatus="{isLowBattery}" _skipIf="!isLowBattery"/>**
<SendWarning deviceType="1" deviceStatus="{isLowBattery}" />
</ReactiveSequence>
</BehaviorTree>
</root> I get the logic error: Question: Are pre-conditions/ post-conditions not meant to be used with certain control nodes? |
I am creating a unit test with your code related to ENUM, but it looks wrong. I added an important fix (thanks!!!), but also there are errors in your code: Given: <Script code=" deviceA:=BATT "/> This is wrong: <CheckLevel deviceType="{BATT}" ... /> It should be either one of these two: <CheckLevel deviceType="BATT" ... />
<CheckLevel deviceType="{deviceA}" ... /> Also, if you want informative error message, go not ignore the error state of DeviceType devType;
if( auto res = self.getInput<DeviceType>("deviceType")) {
devType = res.value();
}
else {
throw std::runtime_error(res.error());
} |
Can you tell me more about that? If there is a problem in Groot2, I would like to fix it |
Thanks a lot for the fixes. I am unable to reproduce this issue at the moment but I will keep an eye out for it and update this thread in the future should it come up. |
Hi all, this is how my Xml setup looks like:
<BehaviorTree ID="GenericT"> <Parallel failure_count="3" success_count="-1" ID="ParallelEx"> <SubTree ID="UserActivityT"/> <SubTree ID="EmergencyT"/> <SubTree ID="PowerManagerT"/> </Parallel> </BehaviorTree>
But every time I run the node, I get this error that says, "Parallel is not registered"
`Starting program: /home/novi/mobrob_ws/devel/lib/mobrob_agent/agent_node __name:=robot_behavior_node __log:=/home/ephson/.ros/log/c776fa04-c1a3-11ed-8920-652b62dfa80b/robot_behavior_node-1.log
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff3fa7700 (LWP 1505800)]
[New Thread 0x7ffff37a6700 (LWP 1505801)]
[New Thread 0x7ffff2fa5700 (LWP 1505802)]
[New Thread 0x7ffff27a4700 (LWP 1505803)]
terminate called after throwing an instance of 'BT::RuntimeError'
what(): Parallel is not a registered node
Thread 1 "agent_node" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.`
PS: I'm compiling the v4.1 branch. No issue when working with the master branch but ENUMS don't work properly on the master branch as of now.
The text was updated successfully, but these errors were encountered: