Skip to content

Crafting LfD Programs with High-Level Instructions

To create complete programs from demonstrated subtasks, high-level instructions can be used to combine LfD-based subtasks into comprehensive robotic tasks.

Example: Pick and Place Task

Below is an example Python script that demonstrates how to craft an LfD program for a pick-and-place task using high-level instructions:

import rospy
from lfd_program.runner import ProgramRunner

if __name__ == "__main__":

    rospy.init_node("lfd_program", anonymous=True)

    # Initialize the program
    runner = ProgramRunner(robot="fr3")
    runner.set_motion_mode("dmp")
    runner.configure_motion(duration_scale=DURATION_SCALE)
    runner.set_camera()  # If a camera program is set up

    # Picking LfD subtask
    runner.configure_motion(demo_name="PICK_DEMO_NAME")
    runner.move(debug=True)
    runner.locate_target("object_alias")  # If a camera program is set up and the object alias is defined
    runner.gripper.gripper_grasp()

    # Placing LfD subtask
    runner.configure_motion(demo_name="PLACE_DEMO_NAME")
    runner.move(debug=True)
    runner.gripper.gripper_open()

Debug Mode

If debug mode is activated, the planned LfD trajectory is first visualized in RViz before being executed on the robot. This helps verify the planned motion to ensure it meets the desired outcome.