C++ API
Hand-written reference for the C++ headers under include/flexiv/pdk/ of an
installed flexiv_pdk (cpp/include/flexiv/pdk/ in the source repository).
Generated headers follow the proto paths: messages in .pb.h (for example
flexiv/pdk/workcell/workcell_service.pb.h) and stubs in .grpc.pb.h.
Namespaces follow the proto packages (flexiv::pdk::workcell), with two
exceptions to note:
SurfaceFinishServiceand its requests are inflexiv::pdk::surface_finish::generator, notsurface_finish.MeshOperationServiceand its requests are inflexiv::pdk, notflexiv::pdk::mesh_operation.
CMake
find_package(flexiv_pdk REQUIRED)
target_link_libraries(my_app PRIVATE flexiv::flexiv_pdk) # plain CMake
ament_target_dependencies(my_node PUBLIC flexiv_pdk) # ROS 2
The target requires C++17 and brings in Eigen3, gRPC and Protobuf. See Install for C++.
Client
#include <flexiv/pdk/client.hpp>
-
template<typename ServiceT>
class ServiceClient Thin holder for a generated stub.
-
class Client
Owns the gRPC channel and lazily creates service clients. Not copyable or movable.
-
explicit Client(const std::string &target = "localhost:50052")
Create an insecure channel to target.
Use an existing channel. Throws
std::invalid_argumentif null.
-
VersionServiceClient &version()
-
LogServiceClient &log()
-
FrameServiceClient &frame()
-
SceneEventServiceClient &scene_event()
-
WorkcellServiceClient &workcell()
-
CollisionServiceClient &collision()
-
ComponentsServiceClient &system_config()
-
StateServiceClient &system_state()
-
SystemServiceClient &system()
-
KinematicsServiceClient &kinematics()
-
SurfaceFinishServiceClient &surface_finish()
-
ConfigServiceClient &config()
-
LicenseServiceClient &license()
-
PointToPointPathServiceClient &point_to_point_path()
-
MeshOperationServiceClient &mesh_operation()
-
CameraServiceClient &camera()
-
ReconstructionServiceClient &reconstruction()
Service accessors; thread-safe. Throw
std::runtime_errorafterclose().
-
explicit Client(const std::string &target = "localhost:50052")
-
class LicenseServiceClient : public ServiceClient<license::LicenseService>
Returned by
Client::license(), with a helper for installing license files.-
grpc::Status InstallFile(const std::string &path, license::SaveResponse *response, const std::string &file_name = "")
Install the
.licfile Flexiv sent back; takes effect immediately. The file is read on this machine and its contents sent, base64-encoded unless it already is. file_name defaults to the file’s own name, or to the license id when that name is not a plain one. Checkresponse->status()as with any other call. Throwsstd::runtime_errorif the file cannot be read or is empty.
-
bool CheckVersion(std::string *message = nullptr)
Ask the server whether this client works with it: same major and minor version. Returns false when the versions differ or the server cannot be reached. If message is not null, it is set to why not, or to the server version.
-
std::shared_ptr<grpc::Channel> channel() const
The channel; use it to create your own stubs, for example with custom call options. Returns null after
close().
-
void close()
Release the channel. Every accessor called afterwards throws. Do not use service client references or stubs obtained before the call.
-
grpc::Status InstallFile(const std::string &path, license::SaveResponse *response, const std::string &file_name = "")
Session
#include <flexiv/pdk/session.hpp>
Watch
#include <flexiv/pdk/watch/subscriber.hpp>
-
class Subscriber
Opens server-streaming RPCs as background subscriptions. Not copyable.
-
template<typename EventT>
Subscription Subscribe(ReaderOpener<EventT> open, EventCallback<EventT> on_event, Options options = {}) open is
std::function<std::unique_ptr<grpc::ClientReaderInterface<EventT>>(grpc::ClientContext*)>and is called again on every reconnect. on_event isstd::function<void(const EventT&)>.
-
void StopAll()
-
template<typename EventT>
-
class Subscription
Move-only handle. The watch runs while the handle is alive; discarding it ends the watch.
-
void reset()
Cancel the stream and block until delivery has stopped.
-
bool active() const noexcept
-
explicit operator bool() const noexcept
True while the watch runs. False once it is stopped, or once it gives up because
reconnectis off ormax_retriesis used up.
-
void reset()
-
struct Options
-
-
bool reconnect = true
-
std::chrono::milliseconds backoff_initial = 500ms
-
std::chrono::milliseconds backoff_max = 10000ms
-
double backoff_factor = 2.0
-
int max_retries = -1
-
bool reconnect = true
Eigen conversions
#include <flexiv/pdk/spatial/eigen_conversion.hpp>
-
Eigen::Vector3d ToEigen(const Vector3 &v)
-
Vector3 ToProto(const Eigen::Vector3d &v)
-
Eigen::Quaterniond ToEigen(const Quaternion &q)
-
Quaternion ToProto(const Eigen::Quaterniond &q)
-
Eigen::Isometry3d ToEigen(const SE3Pose &p)
-
SE3Pose ToProto(const Eigen::Isometry3d &p)
-
Eigen::VectorXd ToEigen(const google::protobuf::RepeatedField<double> &v)
-
google::protobuf::RepeatedField<double> ToProto(const Eigen::VectorXd &v)
-
std::pair<Eigen::VectorXd, Eigen::VectorXd> ToEigen(const JointWaypoint &waypoint)
Returns
(position, velocity).
-
JointWaypoint ToProto(const Eigen::VectorXd &joint_position, const Eigen::VectorXd &joint_velocity)
-
template<typename Derived>
Vector3 ToProto(const Eigen::MatrixBase<Derived> &v) For a fixed-size 3-vector expression, such as
Isometry3d::translation().
-
template<typename Derived>
google::protobuf::RepeatedField<double> ToProto(const Eigen::MatrixBase<Derived> &v) For a dynamic-size column-vector expression, such as
VectorXd::head().
An all-zero (unset) Quaternion converts to the identity rotation.
#include <flexiv/pdk/physics/eigen_conversion.hpp>
-
Eigen::Matrix3d ToEigen(const Inertia &I)
-
Inertia ToProto(const Eigen::Matrix3d &I)