pycram.external_interfaces.knowrob
==================================

.. py:module:: pycram.external_interfaces.knowrob


Attributes
----------

.. autoapisummary::

   pycram.external_interfaces.knowrob.desig_execution_start
   pycram.external_interfaces.knowrob.desig_execution_finished
   pycram.external_interfaces.knowrob.desig_resolution_start
   pycram.external_interfaces.knowrob.desig_resolution_finished
   pycram.external_interfaces.knowrob.desig_init
   pycram.external_interfaces.knowrob.object_desig


Functions
---------

.. autoapisummary::

   pycram.external_interfaces.knowrob.init_object_state
   pycram.external_interfaces.knowrob.pose_to_json
   pycram.external_interfaces.knowrob.object_to_json
   pycram.external_interfaces.knowrob.grasp_description_to_json
   pycram.external_interfaces.knowrob.kwargs_to_json
   pycram.external_interfaces.knowrob.designator_to_json
   pycram.external_interfaces.knowrob.get_current_ros_time
   pycram.external_interfaces.knowrob.execution_start_callback
   pycram.external_interfaces.knowrob.execution_finished_callback
   pycram.external_interfaces.knowrob.resolution_start_callback
   pycram.external_interfaces.knowrob.resolution_finished_callback


Module Contents
---------------

.. py:data:: desig_execution_start

.. py:data:: desig_execution_finished

.. py:data:: desig_resolution_start

.. py:data:: desig_resolution_finished

.. py:data:: desig_init

.. py:data:: object_desig

.. py:function:: init_object_state()

   Publishes the initial state of the objects in the world to Knowrob. Because of the lru_cache decorator, this function
   will only be called once, and the result will be cached for future calls.


.. py:function:: pose_to_json(pose: PoseStamped) -> Dict[str, Union[float, str]]

   Converts a PoseStamped object to a JSON-like dictionary.

   :return : A dictionary representation of the pose.


.. py:function:: object_to_json(obj: Union[knowrob_designator.msg.ObjectDesignator, Object]) -> Dict[str, Dict[str, str]]

   Converts an object or object designator to a JSON-like dictionary containing its type.

   :param obj: The object or object designator to convert.
   :return: A dictionary representation of the object.


.. py:function:: grasp_description_to_json(grasp: GraspDescription) -> Dict[str, Union[float, str]]

   Converts a GraspDescription object to a JSON-like dictionary.

   :param grasp: The GraspDescription object to convert.
   :return: A dictionary representation of the grasp.


.. py:function:: kwargs_to_json(kwargs: Dict) -> dict

   Converts the keyword arguments of a DesignatorNode to a JSON-like dictionary, calls the appropriate conversion function
   for each value based on its type.

   :param kwargs: The keyword arguments to convert.
   :return: A dictionary representation of the keyword arguments.


.. py:function:: designator_to_json(node: pycram.plan.DesignatorNode) -> str

   Converts a DesignatorNode to a JSON-like string representation uses the kwargs of the node for conversion.

   :param node: The DesignatorNode to convert.
   :return: A JSON-like string representation of the DesignatorNode.


.. py:function:: get_current_ros_time() -> pycram.ros.Time

   Returns the ROS time as a ROSTime object.

   :return: The current ROS time.


.. py:function:: execution_start_callback(node: pycram.plan.PlanNode)

   Callback function that is called when the execution of a designator starts. It publishes a message to Knowrob
   containing the designator that is executed.


.. py:function:: execution_finished_callback(node: pycram.plan.PlanNode)

   Callback function that is called when the execution of a designator finishes. It publishes a message to Knowrob
   containing the designator that has just finished executing.


.. py:function:: resolution_start_callback(node: pycram.plan.PlanNode)

   Callback function that is called when the resolution of a designator starts. It publishes a message to Knowrob
   containing the designator that is being resolved. It also sends the initial state of the objects in the world.


.. py:function:: resolution_finished_callback(node: pycram.plan.PlanNode)

   Callback function that is called when the resolution of a designator finishes. It publishes a message to Knowrob
   containing the designator that has just finished resolving.


