Verify with Example Programs

The PDK repository ships runnable examples in examples/. Clone it; paths on this page are relative to its root:

git clone https://github.com/flexivrobotics/flexiv_pdk.git
cd flexiv_pdk

Every example except watch_scene_events_example.py creates a workcell called example_workcell, and most delete it first, so do not run them against a workcell you want to keep.

Python examples

Run from the repository root with the SDK installed and a server running:

python examples/python/scene_example.py

The Python examples connect to localhost:50052. Set PDK_SERVER_ADDR to use another server:

PDK_SERVER_ADDR="192.168.1.100:50052" python examples/python/scene_example.py

Script

Shows

Needs

scene_example.py

Workcell, three objects, two facing robot systems. Setting Up a Scene

server

system_kinematics_example.py

Forward and inverse kinematics, with and without a seed. Kinematics

server

components_service_example.py

Custom tools and adapters, component catalogue, system URDF. Robot Systems and Components

server

system_setup_from_rdk_example.py

Add a system from a connected robot. Robot Systems and Components

real robot (RDK)

point_to_point_path_example.py

P2P planning with several collision configurations. Point-to-Point Motion Planning

P2P license

system_pose_example.py

Save system poses from FK; plan between them by name. Point-to-Point Motion Planning

P2P license

mesh_toolpath_sketch_example.py

Sketch tool path on a mesh. Surface Finish: Tool Paths and Robot Motion

surface-finish license, mesh asset

mesh_toolpath_raster_example.py

Raster tool path on a mesh. Surface Finish: Tool Paths and Robot Motion

surface-finish license, mesh asset

linear_path_trajectory_generation_example.py

Full pipeline: path, robot motion, process parameters, .traj export. Surface Finish: Tool Paths and Robot Motion

surface-finish license, mesh asset

mesh_area_extraction_example.py

Cut a polygon out of a mesh. Mesh Operations

mesh-operation license, mesh asset

mesh_filter_example.py

Smooth a mesh. Mesh Operations

mesh-operation license, mesh asset

camera_example.py

Wrist camera: online check, intrinsics, RGB-D, point cloud. Cameras and 3D Reconstruction

real robot, camera

reconstruction_example.py

Live 3D reconstruction from a camera. Cameras and 3D Reconstruction

real robot, camera

watch_scene_events_example.py

Stream scene events with a callback and with a generator. Watching Scene Events

server, and another client changing the scene

numpy_conversion_example.py

Round-trip every NumPy conversion. Math Conversions

nothing

watch_scene_events_example.py only prints events, so it shows nothing unless the scene changes while it runs. Run another example, or a pdk-scene command such as pdk-scene object create widget --box 0.1 0.1 0.1, in a second terminal.

The mesh asset

Mesh examples load plane_1m_10x10.obj. Copy examples/assets/plane_1m_10x10.obj to flexiv_pdk_data/user_data/meshes/plane_1m_10x10.obj on the server machine. The examples refer to it as /home/flexiv/user_data/meshes/plane_1m_10x10.obj, which is where the containerized server sees that folder (see Set Up the PDK Server). Adjust the path if your server is set up differently.

Real hardware

system_setup_from_rdk_example.py, camera_example.py and reconstruction_example.py connect to a real robot. Before running them:

  • the robot must run Flexiv software package v3.11.3;

  • enable RDK remote mode on the robot;

  • change serial_number in the script to your robot’s;

  • for the camera examples, enable the camera in Noema Edge’s AIConsole. The scripts use camera ID 9 on the robot’s flange: change camera_id to match, and set the camera’s parent to world for a camera that is not on the robot.

C++ example (CMake)

examples/cpp builds against an installed flexiv_pdk (Install for C++). It has a C++ program for every Python example above, under the same name and with the same requirements, so scene_example does what scene_example.py does. eigen_conversion_example is the twin of numpy_conversion_example.py: it round-trips every Eigen type through ToProto() and ToEigen(), and needs no server.

cd examples/cpp
mkdir -p build && cd build
cmake .. -DCMAKE_PREFIX_PATH=$HOME/pdk_install
make -j4
./scene_example
./eigen_conversion_example

or, from examples/cpp, in one step: FLEXIV_PDK_PREFIX=$HOME/pdk_install bash build.sh. It builds into examples/cpp/build.

Every C++ example connects to localhost:50052. Set PDK_SERVER_ADDR to use another server:

PDK_SERVER_ADDR="192.168.1.100:50052" ./scene_example

The example’s CMakeLists.txt:

cmake_minimum_required(VERSION 3.18.6)

# flexiv_pdk must be installed first (configure the repo root, then cmake --install with
# -DCMAKE_INSTALL_PREFIX=...). Configure this project with:
#   cmake -S . -B build -DCMAKE_PREFIX_PATH=<same install prefix>
# CMAKE_INSTALL_PREFIX on *this* project only controls where the examples install; it does not
# help CMake locate flexiv_pdk — use CMAKE_PREFIX_PATH (or flexiv_pdk_DIR) for that.

project(flexiv_pdk_cpp_examples VERSION 1.0.0)

find_package(flexiv_pdk REQUIRED)

set(EXAMPLES
  scene_example
  eigen_conversion_example
  components_service_example
  system_kinematics_example
  watch_scene_events_example
  point_to_point_path_example
  system_pose_example
  mesh_toolpath_raster_example
  mesh_toolpath_sketch_example
  linear_path_trajectory_generation_example
  mesh_filter_example
  mesh_area_extraction_example
  system_setup_from_rdk_example
  camera_example
  reconstruction_example
)

foreach(example ${EXAMPLES})
  add_executable(${example} src/${example}.cpp)
  target_link_libraries(${example} PRIVATE flexiv::flexiv_pdk)
  set_target_properties(${example} PROPERTIES
    CXX_STANDARD 17
    CXX_STANDARD_REQUIRED ON
  )
  if(CMAKE_HOST_UNIX)
    target_compile_options(${example} PRIVATE -Wall -Wextra -fPIC)
  endif()
endforeach()

include(GNUInstallDirs)
install(TARGETS ${EXAMPLES} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

ROS 2 examples

examples/ros is an ament package, pdk_cpp_examples, with two executables: scene_example and point_to_point_path_example.

cd ros2_ws
source /opt/ros/jazzy/setup.bash
rosdep install --from-paths src/flexiv_pdk --ignore-src -r -y
colcon build --paths src/flexiv_pdk src/flexiv_pdk/examples/ros
source install/setup.bash

ros2 run pdk_cpp_examples scene_example
ros2 run pdk_cpp_examples point_to_point_path_example

Both are built from the sources in examples/cpp/src and read PDK_SERVER_ADDR in the same way. examples/ros/scripts has helpers to run the build in an osrf/ros:jazzy-desktop Docker container.