Control Your Robot¶
Physics Control From Python¶
See the API Documentation for complete usage information.
The following scripts assume that the stage contains a Franka robot at /Franka created via the Create->Isaac->Robots->From Library->Franka
Simulation must be started for any of the below snippets to work. Press the Play button to start simulation from the ui.
Alternatively you can do it from python
import omni omni.timeline.get_timeline_interface().play()
One frame of simulation must occur before the Dynamic Control API will work correctly
1 2 3 4 5 6 7
from omni.isaac.dynamic_control import _dynamic_control dc = _dynamic_control.acquire_dynamic_control_interface() # Check to see what type of object the target prim is obj_type = dc.peek_object_type("/Franka") # This print statement should print ObjectType.OBJECT_ARTICULATION print(obj_type)
1 2 3 4 5 6 7 8 9 10 11 12 13 14
from omni.isaac.dynamic_control import _dynamic_control dc = _dynamic_control.acquire_dynamic_control_interface() # Get a handle to the Franka articulation # This handle will automatically update if simulation is stopped and restarted art = dc.get_articulation("/Franka") # Get information about the structure of the articulation num_joints = dc.get_articulation_joint_count(art) num_dofs = dc.get_articulation_dof_count(art) num_bodies = dc.get_articulation_body_count(art) # Get a specific degree of freedom on an articulation dof_ptr = dc.find_articulation_dof(art, "panda_joint2")
Read Joint State¶
1 2 3 4 5 6 7 8 9 10
# Print the state of each degree of freedom in the articulation art = dc.get_articulation("/Franka") dof_states = dc.get_articulation_dof_states(art, _dynamic_control.STATE_ALL) print(dof_states) # Get state for a specific degree of freedom dof_ptr = dc.find_articulation_dof(art, "panda_joint2") dof_state = dc.get_dof_state(dof_ptr) # print position for the degree of freedom print(dof_state.pos)
Set Joint State¶
1 2 3 4
dof_ptr = dc.find_articulation_dof(art, "panda_joint2") # This should be called each frame of simulation if state on the articulation is being changed. dc.wake_up_articulation(art) dc.set_dof_position_target(dof_ptr, -1.5)
From The User Interface¶
If the joint drives are set up for a robot, you can directly control the joint target positions from the Property panel. See the video below for a quick illustration.