Test_unit4 execution error

I’m getting this error after updating test_unit4.cpp lines 214-225 match the solution:

user:~/ros2_ws/build/behaviortree_ros2$ ./test_unit4
terminate called after throwing an instance of ‘BT::RuntimeError’
what(): Error parsing the XML: XML_ERROR_EMPTY_DOCUMENT
Aborted (core dumped)

Could you please provide more context?

  • Which unit?
  • Which exercise or example?
  • Please add screenshots for clarity

Thanks for the reply!

I’m receiving this error in the “ROS2 Simulation” section (after exercise 4) in Unit 4 of Behavior Trees. I updated ~/ros2_ws/src/bt_course_files/behaviortree_ros2/test/test_unit4.cpp with the solution code in lines 214-225:

static const char *xml_text = R"(
 <root >
     <BehaviorTree>
     <Sequence>
      <SetBlackboard   output_key="Interface" value="360" />
        <ReactiveSequence> 
           <Rotating     input="{Interface}" /> 
           <ReadingLaser name="scanner"/>
        </ReactiveSequence> 
        <MoveRobot name="move_robot"/>
    </Sequence>
     </BehaviorTree>
 </root>
)";

Then I started the simulation in one terminal:

Then in a second terminal I run test_unit4 and receive the following error:

Hmm, did you recompile after making the changes? You would need to recompile for the changes to work. Otherwise, the test_unit4 file would be the compiled version of test_unit4.cpp without the XML file.

Thank you for the reply. Yes, after updating the XML of test_unit4.cpp,

  1. I recompile with colcon build (I’ve also tried colcon build --allow-overriding behaviortree_cpp_v3) and I receive Summary: 2 packages finished [4.74s]
  2. then I source /home/simulations/ros2_sims_ws/install/setup.bash and start the simulation successfully
  3. then I run ./test_unit4 and receive the same error (“Error parsing the XML”)

I see. I still think test_unit4.cpp is not being rebuilt. It looks like it’s not in the package you are overriding. You can verify that the timestamp of test_unit4 in the build directory changes when you rebuild.

As a last resort, can you try removing build and install and rebuilding everything again?

cd ~/ros2_ws
rm -rf build/ install/ log/
colcon build
....
1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.