This repository contains several examples being part of a Rosvita project. Every example script lies in a corresponding folder in the Rosvita project. For some examples, a corresponding directory can be found in the Rosvita WorldView containing objects which are used or generated by the script.
The first example script shows a simple pick and place operation. It should show several aspects:
- reading JointValues from the Rosvita WorldView
- executing a Supervised MoveJoints operation
- executing a sequence of MoveJoints operations
- simple use of a Gripper (e.g. close & open)
All joint values needed for the example are read from the WorldView in the corresponding folder. The movement to the start joint values is supervised, the rest of the movement in this example is not.
This example shows how the robot can do pick-and-place operations for a set of poses.
Since the example does a lot of things, it is subdivided into several simple ones which can be run individually. Running the file example_02_palletizing.py puts everything together. The features are:
- Given a pose and some parameter defining the size, calculate a grid of poses with translation and rotation corresponding to the pose example_02_1_generate_grid.py
- Generate some CollisionObjects at a list of poses example_02_2_create_collision_boxes.py
- Using inverse kinematics, get corresponding JointValues for a list of poses [example_02_3_create_joint_values_from_poses.py] (example_02/example_02_3_create_joint_values_from_poses.py)
- Do a pick and place operation from the pick JointValues to every Pose, using
move_joints_collision_free
for movement between pick and preplace and linear movement in cartesian space between preplace and place poses example_02_4_pick_place_poses.py ( see this for an alternative version calling inverse kinematics explicitly for every target place pose and implements the moving between pre place and place using collision free joint value moving, which might be preferable).
The script example_02_palletizing.py runs the subexamples 1-4 to do the following:
- Calculating a grid of place poses using a single pose (named
GridPose
) in WorldView for orientation and translation - Showing some cubes below the poses to show where they are and as a CollisionObject to be avoided.
- Calculate a set of pre place poses hovering over the place poses in z-direction (the grid spans in x and y direction from view of the
GridPose
Pose) - Generating the JointValues for the pre place poses using inverse kinematics.
The JointValues at the pick position (named
Home
) is used as a seed, since we move back and forth from it to the pre place pose. If there could not be found JointValues for every pose, an exception is thrown. In that case, one can alter theGridPose
and/or the size of the grid before running the example again, until a valid set of poses has been found. - Collision free pick and place movement from the
Home
configuration addressing every pose in the grid.
Objects generated by the examples are written in most cases to WorldView for visualization. For example, user can see the JointValues calculated from the poses or observe how the grid is generated differently when its defining pose is altered in WorldView.
Every example has a main function with type annotation, which should make including them into an xgraph straight-forward.
This example script shows how to shift JointValues in cartesian space.
Joint values can be added and changed in example_03_shifting/jointValues/
in WorldView.
The folder example_03_shifting/poses/
in WorldView contains a Reference
and a Shift
pose.
The transformation applied in Cartesian Space is defined by the translation/rotation of the Shift
pose in reference to the Reference
pose.
Every end effector pose is transformed this way. Inverse kinematics is used to get JointValues at this new pose. If the inverse kinematics operation yields no result, the corresponding JointValues are skipped.
The resulting joint values are stored in example_03_shifting/generated/
.
This example script shows how the robot can move while evading CollisionObjects
.
First CollisionObject
s are generated from poses read from WorldView
.
The arm of the robot moves back and forth between two joint values configuration.
For every movement, a different CollisionObject
is added to WorldView
and taken into account when planning the movement.
This example script shows how to produce sinus shaped motion given a list of poses
The script first creates a list of poses consisting of the current pose of the end effector.
Then a new CartesianPath
is created by applying translation along a given axis following a sinus function.
Linear movement of this path is then executed.
Setting the parameter for amplitude, frequence and axis to change the behaviour of the movement.
This example script shows how to achieve movement of the torso joint of the robot while keeping its end effectors locked at their poses.
This set of examples shows how to use the jogging client using the python interface.
-
The first script reads continuously a pose from world view and uses jogging to move the EndEffector to that position.
-
The second script shows how a joint can be addressed and moved directly.
-
The third script shows how a twist can be applied to an end effector.
-
The fourth script uses pynput to allow jogging via keys and saving poses by pressing enter. For the key binding, press "h" after starting the script. To stop the listener thread, press "escape".
There are two dependencies needed not included in the current Docker image. Please install pynput and python3-tk from the rosvita terminal:
sudo pip install pynput sudo apt install python3-tk
Or use the install script
sudo example_07/install_dependencies.sh
This example show how to use the TaskTrajectoryCache to cache a set of trajectories. Also, basic serialization is shown by using the Cache of the xamla_vision package.
With the TaskTrajectoryCache one can precalculate a set of trajectories out of poses. At this moment, it supports:
- one-to-one: caching a single trajectory defined by two poses
- one-to-many: caching a set of trajectories, which all start at a fixed pose and end in poses defined by a set of poses (defined by a SampleVolume instance).
- many-to-one: caching a set of trajectories, which start at poses defined by a set of poses (defined by a SampleVolume instance) and end in a fixed pose.
Furthermore, the TaskTrajectoryCache instance gives access to the next best pre-calculated trajectory given a pose. If for example a one-to-many scenario has been pre-calculated, a random target pose which lies in the boundaries of the SampleVolume used for the pre-calculation can be chosen, and the TaskTrajectoryCache will return the nearest trajectory regarding its endpoint to the target pose. From there, simple linear movement can be done to move to the desired pose. The length of this movement depends on the density of the SampleBox instance.
The SampleBox takes a pose and some parameter to generate a set of poses, composing a 3-d grid of poses at certain translations and rotations.
- The first script shows how to instantiate a one-to-one TaskTrajectoryCache instance and serialize it. Here, the TaskTrajectoryCache instance is stored under the key "one_to_one", to avoid conflict with the other scripts. All scripts use the same cache file. but different keys.
- The second script shows the one-to-many TaskTrajectoryCache.
- The third script shows the many-to-one TaskTrajectoryCache.
- The fourth script uses the serialized TaskTrajectoryCaches to show how a pose can be used to find the best suited trajectory. For that, a new pose
target_pose
is added to world view, which can be moved within the boundaries of the SampleBox to show how different trajectories are selected and executed. The pose must lie in the grid. The SampleBox grid is generated around theend_pose
.
The script lazily calls the second and third script to generate the trajectories, so make sure to run remove_cache if the trajectories should be calculated anew.