11# Scripts
22
3- Utility scripts for maintaining the PickNik website.
3+ Utility scripts for maintaining the PickNik website, in particular the Behaviors Hub .
44
5- ## Get updated behaviors.xml
5+ ### How to update the Behavior Hub data source
6+ These steps allow you to get the updated behaviors.xml, which should happen every release.
67
78``` bash
8- # In moveitpro repo when your rest api is running, run a curl command to get the generated XML data
9+ # In moveitpro repo when your REST API is running, get the generated XML data
910# Save it to scripts/ directory in moveit_pro_example_ws workspace
10- curl -X GET http://localhost:3200/behaviors/data > scripts/behaviors .xml
11+ curl -X GET http://localhost:3200/behaviors/data > scripts/behaviors_raw .xml
1112```
1213
13- ## enhance_behaviors_xml .py
14+ ### enrich_behaviors_with_usage .py
1415
15- Enhances ` behaviors .xml` with usage information (` <UsedIn> ` elements) showing which Objectives use each behavior.
16+ Enhances ` behaviors_raw .xml` with usage information (` <UsedIn> ` elements) showing which Objectives use each behavior.
1617
1718** Run this script in ` moveit_pro_example_ws ` workspace.**
1819
19- ### Prerequisites
20+ #### Prerequisites
2021
21- 1 . Save ` behaviors .xml` (downloaded from REST API) to the ` scripts/ ` directory in ` moveit_pro_example_ws ` workspace.
22+ 1 . Save ` behaviors_raw .xml` (downloaded from REST API) to the ` scripts/ ` directory in ` moveit_pro_example_ws ` workspace.
2223
23- ### Usage
24+ #### Usage
2425
2526``` bash
2627# From moveit_pro_example_ws root directory
27- python3 scripts/enhance_behaviors_xml .py --xml scripts/behaviors .xml --workspace . --output scripts/behaviors_enhanced .xml
28+ python3 scripts/enrich_behaviors_with_usage .py --xml scripts/behaviors_raw .xml --workspace . --output scripts/behaviors_with_usage .xml
2829
2930# Example with custom workspace path
30- python3 scripts/enhance_behaviors_xml .py --xml scripts/behaviors .xml --workspace /path/to/workspace --output scripts/behaviors_enhanced .xml
31+ python3 scripts/enrich_behaviors_with_usage .py --xml scripts/behaviors_raw .xml --workspace /path/to/workspace --output scripts/behaviors_with_usage .xml
3132```
3233
33- ### What it does
34+ #### What it does
3435
3536- Discovers all robot configs in the workspace
3637- Extracts which Objectives use which behaviors by parsing Objective XML files
38+ - Preserves all existing XML data (ports, metadata, etc.)
3739- Adds ` <UsedIn> ` elements to each behavior in the XML showing:
3840 - Which configs use the behavior
3941 - Which Objectives use the behavior
4042 - The file path of each Objective
4143 - The usage type (Action, Control, Decorator, SubTree)
4244- Outputs enhanced XML file ready for conversion to JSON
4345
44- ### Requirements
46+ #### Requirements
4547
4648- Python 3
4749- PyYAML (` pip install pyyaml ` )
48- - ` behaviors .xml` file (from REST API endpoint)
50+ - ` behaviors_raw .xml` file (from REST API endpoint)
4951- ` moveit_pro_example_ws ` workspace with robot configs
5052
51- ## update_behaviors_from_xml.py
53+ ### update_behaviors_from_xml.py
5254
53- Updates ` _data/behaviors.json ` with port information and metadata extracted from ` behaviors .xml` .
55+ Updates ` _data/behaviors.json ` with port information and metadata extracted from ` behaviors_with_usage .xml` .
5456
5557** Run this script in the PickNik website repository.**
5658
57- ### Usage
59+ #### Usage
5860
5961``` bash
6062# From project root
61- python scripts/update_behaviors_from_xml.py [path_to_behaviors_enhanced .xml]
63+ python scripts/update_behaviors_from_xml.py [path_to_behaviors_with_usage .xml]
6264
6365# Example with default path
6466python scripts/update_behaviors_from_xml.py
6567
6668# Example with custom XML path
67- python scripts/update_behaviors_from_xml.py /path/to/behaviors_enhanced .xml
69+ python scripts/update_behaviors_from_xml.py /path/to/behaviors_with_usage .xml
6870```
6971
70- ### What it does
72+ #### What it does
7173
7274- Extracts port information (input, output, input/output) from XML Action and SubTree elements
7375- Extracts metadata (subcategory, description, deprecated status)
@@ -76,15 +78,15 @@ python scripts/update_behaviors_from_xml.py /path/to/behaviors_enhanced.xml
7678- Preserves existing data like links and other fields
7779- Updates the export date
7880
79- ## Complete Workflow
81+ ### Complete Workflow
8082
8183``` bash
8284# 1. In moveitpro repo - Get behaviors.xml from REST API and save to scripts/ directory
83- curl -X GET http://localhost:3200/behaviors/data > scripts/behaviors .xml
85+ curl -X GET http://localhost:3200/behaviors/data > scripts/behaviors_raw .xml
8486
8587# 2. In moveit_pro_example_ws root - Enhance XML with usage information
86- python3 scripts/enhance_behaviors_xml .py --xml scripts/behaviors .xml --workspace . --output scripts/behaviors_enhanced .xml
88+ python3 scripts/enrich_behaviors_with_usage .py --xml scripts/behaviors_raw .xml --workspace . --output scripts/behaviors_with_usage .xml
8789
8890# 3. In PickNik website repo - Convert to JSON
89- python scripts/update_behaviors_from_xml.py _data/behaviors_enhanced .xml
91+ python scripts/update_behaviors_from_xml.py _data/behaviors_with_usage .xml
9092```
0 commit comments