Drake
Drake C++ Documentation
drake::common Namespace Reference

Namespaces

 test
 

Functions

void CallPythonInit (const std::string &filename)
 Initializes CallPython for a given file. More...
 
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... Types>
PythonRemoteVariable ToPythonKwargs (Types... args)
 Creates a keyword-argument list to be unpacked. More...
 
std::string GetRpcPipeTempDirectory ()
 Returns a directory location suitable for temporary files for the call_* clients and libraries. More...
 
void MaybePauseForUser (std::string_view message={})
 Pauses execution for the user to examine visualization output, for use within bazel unit tests. More...
 

Function Documentation

◆ CallPython()

PythonRemoteVariable drake::common::CallPython ( const std::string &  function_name,
Types...  args 
)

Calls a Python client with a given function and arguments, returning a handle to the result.

For example uses, see call_python_test.cc.

◆ CallPythonInit()

void drake::common::CallPythonInit ( const std::string &  filename)

Initializes CallPython for a given file.

If this function is not called, then the filename defaults to /tmp/python_rpc.

Exceptions
std::exceptionIf either this function or CallPython have already been called.

◆ GetRpcPipeTempDirectory()

std::string drake::common::GetRpcPipeTempDirectory ( )

Returns a directory location suitable for temporary files for the call_* clients and libraries.

Returns
The value of the environment variable TEST_TMPDIR if defined or otherwise /tmp. Any trailing / will be stripped from the output.
Exceptions
std::exceptionIf the path referred to by TEST_TMPDIR or /tmp does not exist or is not a directory.

◆ MaybePauseForUser()

void drake::common::MaybePauseForUser ( std::string_view  message = {})

Pauses execution for the user to examine visualization output, for use within bazel unit tests.

This function will not pause execution when running as a bazel test, but when running as a command-line executable, it will enable users to see the visualization outputs.

The caller can provide additional user instructions in message. The message will only be written to the console if the pause is actually enabled.

The complete behavior is somewhat more subtle, depending on the bazel rules used to build the program, and the way it is invoked:

  • built with a bazel test rule
    • invoked with "bazel test" – does not pause
    • invoked with "bazel run" – does not pause
    • invoked directly ("bazel/bin/[PROGRAM]") – does pause
  • built with a bazel binary rule
    • invoked with "bazel run" – does pause
    • invoked directly ("bazel/bin/[PROGRAM]") – does pause

◆ ToPythonKwargs()

PythonRemoteVariable drake::common::ToPythonKwargs ( Types...  args)

Creates a keyword-argument list to be unpacked.

Parameters
argsArgument list in the form of (key1, value1, key2, value2, ...).

◆ ToPythonTuple()

PythonRemoteVariable drake::common::ToPythonTuple ( Types...  args)

Creates a tuple in Python.