cppitasc.runtime

Runtime access for executing pitasc applications and runtime data exchange.

The Executor class is used for starting and executing apps, while the RuntimeAccess class provides access to input and output data of pitasc.

Example

>>> from pitasc.model_interface import SimpleInterface
>>> from cppitasc.runtime import Executor
>>> model = SimpleInterface()
>>> model.import_ros_file("pitasc_common", "examples/rosless/simple_move_rosless.xml")
# lots of [ Info  ] prints
(True, "Successfully loaded '/path/to/pitasc_common/examples/rosless/simple_move_rosless.xml' in X.XXX sec")
>>> executor = Executor(model)
# [ Info  ] prints regarding the license check
>>> executor.start("", {})
# lots of [ Info  ] prints
>>> executor.data.set_q_pos([0, 0, 0, 0, 0, 0])
>>> executor.step()
False  # -> the app is not finished
>>> executor.data.get_q_vel_cmd()
array([0., 0., 0., 0., 0., 0.])
>>> executor.data.set_q_pos([-0.2763951796306786, -1.810352244689719, 1.7330523352540461,
                       -1.4933876960477237, -1.5708139174643418, -1.8471973153217982])
>>> executor.step()
# lots of [ Info  ] prints -> app finished with Outcome: succeeded (previous q_pos was final position of app)
True  # -> the app has just finished
>>> executor.outcome()
'succeeded'
>>> executor.cleanup()
class cppitasc.runtime.Executor(model: pitasc.model.Model)

The Executor class is responsible for executing an application (or application skill). It builds the required runtime objects and provides functionality for running a complete app from start to finish (mainly used for real-time execution with ROS) or step-by-step (intended for RL applications). In the latter case, the methods start, step, cleanup and outcome are utilized.

Parameters:

model (Model) – pitasc model containing the application to be executed. Can be a wrapper if it provides a .model property or instance variable.

cleanup() None

Perform cleanup of runtime objects.

Call this function after the application has finished.

Raises:

RuntimeError – Raised if you call cleanup() twice

property data

Provides access to the input and output data of the pitasc runtime.

Type:

RuntimeAccess

outcome() str

Returns the outcome of the application after it has finished.

Returns:

outcome of the application. Typical values are “succeeded”, “exception” or “finished”.

Return type:

str

run(app_name: str, parameters: dict) None

Runs the application given by app_name from start to finish.

Parameters:
  • app_name (str) – Name of the application to be started.

  • parameters (dict of str to value) – The key gives the parameter path relative to the application, the value overwrites the default value given in the model.

start(app_name: str, parameters: dict) None

Starts the application given by app_name.

Parameters:
  • app_name (str) – Name of the application to be started.

  • parameters (dict of str to value) – The key gives the parameter path relative to the application, the value overwrites the default value given in the model.

step() bool

Executes one timestep of the pitasc execution runtime for the running app.

The time is set to 0 initially and then increased by T_s in each step with T_s = 1.0 / update_rate.

Returns:

True if the application is finished, False if not.

Return type:

bool

class cppitasc.runtime.RuntimeAccess(executor: Executor)

The RuntimeAccess class is responsible for accessing data of the pitasc runtime objects. This includes setting current joint positions, velocities and forces/torques, reading the calculated pitasc joint velocity commands, as well as reading current values of other arbitrary runtime objects.

Parameters:

executor (Executor) – Executor that runs the application.

get_data(model_element_path: str) np.ndarray

Retrieves the current output data of the runtime object corresponding to the given model element.

Returns:

Array of current output values of the specified runtime object.

Return type:

np.ndarray

get_data_keys(model_element_path: str) list

Retrieves the keys describing which output data can be read from the runtime object corresponding to the given model element.

Returns:

Keys describing which output data is read by get_data.

Return type:

list of str

get_q_vel_cmd() None

Returns current joint velocity command calculated by pitasc.

Returns:

Joint velocity commands calculated by pitasc in the last step. These

values should be given to the simulated or real robot to execute the pitasc app.

Return type:

np.ndarray

set_fts_name(fts_name: str, fts_driver_name: str = 'simple_wrench_driver') None

Specifies the force-torque sensor (driver) that will be accessed by calls to set_wrench.

Parameters:
  • fts_name (str) – Robot name in the pitasc model. Default value is ‘force_sensor’.

  • fts_driver_name (str) – Robot driver name in the pitasc model. Default value is ‘simple_wrench_driver’.

set_q_pos(q_pos: np.ndarray) None

Sets the current joint positions of the robot (used as input by the pitasc runtime).

Parameters:

q_pos (np.ndarray) – Array of joint positions.

set_q_vel(q_vel: np.ndarray) None

Sets the current joint velocities of the robot (used as input by the pitasc runtime).

Parameters:

q_vel (np.ndarray) – Array of joint velocities.

set_robot_name(robot_name: str, robot_driver_name: str = 'simple_robot_driver') None

Specifies the robot (driver) that will be accessed by calls to set_q_pos, set_q_vel and get_q_vel_cmd.

Parameters:
  • robot_name (str) – Robot name in the pitasc model. Default value is ‘robot’.

  • robot_driver_name (str) – Robot driver name in the pitasc model. Default value is ‘simple_robot_driver’.

set_wrench()

set_q_vel(wrench: np.ndarray) -> None

Sets the current forces and torques of the F/T sensor (used as input by the pitasc runtime).

Parameters:

wrench (np.ndarray) – 6D array of forces and torques (Fx, Fy, Fz, Tx, Ty, Tz).

cppitasc.runtime.roscpp_init()