call_python.h File Reference

Utilities for calling Python from C++. More...

#include <string>
#include <vector>
#include "drake/common/copyable_unique_ptr.h"
#include "drake/common/proto/call_matlab.h"
Include dependency graph for call_python.h:
This graph shows which files directly or indirectly include this file:


class  PythonAccessor< Policy >
class  PythonApi< Derived >
class  PythonRemoteVariable
 Presents variable stored in Python side. More...
class  PythonAttrPolicy
class  PythonItemPolicy
class  PythonAccessor< Policy >




using PythonItemAccessor = PythonAccessor< PythonItemPolicy >
using PythonAttrAccessor = PythonAccessor< PythonAttrPolicy >


void ToMatlabArray (const PythonRemoteVariable &var, MatlabArray *matlab_array)
template<typename... Types>
PythonRemoteVariable CallPython (const std::string &function_name, Types... args)
 Calls a Python client with a given function and arguments, returning a handle to the result. More...
template<typename... Types>
PythonRemoteVariable ToPythonTuple (Types... args)
 Creates a tuple in Python. More...
template<typename T >
PythonRemoteVariable NewPythonVariable (T value)
 Creates a new remote variable with the corresponding value set. More...
void PublishCallPython (const MatlabRPC &msg)
void CallPythonInit (const std::string &filename)
 Initializes CallPython for a given file. More...
template<typename... Types>
PythonRemoteVariable ToPythonKwargs (Types... args)
 Creates a keyword-argument list to be unpacked. More...

Detailed Description

Utilities for calling Python from C++.

Provides functionality similar to call_matlab (i.e., one-directional RPC), leveraging an API similar to pybind11.

See also
call_python_test.cc for C++ examples.