Skip to content

codes to learn a circuitHTN from human demonstration

Notifications You must be signed in to change notification settings

GT-RAIL/circuit_htn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CircuitHTN Codebase

Repository to host software libraries for task models for human-robot collaboration. All CircuitHTN code is located in the scripts directory. CircuitHTN is a Hierarchical Task Network learning approach inspired from resistor reduction rules in elementary physics. Humans demonstrations are first collected to build an Action Graph representing the state action transitions. The graph needs to be reduced to discover potential action hierarchies and structure. The graph is reduced by alternating series-parallel resistor reduction and restructuring the graph to resolve ambiguities.

This codebase is also organized as a ROS package, which includes a node that demonstrates an action prediction use case, for use in human-robot collaborative tasks.

How to Run HTN learning

The main executable code is located in scripts/htn/circuitHTN.py. Running this file will read in the demonstration information we collected from the table setting experiment, learn HTNs using the CircuitHTN algorithm for each of the sampled demonstration sets reported on in the paper, and generate 100 plans for each learned model. The plans are saved in .pkl files, and consist of lists of actions represented as human-readable strings.

We additionally include a hard-coded examples (in the function hardcoded_example for the table setting task, and in hardcoded_example_drill for the drill assembly task), which show human-readable example demonstrations, will learn an HTN using all of the demonstrations, and will visualize and save the learned HTN. This can be run instead of the experimental code in the main function.

Also included in the main function is the code to replicate HTN learning for the 50Salads dataset. This code is commented out under the table setting code in the main function, and can be used in place of the first code block.

Adapting the HTN learning code to new problem domains

  • Create a new simulator that defines a state representation and action effects (see scripts/simulator/drill_assembly_simulator/drill_assembly_simulator.py as an example)
    • create a new directory scripts/simulator/<new_domain>
    • create the simulator python file <new_domain>_simulator.py
    • define a state representation in the __init__() and return_state() functions
    • define the action effects in the update_step_world() function
    • specify how to read in demonstration data in the get_actions_from_demo() function
  • Change htn/circuitHTN.py to use the new simulator
    • create function <new_domain>\_demonstrations_to_htn(demos), using the new run_actions\_<new_domain>() function from the new simulator you created previously

Running the action prediction use case

Run the action prediction node as follows:

$ rosrun circuit_htn prediction_node.py 

By default, this will load the htn model in models/htn.pkl, which is currently a model trained using serial and parallel demonstrations of a 2-drill assembly task. To change the model, copy another model file generated by circuitHTN.py (see above) into the models directory, and set the desired model name with the ros parameter model_name as follows:

$ rosrun circuit_htn prediction_node.py _model_name:=<desired_model>

The node advertises an action prediction service, predict_next_action, of type PredictNext.srv. The service takes in a history of predicted actions and returns the predicted next actions with associated probabilities. See PredictNext.srv for details. The node is currently designed to work with the 2-drill assembly task demo.

Dependencies for Python Scripts

  • pickle
  • networkx
  • numpy
  • subprocess
  • pydot
  • graphviz
  • copy
  • os
  • sys
  • time
  • json
  • collections
  • matplotlib
  • random

Contributors

  • Kevin Chen
  • David Kent
  • Nithin Shrivatsav

About

codes to learn a circuitHTN from human demonstration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published