This is an old revision of the document!
The Python Repl
For better interaction while programming CRAM utilises a Repl interface. To get a similar experience in PyCRAM we use the IPython interactive console. In the following we will describe how to install IPython and how to use it as a PyCRAM Repl
Install IPython
To install IPython in Ubuntu just use the command below.
apt-get install ipython3
Setup IPython as a PyCRAM Repl
For convenience it is advised to create a setup file which configures the BulletWorld and defines some helper functions. This setup file could look something like this:
import rospy from pycram.ik import ik from pycram import bullet_world, bullet_world_reasoning from pycram.robot_description import InitializedRobotDescription as robot_description world = bullet_world.BulletWorld() robot = bullet_world.Object("boxy", "robot", "resources/boxy.urdf", [0, 0, 0], [0, 0, 0, 1]) floor = bullet_world.Object("floor", "environment", "resources/plane.urdf") milk = bullet_world.Object("milk", "milk"m "resources/milk.obj") world.robot = robot tool = robot.get_link_position_and_orientation(robot_description.i.get_tool_frame("left")) world.add_vis_axis(tool) def move_milk_to_hand(): hand_pose = robot.get_link_position(tool) milk.set_position(hand_pose)
Now start the IPython shell in the terminal by typing the following command:
ipython3
By default IPython starts in the current directory of the terminal. Next, navigate to the directory where the setup file is located. For this you can use the commands
cd
and
ls
Lastly, execute the setup file by typing
run <name of your setupfile>.py
Now the BulletWorld window should show up and load all objects specified in the setup file. After everything is loaded you are presented with a prompt where you can now type python code as well as use the objects which are initialized in the executed code.