diff --git a/README.md b/README.md index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e355791ca5849b535672904a4c313e47d16c14f5 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,5 @@ +# RobotAPI + +## Documentation + +[Wiki](docs) diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000000000000000000000000000000000000..090ef176fc179e5adb7d27857b0fe9933928c0b0 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,3 @@ +[Aron](aron) + +[ArMem](armem) diff --git a/docs/armem/README.md b/docs/armem/README.md new file mode 100644 index 0000000000000000000000000000000000000000..1742eec0abd08fe86b0724828722338718348fd5 --- /dev/null +++ b/docs/armem/README.md @@ -0,0 +1,3 @@ +* [Introduction](introduction) +* [Existing Memories (Memory Servers)](existing_memory_servers_and_segments) +* [How to create a new Core Segment or Memory Server](how_to_create_a_new_core_segment_or_memory_server) diff --git a/docs/armem/existing_memory_servers_and_segments/README.md b/docs/armem/existing_memory_servers_and_segments/README.md new file mode 100644 index 0000000000000000000000000000000000000000..edc04ab4a3eda6652d59f2356687aa70d34a3db1 --- /dev/null +++ b/docs/armem/existing_memory_servers_and_segments/README.md @@ -0,0 +1,96 @@ +This is a list of existing memory servers, their core segments and their ARON data types. + +# `RobotState` + +* Memory Server: [`RobotStateMemory` (RobotAPI)](https://git.h2t.iar.kit.edu/sw/armarx/robot-api/-/tree/master/source/RobotAPI/components/armem/server/RobotStateMemory) +* Core Segments: + +| Core Segment Name | Type | Description | Example Entities | +|-------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------|-------------------------| +| `Description` | [RobotDescription](https://git.h2t.iar.kit.edu/sw/armarx/robot-api/-/blob/master/source/RobotAPI/libraries/armem_robot/aron/RobotDescription.xml) | Robot description (e.g. link to XML or URDF file) | | +| `Proprioception` | ToDo | Robot configuration and internal sensor values. | tbd | +| [`Localization`](RobotState/Localization) | [Transform](https://git.h2t.iar.kit.edu/sw/armarx/robot-api/-/blob/master/source/RobotAPI/libraries/armem_robot_localization/aron/Transform.xml) | Transformations between frames {world,map,robot} to retrieve global robot pose. | armarx::aron::Transform | + +Missing: +- Robot calibration: should be part of `Description` core segment + +# `Object` + +* Memory Server: [`ObjectMemory` (RobotAPI)](https://git.h2t.iar.kit.edu/sw/armarx/robot-api/-/blob/master/source/RobotAPI/components/armem/server/ObjectMemory) +* Core Segments: + +| Core Segment Name | Type | Description | Example Entities | +|-----------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------|-----------------------------------------------------| +| `Class` | [ObjectClass](https://git.h2t.iar.kit.edu/sw/armarx/robot-api/-/blob/master/source/RobotAPI/libraries/armem_objects/aron/ObjectClass.xml) | Static description of a known object class. Entity names are (ArmarXObjects) object IDs. | `KIT/CoffeeFilters`, `YCB/001_chips_can` | +| `Instance` | [ObjectInstance](https://git.h2t.iar.kit.edu/sw/armarx/robot-api/-/blob/master/source/RobotAPI/libraries/armem_objects/aron/ObjectInstance.xml) | Localized object instance. Entity names are (ArmarXObjects) object IDs. | `KIT/CoffeeFilters`, `YCB/001_chips_can/instance_1` | +| `ArticulatedObjectClass` | [RobotDescription](https://git.h2t.iar.kit.edu/sw/armarx/robot-api/-/blob/master/source/RobotAPI/libraries/armem_robot/aron/RobotDescription.xml) | Static description of a known object class. Entity names are (ArmarXObjects) object IDs. | | +| `ArticulatedObjectInstance` | [Robot](https://git.h2t.iar.kit.edu/sw/armarx/robot-api/-/blob/master/source/RobotAPI/libraries/armem_robot/aron/Robot.xml) | Localized object instance. Entity names are (ArmarXObjects) object IDs. | | +| `Attachments` | [ObjectAttachment and ArticulatedObjectAttachment](https://git.h2t.iar.kit.edu/sw/armarx/robot-api/-/blob/master/source/RobotAPI/libraries/armem_objects/aron/Attachment.xml) | | | + + +# `Vision` + +* Memory Server: [`ArMemVisionMemory` (VisionX)](https://git.h2t.iar.kit.edu/sw/armarx/visionx/-/tree/master/source/VisionX/components/armem/ArMemVisionMemory) +* Core Segments: + +| Core Segment Name | Type | Description | Example Entities | +|-------------------|--------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------|------------------| +| `ImageRGB` | [`ImageRGB`](https://git.h2t.iar.kit.edu/sw/armarx/visionx/-/blob/master/source/VisionX/libraries/ArMem/aron/ImageRGB.xml) | RGB images (mono and stereo) of a camera | image | +| `ImageDepth` | [`ImageDepth`](https://git.h2t.iar.kit.edu/sw/armarx/visionx/-/blob/master/source/VisionX/libraries/ArMem/aron/ImageDepth.xml) | Depth images of an RGB-D or stereo camera | image | + + + +# `Speech` + +* Memory Server: [`SpeechMemory` (SpeechX)](https://git.h2t.iar.kit.edu/sw/armarx/speechx/-/tree/master/source/SpeechX/components/SpeechMemory) +* Core Segments: + +| Core Segment Name | Type | Description | Example Entities | +|-------------------------|-----------------|---------------------------------------------------------------------------|------------------| +| `Command` | `SpeechCommand` | Language commands from speech (topic `Speech_Commands`). | `command` | +| `TextListenerInterface` | `Text` | Data from `TextListenerInterface` topics. (`TextToSpeech`, `RobotAction`) | `text` | + +... + + +# `Skills` + +* Memory Server: [`SkillsMemory` (RobotAPI)](https://git.h2t.iar.kit.edu/sw/armarx/robot-api/-/tree/master/source/RobotAPI/components/armem/server/SkillsMemory) +* Core Segments: + +| Core Segment Name | Type | Description | Example Entities | +|-------------------|--------------|-------------------------------------|------------------| +| `Statechart` | `Transition` | Transitions in ArmarX state charts. | tbd | + + +# `GeneralPurpose` + +This memory is meant to allow for a quick-and-dirty integration of your data type in the memory framework. When your development finishes a stable state, consider creating moving the core segment(s) to an existing memory server or creating a new dedicated memory server. + +* Memory Server: [`GeneralPurposeMemory` (RobotAPI)](https://git.h2t.iar.kit.edu/sw/armarx/robot-api/-/tree/master/source/RobotAPI/components/armem/server/GeneralPurposeMemory) +* Core Segments: + +| Core Segment Name | Type | Description | Example Entities | +|----------------------------------------|------|-------------|------------------| +| None. You can add segments on the fly. | | | | + +# `Mapping` + +* Memory Server: `ToDo` +* Core Segments: + +| Core Segment Name | <br/>Type | Description | Example Entities | +|---------------------------------|-----------|--------------------------------------------------|------------------| +| [`Mapping`](RobotState/Mapping) | `ToDo` | Mapping related sensor data (e.g. point clouds). | tbd | + + +# `Example` + +An example memory server (alongside a matching client) showing how to implement a standard memory server and test the framework during development. + +* Memory Server: [`ExampleMemory` (RobotAPI)](https://git.h2t.iar.kit.edu/sw/armarx/robot-api/-/tree/master/source/RobotAPI/components/armem/server/ExampleMemory) +* Core Segments: + +| Core Segment Name | Type | Description | Example Entities | +|-------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------|------------------| +| `ExampleData` | [ExampleData](https://git.h2t.iar.kit.edu/sw/armarx/robot-api/-/blob/master/source/RobotAPI/components/armem/server/ExampleMemory/aron/ExampleData.xml) | Some example data. | example | \ No newline at end of file diff --git a/docs/armem/existing_memory_servers_and_segments/RobotState/Localization/README.md b/docs/armem/existing_memory_servers_and_segments/RobotState/Localization/README.md new file mode 100644 index 0000000000000000000000000000000000000000..fe8ac7af138bca553c7a80c3683ff74db0156c90 --- /dev/null +++ b/docs/armem/existing_memory_servers_and_segments/RobotState/Localization/README.md @@ -0,0 +1,36 @@ +# The localization segment within the RobotState memory + +## Concept + +There exist various frames that are needed to obtain the robot's global pose (pose within in the global frame): + +* [global] the "world" frame. +* [map] During mapping, the robot does not have knowledge about the world but creates a local map (with "map" as root frame). All map features (e.g. point clouds, occupancy grids, ...) are linked to this frame. +* [odom] The odometry as an integration of the robot's velocity. +* [robot] The robot's root frame + + + +For each transformation between frames, there exist individual components: + +* [global->map] **Map registration:** given a scene (objects with known poses, e.g. walls, ...), this component obtains a static transformation between a the scene and the map. +* [map->odom] **Localization** The localization component computes the transformation [map->robot] and performs map corrections by updating [map->odom]. +* [odom->robot] **Odometry** + + +### Memory design + +Within the core segment, each robot has its own provider segment (here: Armar6). Within the provider segment, entities describe the transformations between the frames ("Global,Map" -> [global->map]). + + + +### Using the localization memory + +See **RobotAPI/libraries/armem_robot_localization** + +There exist two classes: + +* TransformWriter to send transformations to memory +* TransformReader to obtain transformations between any of the frames; can also be used to obtain the "robot's global pose" + +For an example, see RobotComponents/components/carographer_mapping_and_localization (currently branch feature/cartographer_integration) diff --git a/docs/armem/existing_memory_servers_and_segments/RobotState/Localization/res/frames.png b/docs/armem/existing_memory_servers_and_segments/RobotState/Localization/res/frames.png new file mode 100644 index 0000000000000000000000000000000000000000..35125768524bef2ae285af2bbfedf1b15cfebbb7 Binary files /dev/null and b/docs/armem/existing_memory_servers_and_segments/RobotState/Localization/res/frames.png differ diff --git a/docs/armem/existing_memory_servers_and_segments/RobotState/Localization/res/localization-armem.png b/docs/armem/existing_memory_servers_and_segments/RobotState/Localization/res/localization-armem.png new file mode 100644 index 0000000000000000000000000000000000000000..14240f9f9c78b34a65f70b85f6ae7e38e98bf992 Binary files /dev/null and b/docs/armem/existing_memory_servers_and_segments/RobotState/Localization/res/localization-armem.png differ diff --git a/docs/armem/existing_memory_servers_and_segments/RobotState/Mapping/README.md b/docs/armem/existing_memory_servers_and_segments/RobotState/Mapping/README.md new file mode 100644 index 0000000000000000000000000000000000000000..167e058d44b78ebec0f59d97c2dc4f7ffc7eef72 --- /dev/null +++ b/docs/armem/existing_memory_servers_and_segments/RobotState/Mapping/README.md @@ -0,0 +1,9 @@ +# The mapping segment within the RobotState memory + +## Concept + +Within the memory segment, sensor data is stored that is relevant for +* mapping +* map registration + + diff --git a/docs/armem/existing_memory_servers_and_segments/RobotState/Mapping/res/transformations_frames-Page-2.png b/docs/armem/existing_memory_servers_and_segments/RobotState/Mapping/res/transformations_frames-Page-2.png new file mode 100644 index 0000000000000000000000000000000000000000..65e856849ff9fc62016d27b1631f8d456b5a22b1 Binary files /dev/null and b/docs/armem/existing_memory_servers_and_segments/RobotState/Mapping/res/transformations_frames-Page-2.png differ diff --git a/docs/armem/how_to_create_a_new_core_segment_or_memory_server/README.md b/docs/armem/how_to_create_a_new_core_segment_or_memory_server/README.md new file mode 100644 index 0000000000000000000000000000000000000000..9aaf1d9795a9ea38ae6414dc39ad03566f9f13da --- /dev/null +++ b/docs/armem/how_to_create_a_new_core_segment_or_memory_server/README.md @@ -0,0 +1,393 @@ +In order to make a new type of data available in the memory system, you first need to create an ARON XML file. Please refer to [Aron/CodeGeneration](Aron/CodeGeneration) if you want to know how to do so. + +[[_TOC_]] + +<!-- +# Define your data type in ARON + +Consider you want to use a data type called `MyData` (in the namespace `armarx::mydata`) in the memory system. First, you need to describe it in ARON. + +- Choose a library in an ArmarX package where your data type will be defined (or create a new one). Here, we will call it `MyDataLib`. +- In the directory `MyDataLib/`, create a directory `aron/` (if necessary). Inside, add a file `MyData.xml`. The directory structure should now look like this: + +```plaintext +.../libraries/ +- MyDataLib/ + - CMakeLists.txt + - ... + - aron/ + - MyData.xml +``` + +- In the `CMakeLists.txt`, add or extend after the definition of the target (e.g. through add_library or add_component): + +```cmake +armarx_enable_aron_file_generation_for_target( + TARGET_NAME + ${LIB_NAME} + ARON_FILES + aron/MyData.xml +) +``` + +- Define your data in ARON. A hello world example could look like this: + +```xml +<?xml version="1.0" encoding="UTF-8" ?> +<AronTypeDefinition> + <CodeIncludes> + </CodeIncludes> + <AronIncludes> + </AronIncludes> + <GenerateTypes> + + <Object name="armarx::mydata::arondto::MyData"> + + <ObjectChild key="helloWorld"> + <String /> + </ObjectChild> + + </Object> + + </GenerateTypes> +</AronTypeDefinition> +``` + +Note: + +- `<Object>` defines a new ARON object type (generating a C++ class) containing a number of children. +- `<ObjectChild>` defines a child (generating a public member variable of the generated C++ class, with `key` specifying the member's name). +- `<String />` inside a `<ObjectChild>` defines the type of the child. It can be a number of primitive types, or fully qualified names of other ARON objects. + +Conventions: + +- Put your ARON object type into a `arondto::` namespace inside your usual namespace (e.g., `armarx::mydata::arondto::MyData`), where "DTO" stands for "Data Transfer Object". This way, you can define or use a custom or existing C++ type with more methods/intelligence in the usual namespace in your business logic code (e.g. `armarx::mydata::MyData`). + +Here is an example of an ARON object representing the business object (BO) type `simox::OrientedBox`: + +```xml +<?xml version="1.0" encoding="UTF-8" ?> +<AronTypeDefinition> + <CodeIncludes> + <Include include="<Eigen/Core>" /> + <Include include="<Eigen/Geometry>" /> + </CodeIncludes> + <GenerateTypes> + + <Object name="simox::arondto::OrientedBox"> + <ObjectChild key='center'> + <Position /> + </ObjectChild> + <ObjectChild key='orientation'> + <Orientation /> + </ObjectChild> + <ObjectChild key='extents'> + <Position /> + </ObjectChild> + + </Object> + + </GenerateTypes> +</AronTypeDefinition> +``` + +Note: + +- (At the moment), you need to specify `<CodeIncludes>` to Eigen to use `Pose`, `Position` and `Orientation` (which are translated to `Eigen::Matrix4f`, `Eigen::Vector3f`, and `Eigen::Quaternionf` in C++). + +If you want to use an ARON object type defined in another file, this could look like this: + +```xml +<?xml version="1.0" encoding="UTF-8" ?> +<AronTypeDefinition> + <CodeIncludes> + <Include include="<RobotAPI/libraries/aron/common/aron/AxisAlignedBoundingBox.aron.generated.h>" /> + <Include include="<RobotAPI/libraries/aron/common/aron/OrientedBox.aron.generated.h>" /> + <Include include="<RobotAPI/libraries/aron/common/aron/PackagePath.aron.generated.h>" /> + <Include include="<RobotAPI/libraries/ArmarXObjects/aron/ObjectID.aron.generated.h>" /> + <Include include="<RobotAPI/libraries/ArmarXObjects/aron/ObjectNames.aron.generated.h>" /> + <Include include="<RobotAPI/libraries/armem/aron/MemoryID.aron.generated.h>" /> + </CodeIncludes> + <AronIncludes> + <Include include="<RobotAPI/libraries/aron/common/aron/AxisAlignedBoundingBox.xml>" /> + <Include include="<RobotAPI/libraries/aron/common/aron/OrientedBox.xml>" /> + <Include include="<RobotAPI/libraries/aron/common/aron/PackagePath.xml>" /> + <Include include="<RobotAPI/libraries/ArmarXObjects/aron/ObjectID.xml>" /> + <Include include="<RobotAPI/libraries/ArmarXObjects/aron/ObjectNames.xml>" /> + <Include include="<RobotAPI/libraries/armem/aron/MemoryID.xml>" /> + </AronIncludes> + <GenerateTypes> + + <Object name="armarx::armem::arondto::ObjectClass"> + + <ObjectChild key="id"> + <armarx::arondto::ObjectID /> + </ObjectChild> + + <ObjectChild key="simoxXmlPath"> + <armarx::arondto::PackagePath /> + </ObjectChild> + + <ObjectChild key="meshWrlPath"> + <armarx::arondto::PackagePath /> + </ObjectChild> + + <ObjectChild key="meshObjPath"> + <armarx::arondto::PackagePath /> + </ObjectChild> + + <ObjectChild key="aabb"> + <simox::arondto::AxisAlignedBoundingBox /> + </ObjectChild> + <ObjectChild key="oobb"> + <simox::arondto::OrientedBox /> + </ObjectChild> + + <ObjectChild key="names"> + <armarx::arondto::ObjectNames /> + </ObjectChild> + + </Object> + + </GenerateTypes> +</AronTypeDefinition> +``` + +Note: + +- You need to include other ARON files in `<AronIncludes>`. The paths have the same form as usual C++ includes and point to the ARON XML files. +- At the moment, you also have to `<CodeInclude>` the respective generated headers (`.../MyData.aron.generated.h`). These should be generated automatically in the future. + +# (Optional) Add conversions to existing (potentially more intelligent) C++ types + +Consider the case of `simox::OrientedBoxf` and `simox::arondto::OrientedBox`. The former is the business object (BO), used in daily business logic code (as it offers useful methods to construct and manipulate it). The latter is a mere data storage used to transfer the data, which is called a data transfer object (DTO). + +Therefore, you usually want to convert a `simox::arondto::OrientedBox` to a `simox::OrientedBoxf` as soon as you want to do things other than passing it around over network (e.g., at the beginning of a component method or after reading it from the working memory). Likewise, you want to convert a `simox::OrientedBoxf` to a `simox::arondto::OrientedBox` when you send the information over network or store it in the memory. + +To allow this conversion, follow these steps: + +- In your library, add a file pair `aron_conversions.{h, cpp}` next to your `aron/` directory and add them to the `CMakeLists.txt` +- In the header, declare functions following this form: + +```cpp +#pragma once + +#include <SimoxUtility/shapes/OrientedBox.h> +#include <RobotAPI/libraries/aron/common/aron/OrientedBox.aron.generated.h> + + +namespace simox +{ + void fromAron(const arondto::OrientedBox& dto, OrientedBoxf& bo); + void toAron(arondto::OrientedBox& dto, const OrientedBoxf& bo); +} +``` + +Note: + +- Both functions take the DTO first and the BO second. +- `fromAron()` takes a `const` DTO and a `non-const` BO. +- `toAron()` takes a `non-const` DTO and a `const` BO. +- All arguments are passed as reference (especially the `non-const` arguments). +- The functions are defined in the BO's namespace (`simox` in this example, `armarx::mydata` in the running example). + + +* In the cpp file, define the functions like this: + +```cpp +#include "aron_conversions.h" + +// Include this and use armarx::aron::to/fromAron() for std::vector, std::map. +#include <RobotAPI/libraries/aron/common/aron_conversions.h> + +// Include other aron_conversions.h files for other ARON types + + +void simox::fromAron(const arondto::OrientedBox& dto, OrientedBoxf& bo) +{ + bo = OrientedBoxf(dto.center, dto.orientation, dto.extents); +} + +void simox::toAron(arondto::OrientedBox& dto, const OrientedBoxf& bo) +{ + dto.center = bo.center(); + dto.orientation = bo.rotation(); + dto.extents = bo.dimensions(); +} +``` + +Note: + +- The implementation depends on your data. It might be as simple as copying all members, or require more complex conversions. Especially, you might use `fromAron()` for `toAron()` for other ARON object types. + +--> + +# Create a new memory server + +> **Note:** If you plan to extend an existing memory server, you can skip this step. + +If your data should be stored in a new memory server, follow these steps: + +Create a new component, let's say `MyMemory`: + +```plaintext +# In the root directory of your ArmarX package: +armarx-package add component MyMemory +``` + +Then, extend the new component by the respective component plugin. + +Add the include: + +```cpp +#include <RobotAPI/libraries/armem/server/plugins/ReadWritePluginUser.h> + +// Or: +#include <RobotAPI/libraries/armem/server/plugins/ReadOnlyPluginUser.h> +``` + +Make the component derive from the component plugin user: + +```cpp + class MyMemory : + virtual public armarx::Component + // v Add this line ... v + , virtual public armarx::armem::server::ReadWritePluginUser + // v ... or this line ... v + , virtual public armem::server::ReadOnlyPluginUser +``` + +Don't forget to add the respective library to your `CMakeLists.txt`: + +```cmake +set(COMPONENT_LIBS + ... + # Add this: + armem + ... +) +``` + +**If the component already implements an ice interface,** you have to add the memory server into face to it (otherwise, you will receive `no unique final overrider for 'virtual function ...'` errors by the compiler): +```cpp +// memory_tutorial/source/memory_tutorial/components/object_memory/ComponentInterface.ice + +#pragma once + +// v either include this one (read-write) v +#include <RobotAPI/interface/armem/server/MemoryInterface.ice> +// v or this one (read-only) v +// #include <RobotAPI/interface/armem/server/ReadingMemoryInterface.ice> + + +module memory_tutorial { module components { module object_memory +{ + + interface ComponentInterface + // v either extend from this one (read-write) v + extends armarx::armem::server::MemoryInterface + // v or this one (read-only) v + // extends armarx::armem::server::ReadingMemoryInterface + { + ... + }; + +};};}; +``` + +In this case, make sure `RobotAPIInterfaces` is in the Ice dependencies of your ice library: +```cmake +armarx_add_component(object_memory + ICE_FILES + ComponentInterface.ice + ICE_DEPENDENCIES + ... + RobotAPIInterfaces + ... +``` + + +You can set the memory name of the memory server in the `createPropertyDefinitions()`: + +```cpp +#include <RobotAPI/libraries/armem/server/wm/memory_definitions.h> + +... + + armarx::PropertyDefinitionsPtr MyMemory::createPropertyDefinitions() + { + armarx::PropertyDefinitionsPtr defs = new ComponentPropertyDefinitions(getConfigIdentifier()); + ... + + // Set the memory name: + workingMemory().name() = "My"; + + ... + return defs; + } +``` + +**Note:** + +* The `ReadWritePluginUser` implements the ice interface `MemoryInterface`, which combines, among others, the `ReadingMemoryInterface` and the `WritingMemoryInterface`. +* The `ReadOnlyPluginUser` only implements the `ReadingMemoryInterface`. +* Both provide a working memory data storage `workingMemory()` (of type `armem::server::wm::Memory`) and an `iceAdapter()` (`armem::server::MemoryToIceAdapter`). + +That's it: Your component is now a memory server. + +# Add a core segment with your new data type in a memory server + +> Wait, how does the new memory server know of my specially written ARON type? + +Oh right, it doesn't. At least not yet. But this is easy to fix: We just have to add a core segment. + +> What on earth is a core segment? + +A _segment_ is a section of a memory (server) containing data of a specific type, i.e. they are homogeneous data containers (in contrast to heterogeneous, which would mean they contain different kinds of data) (see the [Introduction](ArMem/Introduction)). + +There are two kinds of segments: _core_ segments, and _provider_ segments: + +* **Core segments** are usually added by the memory server itself with a name and the ARON data type the core segment is going to keep. +* **Provider segments** are usually added by clients committing data to the memory. You can think of them as "sub-segments" of a (core) segment, providing a namespace for the provider's entities and some additional features. + +> ... what? + +Just stick with me, you'll get used to it. + +> Okay ... but how does the memory add the ... core segment? + +A fine question! Luckily, that's very simple. All we need is your ARON type, a name and the working memory data structure. + +> ... + +Okay, okay, I'll come to the code. Adding a core segment merely alters a local data structure (it is not an ice/network operation). Thus, we can do it in `onInitComponent()`: + +```cpp + void MyMemory::onInitComponent() + { + workingMemory().addCoreSegment("Data", armarx::mydata::arondto::MyData::toAronType()); + } +``` + +* `workingMemory()` is a function provided by the component plugin user (`ReadWritePluginUser` or `ReadOnlyPluginUser`) returning a reference to the working memory data of the type `armem::server::wm::Memory`. +* `addCoreSegment()` adds a core segment. It takes a name and (optionally) an ARON type. +* `"Data"` is the name of the core segment. + * It should refer to a modality or concept, not to its elements (i.e. prefer "Instance" over "Instances" and "Location" over "Locations"). + * Also, try to avoid repeating the memory name, as the core segment's ID is prepended by the memory name anyway (e.g. "Object/Instance" over "Object/ObjectInstance" and "Navigation/Location" over "Navigation/NavigationLocation"). +* `armarx::mydata::arondto::MyData` is the C++ class generated from your `MyData.xml` ARON XML description file. + * `::toAronType()` creates a runtime type object describing the ARON type. This allows, e.g., the `MemoryViewer` GUI to show the data in a suitable manner (e.g. a pose as an affine transformation instead of a 4x4 matrix). + * Of course, you need to include the respective header: It's located at the same path where your XML is. For example, for the `ObjectInstance.xml` located at `RobotAPI/libraries/armem_objects/aron/ObjectInstance.xml`, the include would be: + +```cpp +#include <RobotAPI/libraries/armem_objects/aron/ObjectInstance.h> +``` + +Note that you need to include the `.h` file, not the `.xml`. As the generated class is header-only, you do not need to link any libraries in your `CMakeLists.txt`. + +When you now start your new memory server and the MemoryNameSystem (MNS) (e.g. using the scenario _ArMemCore_ in RobotAPI), and open the _MemoryViewer_ gui plugin, you should see an entry for your memory (`My`) and the core segment (`Data` under `My`). + +# Conclusion + +That's it! You now have a memory server providing a place where your nice and interesting data can feel welcome, and where interested listeners would look to find it. + +[Next, we learn how to commit data to the memory, and query data from the memory.](ArMem/How-to-read-from-and-write-to-a-Memory-Server) \ No newline at end of file diff --git a/docs/armem/introduction/README.md b/docs/armem/introduction/README.md new file mode 100644 index 0000000000000000000000000000000000000000..43f2e3ac5e1b169c900f5793875bc5788a79c37a --- /dev/null +++ b/docs/armem/introduction/README.md @@ -0,0 +1,42 @@ +# Distributed Memory + +The ArMem memory system is distributed: It is comprised of several **memory servers** storing data in a hierarchical structure. +A memory server can be defined in any ArmarX package and defines which kind of data it stores (e.g. robot state, object classes and instances, visual data, speech, ...). +As a memory server knows which data it stores, it can provide special behaviour, such as custom visualization, aggregation, interpolation or prediction. +As each server is a separate component describing its own structure, it is simple to add new memory servers containing special data types, which are defined in ArmarX packages further down in the dependency chain. + +All memory servers follow the same hierarchical data structure and self-describing data format. +The data structure consists of several levels, storing histories/timelines of different entities stored in different segments (see "Memory Levels" below). +The common data format is ARON (ArmarX Object Notation), which is a self-describing, hierarchical data format, allowing extensive introspection as well as general storage. +Each item in the memory (i.e. entries in all levels) can be identified with a **Memory ID**, which contains the keys of each (specified) level. For example, a core segment ID specifies the memory name and core segment name, while an entity instance ID specifies the whole path to the leaf of the data structure. + + +Technically, each memory server is one ArmarX component implementing the `armem::server::MemoryInterface` (comprising a `ReadingMemoryInterface` and a `WritingMemoryInterface`). +Memory servers register themselves in the **Memory Name System (MNS)**, where they can be found by their (semantic) memory name (which is usually a short, human-readable name such as "Robot", "Object" or "Vision"). +Memory servers receive data via **commits** (via the `WritingMemoryInterface`), and return data according to **queries** (via the `ReadingMemoryInterface`). + + +# Memory Levels + +A memory server stores data in a hierarchical structure consisting of several levels: +``` +- Grasping (Memory) + - Grasps (Core Segment) + - KnownObjectGraspPlanner (Provider Segment) + - my_object (Entity) + - t = 2021-03-09 14:24:20.064524 (Entity Snapshot) + - 00 (Entity Instance) + - 01 (Entity Instance) + - 02 (Entity Instance) +``` + +| Level | Key | Description | Examples | Implementation | +| ----- | --- | ----------- | -------- | -------------- | +| Memory | Name (String) | Semantic grouping of one or more core segments. Corresponds to one memory server. | Robot, Object, Vision | [Memory](https://git.h2t.iar.kit.edu/sw/armarx/robot-api/-/blob/master/source/RobotAPI/libraries/armem/core/Memory.h) | +| Core Segment | Name (String) | Building block of a memory containing homogeneous data of a specific (ARON) type. Specifies a _Core Segment Type_ which all provided data must comply to. | (Robot) Configuration, (Object) Classes, Known (Object) Instances, ImageRGB | [CoreSegment](https://git.h2t.iar.kit.edu/sw/armarx/robot-api/-/blob/master/source/RobotAPI/libraries/armem/core/CoreSegment.h) | +| Provider Segment | Name (String) | Sub-segment of a core segment which contains the data from a single source (e.g. a camera, a method, a component). Can define a _Provider Segment Type_ which extends the _Core Segment Type_. | Primsense, SimTrack, MyGraspPlanner | [ProviderSegment](https://git.h2t.iar.kit.edu/sw/armarx/robot-api/-/blob/master/source/RobotAPI/libraries/armem/core/ProviderSegment.h) | +| Entity | Name (String) | A single thing or concept whose properties change over time. An entity has a history / timeline, i.e. a sequence of snapshots storing the entity's properties at a specific point in time. | `image`, `some_object`, `some_object_grasps` | [Entity](https://git.h2t.iar.kit.edu/sw/armarx/robot-api/-/blob/master/source/RobotAPI/libraries/armem/core/Entity.h) | +| Entity Snapshot | Timestamp (`armem::Time` aka `IceUtil::Time`) | An entry of an entity's history, i.e. the state of an entity at a specific point in time. Can contain multiple (entitiy) instances. | Image, object instance, grasp hypotheses at a time *t* | [EntitySnapshot](https://git.h2t.iar.kit.edu/sw/armarx/robot-api/-/blob/master/source/RobotAPI/libraries/armem/core/EntitySnapshot.h) | +| Entity Instance | Index (int) | One instance of the segment's ARON type. | left/right stereo image (at time t), object (at time t), grasp hypothesis (one of many at time t) | [EntityInstance](https://git.h2t.iar.kit.edu/sw/armarx/robot-api/-/blob/master/source/RobotAPI/libraries/armem/core/EntityInstance.h) | +| Entity Instance Metadata | -- | Metadata stored alongside the instance's data. | Further timesteps, confidence | [EntityInstanceMetadata](https://git.h2t.iar.kit.edu/sw/armarx/robot-api/-/blob/master/source/RobotAPI/libraries/armem/core/EntityInstance.h) | + diff --git a/docs/aron/README.md b/docs/aron/README.md new file mode 100644 index 0000000000000000000000000000000000000000..daff059aabe7c576936c41e30789b87fc63c6b1c --- /dev/null +++ b/docs/aron/README.md @@ -0,0 +1,4 @@ +* [Introduction](introduction) +* [Code Generation](code_generation) +* [Visitors](visitors) +* [Readers, Writers and Conversion](conversion) diff --git a/docs/aron/code_generation/README.md b/docs/aron/code_generation/README.md new file mode 100644 index 0000000000000000000000000000000000000000..a48594a45348e392a3d074ccb752c94c7ead9b2d --- /dev/null +++ b/docs/aron/code_generation/README.md @@ -0,0 +1,733 @@ +[[_TOC_]] + +# Aron Type Reading + +As already mention in the introduction, aron supports code generation in order to create a c++ (other languages also possible) class with plain c++ members which you can use for convenience. Further, the generated class offers methods to convert itself to a Aron object and to set the members from a Aron object. Code generation only makes sense for Aron data, however we need an Aron type specification in order to generate the class. + +In the following we will describe how to specify Aron types in XML and how the generated code looks like. + + +## XML type description and creation + +In order to make Aron generate a c++ class for you, you first have to tell the program how the object should look like. Second you need to add the file to cmake in order to create the code generation target. + +### XML type description + +Consider you want to use a data type called `MyData` (in the namespace `armarx::mydata`). +* Choose a library in an ArmarX package where your data type will be defined (or create a new one). Here, we will call it `MyDataLib`. +* In the directory `MyDataLib/`, create a directory `aron/` (if necessary). Inside, add a file `MyData.xml`. The directory structure should now look like this: + +``` +.../libraries/ +- MyDataLib/ + - CMakeLists.txt + - ... + - aron/ + - MyData.xml +``` + +Then start defining your data in ARON. A hello world example could look like this: +```xml +<!-- MyData containing a helloWorld member --> +<?xml version="1.0" encoding="UTF-8" ?> +<AronTypeDefinition> + <CodeIncludes> + </CodeIncludes> + <AronIncludes> + </AronIncludes> + <GenerateTypes> + <Object name="armarx::mydata::arondto::MyData"> + <ObjectChild key="helloWorld"> + <String /> + </ObjectChild> + </Object> + </GenerateTypes> +</AronTypeDefinition> +``` + +Every type specification must have the top-level-tag `AronTypeDefinition` and must at least define one type in `GenerateTypes`. In the `GenerateTypes`-tag you can add as many `Object` or `IntEnum` definitions as you want. `<Object>` defines a new ARON object type (generating a C++ class) containing a number of children. Inside the `Object`-tag you can add as many members as you want through the `ObjectChild`-tag (generating a public member variable of the generated C++ class, with `key` specifying the member's name). If a member should be e.g. optional you have to add the attribute `optional="true"` to the member: +```xml + <ObjectChild key="helloWorld"> + <String optional="true" /> + </ObjectChild> +``` +The same way you can define `raw_ptr`, `shared_ptr` or `unique_ptr` members. + +Conventions: +- Put your ARON object type into a `arondto::` namespace inside your usual namespace (e.g., `armarx::mydata::arondto::MyData`), where "DTO" stands for "Data Transfer Object". This way, you can define or use a custom or existing C++ type with more methods/intelligence in the usual namespace in your business logic code (e.g. `armarx::mydata::MyData`). + +If you want to use a definition of another Aron file, you can include the file using the `AronIncludes`-section. Simply add the files you want to include using a `include`-tag: +```xml + <AronIncludes> + <Include include="<RobotAPI/libraries/aron/common/aron/PackagePath.xml>" autoinclude="true" /> + ... + </AronIncludes> +``` +The option `autoinclude` automatically adds the generated class of the Aron xml file to the c++ class. + +After that, you can use the type definitions in your current xml file (you must specify the full namespace): +```xml + <ObjectChild key="referenceToMemoryID"> + <armarx::arondto::PackagePath /> + </ObjectChild> +``` + +(At the moment), you need to specify `<CodeIncludes>` to Eigen to use `Pose`, `Position` and `Orientation` (which are translated to `Eigen::Matrix4f`, `Eigen::Vector3f`, and `Eigen::Quaternionf` in C++). In that section, you can add includes in your target language (right now only C++), e.g.: +```xml + <CodeIncludes> + <Include include="<Eigen/Core>" /> + </CodeIncludes> +``` + +If you do not need the `CodeIncludes` and `AronIncludes` you can remove these tags. + +### Examples + +In the following we define a class that uses all more complex types once: +```xml +<!-- MyData containing all accepted members once --> +<?xml version="1.0" encoding="UTF-8" ?> +<AronTypeDefinition> + <CodeIncludes> + <Include include="<Eigen/Core>" /> + <Include include="<Eigen/Geometry>" /> + <Include include="<pcl/point_cloud.h>" /> + <Include include="<pcl/point_types.h>" /> + <Include include="<opencv2/core/core.hpp>" /> + </CodeIncludes> + <GenerateTypes> + <IntEnum name="TheIntEnum"> + <EnumValue key="INT_ENUM_VALUE_0" value="0" /> + <EnumValue key="INT_ENUM_VALUE_1" value="1" /> + <EnumValue key="INT_ENUM_VALUE_2" value="2" /> + <EnumValue key="INT_ENUM_VALUE_3" value="3" /> + <EnumValue key="INT_ENUM_VALUE_4" value="4" /> + <EnumValue key="INT_ENUM_VALUE_5" value="5" /> + <EnumValue key="INT_ENUM_VALUE_6" value="6" /> + <EnumValue key="INT_ENUM_VALUE_7" value="7" /> + <EnumValue key="INT_ENUM_VALUE_8" value="8" /> + </IntEnum> + + <Object name="armarx::mydata::arondto::MyData"> + <objectchild key="the_int_enum"> + <TheIntEnum /> + </objectchild> + + <ObjectChild key="the_dict"> + <Dict> + <Float /> + </Dict> + </ObjectChild> + + <ObjectChild key='the_list'> + <List> + <Float /> + </List> + </ObjectChild> + + <ObjectChild key='the_short_matrix'> + <Matrix rows="5" cols="7" type="int16" /> + </ObjectChild> + + <ObjectChild key='the_double_quaternion'> + <Quaternion type="float64" /> + </ObjectChild> + + <ObjectChild key='the_position'> + <Position /> + </ObjectChild> + + <ObjectChild key='the_orientation'> + <Orientation /> + </ObjectChild> + + <ObjectChild key='the_pose'> + <Pose /> + </ObjectChild> + + <ObjectChild key='the_rgb24_image'> + <Image type="rgb24" /> + </ObjectChild> + + <ObjectChild key='the_xyzrgb_pointcloud'> + <PointCloud type="PointXYZRGB" /> + </ObjectChild> + + </Object> + </GenerateTypes> +</AronTypeDefinition> +``` + +### CMake specification + +In the `CMakeLists.txt`, add or extend after the definition of the target (e.g. through add_library or add_component): + +```cmake +armarx_enable_aron_file_generation_for_target( + TARGET_NAME + ${LIB_NAME} + ARON_FILES + aron/MyData.xml +) +``` + +### Important changes + +- I changed the xml type reader so that embedded classes are not allowed anymore! Before that you were able to define a new class inside an existing one, e.g.: +```xml +<!-- MyData containing a helloWorld member --> +<?xml version="1.0" encoding="UTF-8" ?> +<AronTypeDefinition> + <GenerateTypes> + <Object name="armarx::mydata::arondto::MyData"> + <ObjectChild key="helloWorld"> + <Object name="armarx::mydata::arondto::MyOtherData"> + ... + </Object> + </ObjectChild> + </Object> + </GenerateTypes> +</AronTypeDefinition> +``` +This is not supported anymore! + +## Full example + +Say you have the following Aron XML type description: +```xml +<?xml version="1.0" encoding="UTF-8" ?> +<AronTypeDefinition> + <GenerateTypes> + <IntEnum name="armarx::NaturalIKControlMode"> + <EnumValue key="CONTROL_MODE_0" value="0" /> + <EnumValue key="CONTROL_MODE_1" value="1" /> + <EnumValue key="CONTROL_MODE_2" value="2" /> + </IntEnum> + + <Object name='armarx::NaturalIKResult'> + <ObjectChild key='control_mode'> + <armarx::NaturalIKControlMode /> + </ObjectChild> + + <ObjectChild key='reached'> + <Bool /> + </ObjectChild> + + <ObjectChild key='jointValues'> + <List> + <Float /> + </List> + </ObjectChild> + </Object> + </GenerateTypes> +</AronTypeDefinition> +``` + +The generated c++ file looks like: +```cpp +#pragma once + +#include <memory> +#include <string> +#include <vector> +#include <map> +#include <RobotAPI/interface/aron.h> +#include <RobotAPI/libraries/aron/core/codegenerator/codewriter/cpp/AronCppClass.h> +#include <RobotAPI/libraries/aron/core/data/rw/writer/variant/VariantWriter.h> +#include <RobotAPI/libraries/aron/core/data/rw/reader/variant/VariantReader.h> +#include <RobotAPI/libraries/aron/core/type/rw/writer/variant/VariantWriter.h> +namespace armarx +{ + /** + ****************************************** + * AUTOGENERATED CLASS. Please do NOT edit. + ****************************************** + */ + class NaturalIKControlMode + : public armarx::aron::codegenerator::cpp::AronCppClass + { + public: + /** + * The internal enum definition of the enum of this autogenerated class. + */ + enum class ImplEnum + { + CONTROL_MODE_0, + CONTROL_MODE_1, + CONTROL_MODE_2, + }; // enum class ImplEnum + + public: + using This = armarx::NaturalIKControlMode; + static constexpr ImplEnum CONTROL_MODE_0 = ImplEnum::CONTROL_MODE_0; + static constexpr ImplEnum CONTROL_MODE_1 = ImplEnum::CONTROL_MODE_1; + static constexpr ImplEnum CONTROL_MODE_2 = ImplEnum::CONTROL_MODE_2; + /// Mapping enum values to readable strings + const std::map<ImplEnum, std::string> EnumToStringMap = { + {ImplEnum::CONTROL_MODE_0, "CONTROL_MODE_0"}, + {ImplEnum::CONTROL_MODE_1, "CONTROL_MODE_1"}, + {ImplEnum::CONTROL_MODE_2, "CONTROL_MODE_2"}, + }; + /// Mapping readable strings to enum values + const std::map<std::string, ImplEnum> StringToEnumMap = { + {"CONTROL_MODE_0", ImplEnum::CONTROL_MODE_0}, + {"CONTROL_MODE_1", ImplEnum::CONTROL_MODE_1}, + {"CONTROL_MODE_2", ImplEnum::CONTROL_MODE_2}, + }; + /// Mapping enum values to a int value + const std::map<ImplEnum, int> EnumToValueMap = { + {ImplEnum::CONTROL_MODE_0, 0}, + {ImplEnum::CONTROL_MODE_1, 1}, + {ImplEnum::CONTROL_MODE_2, 2}, + }; + /// Mapping int values to a enum + const std::map<int, ImplEnum> ValueToEnumMap = { + {0, ImplEnum::CONTROL_MODE_0}, + {1, ImplEnum::CONTROL_MODE_1}, + {2, ImplEnum::CONTROL_MODE_2}, + }; + /// The current value of the enum object + ImplEnum value; + + public: + NaturalIKControlMode() + { + resetHard(); + } + NaturalIKControlMode(const armarx::NaturalIKControlMode& i) + : value(i.value) + { + } + NaturalIKControlMode(const ImplEnum e) + : value(e) + { + } + + public: + /** + * @brief operator==() - This method checks whether all values equal another instance. + * @param i - The other instance + * @return - true, if all members are the same, false otherwise + */ + bool operator==(const armarx::NaturalIKControlMode& i) const + { + if (not (value == i.value)) + { + return false; + } + return true; + } + + /** + * @brief resetHard() - This method resets member variables according to the XML type description. + * @return - nothing + */ + virtual void resetHard() override + { + value = {}; + } + + /** + * @brief resetSoft() - This method resets all member variables with respect to the current parameterization. + * @return - nothing + */ + virtual void resetSoft() override + { + value = {}; + } + + /** + * @brief writeType() - This method returns a new type from the class structure using a type writer implementation. This function is static. + * @return - the result of the writer implementation + */ + template<class T> + static T writeType(armarx::aron::type::WriterInterface<T>& aron_w, armarx::aron::type::Maybe aron_maybeType = armarx::aron::type::Maybe::eNone, const armarx::aron::Path& aron_p = armarx::aron::Path()) + { + //TODO: + std::map<std::string, int> aron_str2ValueMap; + return aron_w.writeIntEnum("armarx::NaturalIKControlMode", aron_str2ValueMap, aron_maybeType, aron_p); + } + + /** + * @brief write() - This method returns a new type from the member data types using a data writer implementation. + * @param w - The writer implementation + * @return - the result of the writer implementation + */ + template<class T> + T write(armarx::aron::data::WriterInterface<T>& aron_w, const armarx::aron::Path& aron_p = armarx::aron::Path()) const + { + return aron_w.writePrimitive(EnumToValueMap.at(value), aron_p); // of top level enum armarx::NaturalIKControlMode + } + + /** + * @brief read() - This method sets the struct members to new values given in a data reader implementation. + * @param r - The reader implementation + * @return - nothing + */ + template<class T> + void read(armarx::aron::data::ReaderInterface<T>& aron_r, T& input) + { + using TNonConst = typename std::remove_const<T>::type; + { + const TNonConst* _suppressUnusedWarning; + (void) _suppressUnusedWarning; + } + this->resetSoft(); + if (aron_r.readNull(input)) + { + throw armarx::aron::error::AronException(__PRETTY_FUNCTION__, "The input to the read method must not be null."); + } + int aron_tmpValue; + aron_r.readPrimitive(input, aron_tmpValue); // of top level enum armarx::NaturalIKControlMode + value = ValueToEnumMap.at(aron_tmpValue); + } + + /** + * @brief toString() - Converts the internally stored value to string + * @return - the name of the enum + */ + std::string toString() const + { + return EnumToStringMap.at(value); + } + + /** + * @brief fromString() - sets the internally stored value to the corrsponding enum of the input str + * @return - nothing + */ + void fromString(const std::string& str) + { + if (auto it = StringToEnumMap.find(str); it == StringToEnumMap.end()) + { + throw armarx::LocalException("The input name is not valid. Could net set the enum to value '" + str + "'"); + } + else + { + value = it->second; + } + } + + /** + * @brief int() - Converts the internally stored value to int representation + * @return - the int representation + */ + operator int() const + { + return EnumToValueMap.at(value); + } + + /** + * @brief operator=() - Assignment operator for the internally defined enum + * @return - nothing + */ + armarx::NaturalIKControlMode& operator=(ImplEnum v) + { + value = v; + return *this; + } + + /** + * @brief operator=() - Assignment operator for copy + * @return - nothing + */ + armarx::NaturalIKControlMode& operator=(const armarx::NaturalIKControlMode& c) + { + value = c.value; + return *this; + } + + /** + * @brief operator=() - Assignment operator for the internally defined enum + * @return - nothing + */ + armarx::NaturalIKControlMode& operator=(int v) + { + if (auto it = ValueToEnumMap.find(v); it == ValueToEnumMap.end()) + { + throw armarx::LocalException("The input int is not valid. Could net set the enum to value '" + std::to_string(v) + "'"); + } + else + { + value = it->second; + } + return *this; + } + + }; // class NaturalIKControlMode +} // namespace armarx + +namespace armarx +{ + /** + ****************************************** + * AUTOGENERATED CLASS. Please do NOT edit. + ****************************************** + */ + class NaturalIKResult + : public armarx::aron::codegenerator::cpp::AronCppClass + { + public: + using This = armarx::NaturalIKResult; + armarx::NaturalIKControlMode control_mode; + std::vector<float> jointValues; + bool reached; + + public: + NaturalIKResult() + { + resetHard(); + } + + public: + /** + * @brief operator==() - This method checks whether all values equal another instance. + * @param i - The other instance + * @return - true, if all members are the same, false otherwise + */ + bool operator==(const armarx::NaturalIKResult& i) const + { + if (not (control_mode == i.control_mode)) + { + return false; + } + if (not (jointValues == i.jointValues)) + { + return false; + } + if (not (reached == i.reached)) + { + return false; + } + return true; + } + + /** + * @brief resetHard() - This method resets member variables according to the XML type description. + * @return - nothing + */ + virtual void resetHard() override + { + control_mode.resetHard(); + jointValues = std::vector<float>(); + reached = bool(); + } + + /** + * @brief resetSoft() - This method resets all member variables with respect to the current parameterization. + * @return - nothing + */ + virtual void resetSoft() override + { + control_mode.resetSoft(); + jointValues.clear(); + reached = bool(); + } + + /** + * @brief writeType() - This method returns a new type from the class structure using a type writer implementation. This function is static. + * @return - the result of the writer implementation + */ + template<class T> + static T writeType(armarx::aron::type::WriterInterface<T>& aron_w, armarx::aron::type::Maybe aron_maybeType = armarx::aron::type::Maybe::eNone, const armarx::aron::Path& aron_p = armarx::aron::Path()) + { + std::map<std::string, T> aron_objectMembers; + auto aron_objectExtends = std::nullopt; + // members of armarx::NaturalIKResult + auto aron_variant_control_mode = armarx::NaturalIKControlMode::writeType(aron_w, armarx::aron::type::Maybe::eNone, armarx::aron::Path(aron_p, {"control_mode"})); // of control_mode + aron_objectMembers.emplace("control_mode", aron_variant_control_mode); + auto aron_variant_jointValues_dot_accepted_type = aron_w.writeFloat(armarx::aron::type::Maybe::eNone, armarx::aron::Path(aron_p, {"jointValues", "::accepted_type"})); // of float + auto aron_variant_jointValues = aron_w.writeList(aron_variant_jointValues_dot_accepted_type, armarx::aron::type::Maybe::eNone, armarx::aron::Path(aron_p, {"jointValues"})); // of jointValues + aron_objectMembers.emplace("jointValues", aron_variant_jointValues); + auto aron_variant_reached = aron_w.writeBool(armarx::aron::type::Maybe::eNone, armarx::aron::Path(aron_p, {"reached"})); // of bool + aron_objectMembers.emplace("reached", aron_variant_reached); + return aron_w.writeObject("armarx::NaturalIKResult", aron_objectMembers, aron_objectExtends, aron_maybeType, aron_p); // of top level object armarx::NaturalIKResult + } + + /** + * @brief write() - This method returns a new type from the member data types using a data writer implementation. + * @param w - The writer implementation + * @return - the result of the writer implementation + */ + template<class T> + T write(armarx::aron::data::WriterInterface<T>& aron_w, const armarx::aron::Path& aron_p = armarx::aron::Path()) const + { + std::map<std::string, T> aron_objectMembers; + std::optional<T> aron_objectExtends; + // members of armarx::NaturalIKResult + auto aron_variant_control_mode = aron_w.writeNull(); + aron_variant_control_mode = control_mode.write(aron_w, armarx::aron::Path(aron_p, {"control_mode"})); // of control_mode + aron_objectMembers.emplace("control_mode", aron_variant_control_mode); + auto aron_variant_jointValues = aron_w.writeNull(); + std::vector<T> aron_variant_jointValues_listElements; + for(unsigned int aron_jointValues_it = 0; aron_jointValues_it < jointValues.size(); ++aron_jointValues_it) + { + auto aron_variant_jointValues_dot_at_lbrR_aron_jointValues_it_rbrR_ = aron_w.writeNull(); + aron_variant_jointValues_dot_at_lbrR_aron_jointValues_it_rbrR_ = aron_w.writePrimitive(jointValues.at(aron_jointValues_it), armarx::aron::Path(aron_p, {"jointValues", std::to_string(aron_jointValues_it)})); // of jointValues.at(aron_jointValues_it) + aron_variant_jointValues_listElements.push_back(aron_variant_jointValues_dot_at_lbrR_aron_jointValues_it_rbrR_); + } + aron_variant_jointValues = aron_w.writeList(aron_variant_jointValues_listElements, armarx::aron::Path(aron_p, {"jointValues"})); // of jointValues + aron_objectMembers.emplace("jointValues", aron_variant_jointValues); + auto aron_variant_reached = aron_w.writeNull(); + aron_variant_reached = aron_w.writePrimitive(reached, armarx::aron::Path(aron_p, {"reached"})); // of reached + aron_objectMembers.emplace("reached", aron_variant_reached); + return aron_w.writeDict(aron_objectMembers, aron_objectExtends, aron_p); // of top level object armarx::NaturalIKResult + } + + /** + * @brief read() - This method sets the struct members to new values given in a data reader implementation. + * @param r - The reader implementation + * @return - nothing + */ + template<class T> + void read(armarx::aron::data::ReaderInterface<T>& aron_r, T& input) + { + using TNonConst = typename std::remove_const<T>::type; + { + const TNonConst* _suppressUnusedWarning; + (void) _suppressUnusedWarning; + } + this->resetSoft(); + if (aron_r.readNull(input)) + { + throw armarx::aron::error::AronException(__PRETTY_FUNCTION__, "The input to the read method must not be null."); + } + std::map<std::string, TNonConst> aron_objectMembers; + aron_r.readDict(input, aron_objectMembers); // of top level object armarx::NaturalIKResult + control_mode.read<T>(aron_r, aron_objectMembers.at("control_mode")); + std::vector<TNonConst> aron_jointValues_listElements; + aron_r.readList(aron_objectMembers.at("jointValues"), aron_jointValues_listElements); + for (const auto& aron_jointValues_listValue : aron_jointValues_listElements) + { + float aron_jointValues_listTmp; + aron_r.readPrimitive(aron_jointValues_listValue, aron_jointValues_listTmp); // of aron_jointValues_listTmp + jointValues.push_back(aron_jointValues_listTmp); + } + aron_r.readPrimitive(aron_objectMembers.at("reached"), reached); // of reached + } + + /** + * @brief toAron() - This method returns a new data from the member data types using a writer implementation. + * @return - the result of the writer implementation + */ + armarx::aron::data::DictPtr toAron() const + { + armarx::aron::data::writer::VariantWriter writer; + return armarx::aron::data::Dict::DynamicCastAndCheck(this->write(writer)); + } + + /** + * @brief FromAron() - This method sets the struct members to new values given in a reader implementation. + * @return - nothing + */ + static This FromAron(const armarx::aron::data::DictPtr& input) + { + This t; + t.fromAron(input); + return t; + } + + /** + * @brief fromAron - This method sets the struct members to new values given in a reader implementation. + * @return - nothing + */ + void fromAron(const armarx::aron::data::DictPtr& input) + { + armarx::aron::data::reader::VariantReader reader; + this->read<armarx::aron::data::reader::VariantReader::InputType>(reader, (input)); + } + + /** + * @brief toAronType() - This method returns a new type from the member data types using a writer implementation. + * @return - the result of the writer implementation + */ + static armarx::aron::type::ObjectPtr toAronType() + { + armarx::aron::type::writer::VariantWriter writer; + return armarx::aron::type::Object::DynamicCastAndCheck(writeType(writer)); + } + + }; // class NaturalIKResult +} // namespace armarx + +``` + +As you see, the code generation creates a class for the `NaturalIKControlMode` enum. This special class provides convenience methods compared to normal c++ enums. +Further, it creates a class for the `NaturalIKResult` object. + +Both, the enum and the object provide methods for reading and writing. The `read` method is used to parse a Aron object in an arbitrary representation (e.g. Aron variant or nlohmann::json) and to set the c++ members to the same values as the Aron object. To do so it uses a ReaderInterface implementation (See [Converter](Aron/Converter)). The `write` method is used to create an Aron object in an arbitrary representation with the same values as the c++ object. This method uses a WriterInterface implementation. + +For convenience, the `toAron()` and `fromAron()` methods, which internally use the `read` and `write` methods, are created. To get the structure of the c++ class as an Aron type object you can use the static `toAronType()` method which internally uses the `writeType` method. + +Futher, the code generation creates methods to compare two classes with each other (right now only operator==). + +This means, when using Aron, you don't need to mess around with the Aron DTOs and Aron objects, you only have to set and use plain c++ members of a generated class! + + + + +# (Optional) Add conversions to existing (potentially more intelligent) C++ types + +Consider the case of `simox::OrientedBoxf` and `simox::arondto::OrientedBox`. The former is the business object (BO), used in daily business logic code (as it offers useful methods to construct and manipulate it). The latter is a mere data storage used to transfer the data, which is called a data transfer object (DTO). + +Therefore, you usually want to convert a `simox::arondto::OrientedBox` to a `simox::OrientedBoxf` as soon as you want to do things other than passing it around over network (e.g., at the beginning of a component method or after reading it from the working memory). Likewise, you want to convert a `simox::OrientedBoxf` to a `simox::arondto::OrientedBox` when you send the information over network or store it in the memory. + +To allow this conversion, follow these steps: + +- In your library, add a file pair `aron_conversions.{h, cpp}` next to your `aron/` directory and add them to the `CMakeLists.txt` +- In the header, declare functions following this form: + +```cpp +#pragma once + +#include <SimoxUtility/shapes/OrientedBox.h> +#include <RobotAPI/libraries/aron/common/aron/OrientedBox.aron.generated.h> + + +namespace simox +{ + void fromAron(const arondto::OrientedBox& dto, OrientedBoxf& bo); + void toAron(arondto::OrientedBox& dto, const OrientedBoxf& bo); +} +``` + +Note: + +- Both functions take the DTO first and the BO second. +- `fromAron()` takes a `const` DTO and a `non-const` BO. +- `toAron()` takes a `non-const` DTO and a `const` BO. +- All arguments are passed as reference (especially the `non-const` arguments). +- The functions are defined in the BO's namespace (`simox` in this example, `armarx::mydata` in the running example). + + +* In the cpp file, define the functions like this: + +```cpp +#include "aron_conversions.h" + +// Include this and use armarx::aron::to/fromAron() for std::vector, std::map. +#include <RobotAPI/libraries/aron/common/aron_conversions.h> + +// Include other aron_conversions.h files for other ARON types + + +void simox::fromAron(const arondto::OrientedBox& dto, OrientedBoxf& bo) +{ + bo = OrientedBoxf(dto.center, dto.orientation, dto.extents); +} + +void simox::toAron(arondto::OrientedBox& dto, const OrientedBoxf& bo) +{ + dto.center = bo.center(); + dto.orientation = bo.rotation(); + dto.extents = bo.dimensions(); +} +``` + +Note: + +- The implementation depends on your data. It might be as simple as copying all members, or require more complex conversions. Especially, you might use `fromAron()` for `toAron()` for other ARON object types. + +# Lessons learned +- How to create a XML file with a valid Aron specification +- How to add this file to CMake +- How to use the generated class and how to convert it to an Aron object (e.g. for sending it to the memory) \ No newline at end of file diff --git a/docs/aron/conversion/README.md b/docs/aron/conversion/README.md new file mode 100644 index 0000000000000000000000000000000000000000..a2233c26e99620a5331c2a1ea2448a7c2189656d --- /dev/null +++ b/docs/aron/conversion/README.md @@ -0,0 +1,35 @@ +# Aron conversion + +Aron offers ways to simply convert any aron object into another representation (e.g. from variant to nlohmann::json or vice versa). To do so, it makes use of specific readers and writers. In the following we will only describe the readers, writers and converters for Aron data, not for types (but the principle is the same). + +## Readers + +An Aron reader is used to get information of an Aron object in a specific representation. Assume you have an nlohmann::json aron object which contains some information (E.g. it is a dict, containing some members, ...). We need this information to create another object in another representation with the same content. + +To do so, you only have to implement the armarx::aron::data::ReaderInterface class. It needs one template parameter for your InputType (e.g. here const nlohmann::json). + +The interface provides the following pure virtual methods: +```cpp + virtual void readList(InputType& input, std::vector<InputTypeNonConst>& elements) = 0; + virtual void readDict(InputType& input, std::map<std::string, InputTypeNonConst>& elements) = 0; + virtual void readNDArray(InputType& input, std::vector<int>& shape, std::string& typeAsString, std::vector<unsigned char>& data) = 0; + virtual void readInt(InputType& input, int& i) = 0; + virtual void readLong(InputType& input, long& i) = 0; + virtual void readFloat(InputType& input, float& i) = 0; + virtual void readDouble(InputType& input, double& i) = 0; + virtual void readString(InputType& input, std::string& s) = 0; + virtual void readBool(InputType& input, bool& i) = 0; +``` +You have to implement the function so that the non-const arguments of the method will be filled with the values of the input. E.g. the implementation of the readString method for the nlohmann::json reader would be: +```cpp + void NlohmannJSONReader::readString(const nlohmann::json& input, std::string& i) + { + if (input[rw::json::constantes::TYPE_SLUG] != expectedType) + { + throw error::ValueNotValidException(__PRETTY_FUNCTION__, "Wrong type in json encountered.", input[rw::json::constantes::TYPE_SLUG], expectedType); + } + i = input[rw::json::constantes::VALUE_SLUG]; + } +``` + +Of course, the way to get the member depend on the way how to construct (writer) the nlohmann::json. \ No newline at end of file diff --git a/docs/aron/introduction/README.md b/docs/aron/introduction/README.md new file mode 100644 index 0000000000000000000000000000000000000000..1a9c9987d50c3784a87807595353b68362419293 --- /dev/null +++ b/docs/aron/introduction/README.md @@ -0,0 +1,213 @@ +[[_TOC_]] + +# Aron structure + +Aron (ArmarX Object Notation) is the ArmarX implementation of variants which can be transferred over the network via ZeroC Ice. Further, Aron is the data representation used in the ArmarX Memory System [ArMem](ArMem/ArMem). We distinguish between: + +- type specification vs. data information +- data transfer object (in the following called Aron DTO) vs. its corresponding c++ wrapper (in the following called Aron object). The DTO specification is done in ice so that every Aron object can be transferred via ice. + +## Aron Type specification + +An Aron type specification defines the static type for an Aron data DTO or an Aron data object. It does not contain any data (e.g. an aron type list only knows the accepted type, not the list members). Since Aron supports maybe types (raw ptr, smart ptr, optional), every Aron type DTO contains a special member. It can only consist of the following types and information (AronVariant means any Type): + +```cpp + Object { // dto called armarx::aron::type::dto::AronObject + string name; + AronVariant extends; + map<string, AronVariant> memberTypes; + } + Dict { // dto called armarx::aron::type::dto::Dict + AronVariant acceptedType; + } + List { // dto called armarx::aron::type::dto::List + AronVariant acceptedType; + } + Pair { // ... + AronVariant acceptedType1; + AronVariant acceptedType2; + } + Tuple { + vector<AronVariant> acceptedTypes; + } + IntEnum { + string name; + map<string, int> acceptedValues; + } + NDArray { + int ndim; + type type; // in [uint8, int8, uint16, int16, uint32, int32, float32, float64] + } + Matrix { + int rows, cols; + type type; // in [int16, int32, int64, float32, float64] + } + Quaternion { + type type; // in [float32, float64] + } + Position { + } + Orientation { + } + Pose { + } + Image { + pixelType type; // in [rgb24, depth32] + } + PointCloud { + voxelType type; // in [PointXYZ, PointXYZI, PointXYZL, PointXYZRGB, PointXYZRGBA, PointXYZRGBL, PointXYZHSV] + } + Int { // dto called armarx::aron::type::dto::AronInt + } + Long { // dto called armarx::aron::type::dto::AronLong + } + Float { // dto called armarx::aron::type::dto::AronFloat + } + Double { // dto called armarx::aron::type::dto::AronDouble + } + String { // dto called armarx::aron::type::dto::AronString + } + Bool { // dto called armarx::aron::type::dto::AronBool + } + Time { // dto called armarx::aron::type::dto::AronTime + } +``` + +## Aron Data specification + +Aron data objects and Aron data DTOs are similar structured to type objects and type DTOs. However, there are less classes for data objects and data DTOs. Aron data is completely decoupled from the static types and contains the data members (e.g. an aron data list only contains the list members (as AronVariants) and not the accepted type): + +```cpp + Dict { // dto called armarx::aron::data::dto::Dict + map<string, AronVariant> members; + } + List { // dto called armarx::aron::data::dto::List + vector<AronVariant> elements; + } + NDArray { // ... + vector<int> shape; + string type; + vector<byte> data; + } + Int { // dto called armarx::aron::data::dto::AronInt + int value; + } + Long { // dto called armarx::aron::data::dto::AronLong + long value; + } + Float { // dto called armarx::aron::data::dto::AronFloat + float value; + } + Double { // dto called armarx::aron::data::dto::AronDouble + double value; + } + String { // dto called armarx::aron::data::dto::AronString + string value; + } + Bool { // dto called armarx::aron::data::dto::AronBool + bool value; + } +``` + +Please note that every Aron data object or DTO can be NULL!. The reason is, that if the type supports maybe types and a member is e.g. optional the data must support maybetype as well. If a generated Aron class (We come to the code generation later) has an optional member, this member will be translated into a NULL Aron object and DTO. + +## Connection of Aron data and Aron type + +Aron data contains less classes than Aron type. Because Aron data objects and DTOs do not check the type of the members (they can be any aron data (AronVariant)), we can only validate an aron data object or DTO if we have the type information. The following mapping describes, how data and types correspond. +```cpp + Aron Type | Aron Data + ------------------------------- + Object -> Dict + Dict -> Dict + List -> List + Pair -> List + Tuple -> List + NDArray -> NDArray + Matrix -> NDArray + Quaternion -> NDArray + Position -> NDArray + Orientation -> NDArray + Pose -> NDArray + Image -> NDArray + PointCloud -> NDArray + IntEnum -> Int + Int -> Int + Long -> Long + Float -> Float + Double -> Double + String -> String + Bool -> Bool + Time -> Long +``` + +If no type object or DTO is available, we can at least derive some information from the data object (e.g. "it is a data dict, so the type cant be list"). + +To differ between data and type makes it easier to work with these Variants. In most cases, the type information is not relevant. Then you only have to check for the data type. + +# Aron data and type objects + +As already mentioned, we implemented wrapper classes around the DTO. These classes offer convenience methods and conversions and make lots things easier when working directly with Aron. These classes can be found at aron/core/[data,type]/variant/Variant.h. + +The Aron objects have more or less the same structure as the DTOs (see above). Everything is stored as a shared_ptr (e.g. members, elements, acceptedTypes, ...). If you want to implement a method which takes any Aron data object as input, you can use the base class of every Aron data object: +```cpp + void myFancyMethod(const armarx::aron::data::VariantPtr& variant); +``` + +If you want to check, what a variant really is, you can use the descriptor of the object: +```cpp + armarx::aron::data::VariantPtr variant; // <-- the variant + auto desc = variant->getDescriptor(); + switch(desc) + { + case armarx::aron::data::Descriptor::eDict: ... + case armarx::aron::data::Descriptor::eList: ... + ... + } +``` + +If you have a DTO, you dont know the exact type but you want to have a Aron object you can make use of the static construction methods: +```cpp + armarx::aron::data::dto::GenericData dto; // <-- the DTO variant + auto aron = armarx::aron::data::Variant::FromAronDTO(dto); +``` + +If you know the type, you can use the constructor the specific Aron object. + +## Example to create an Aron data dict from scratch + +Goal: Have an Aron dict with a list as member "the_list" and some values in it. Then echo the members and their descriptor as a string. + +```cpp + using namespace armarx; + + // setup aron object + auto dict = std::make_shared<aron::data::Dict>(); + { + auto list = std::make_shared<aron::data::List>(); + for (unsigned int i = 0; i < 10; ++i) + { + list->addElement(std::make_shared<aron::data::Int>(i)); + } + dict->addElement("the_list", list); + } + + // echo + auto listVariant = dict->getElement("the_list"); // will return a aron::data::VariantPtr + auto list = aron::data::List::DynamicCastAndCheck(listVariant); // cast and check whether the cast was successful + for (const auto& intVar : list->getElements()) + { + auto i = aron::data::Int::DynamicCastAndCheck(intVar); + std::cout << "The value is: " << i->getValue() << std::endl; + std::cout << "The descriptor is: " << aron::data::defaultconversion::string::Descriptor2String.at(i->getDescriptor()) << std::endl; + } +``` + +Please note that we might add more methods or make the current ones more flexible (e.g. such as nlohmann::json). + +# Lessons learned + +- There is a difference between Aron data and Aron type +- There is a difference between Aron objects and Aron DTOs +- How are Aron DTOs structured +- How do Aron data and Aron types correspond +- How to use the Aron objects \ No newline at end of file diff --git a/docs/aron/visitors/README.md b/docs/aron/visitors/README.md new file mode 100644 index 0000000000000000000000000000000000000000..c72e3a92e31b44b4bccbe2cfcd73be2aecb0c1b4 --- /dev/null +++ b/docs/aron/visitors/README.md @@ -0,0 +1,101 @@ +[[_TOC_]] + +# Visitors + +Visitors are a useful tool to define specific methods for specific types without specifying the `switch(): case: ...` again and again. Further, recursive visitors offer a convenient way to iterate through the tree-like structure of any Aron object. (Please note that right now the implementation does not check for cycles!). Again, we will only look at data visitors since the implementation of type visitors is more or less similar. + +## Non-recursive Visitors + +First, there are "normal" visitors. They are used to get rid of the big switch-case statement when getting an Aron object with unknown type. Further, these visitors can be used to convert an Aron object from one representation into another (see [Aron/Conversion](Aron/Conversion)). +The Visitor Base-class offers the following pure virtual methods which you have to implement: +```cpp + virtual data::Descriptor getDescriptor(Input&) = 0; + virtual void visitDict(Input&) {}; + virtual void visitList(Input&) {}; + virtual void visitNDArray(Input&) {}; + virtual void visitInt(Input&) {}; + virtual void visitLong(Input&) {}; + virtual void visitFloat(Input&) {}; + virtual void visitDouble(Input&) {}; + virtual void visitBool(Input&) {}; + virtual void visitString(Input&) {}; + virtual void visitUnknown(Input&) { throw error::AronException(__PRETTY_FUNCTION__, "Unknown type in visitor."); } +``` +`Input` is a template parameter, defining the Input-type (e.g. `const armarx::aron::data::VariantPtr` for a `VariantVisitor` Implementation). + +The method `getDescriptor(Input&)` is used for the switch case interally. + +As you can see the `VariantVisitor` always gets a generic variant as input in each function. This means that, although the Visitor guarantees that the input is correct, you have to cast the class to the correct type. For widely used Visitors, the Aron library offers convenience implementations (e.g. for Variants and for nlohmann::json inputs). The convenience class for Variants additionally adds overloads where the input is already casted correctly (you can decide which method you want to override). + +To use a Visitor, you have to use the function +```cpp + void visit(VisitorImplementation& v, typename VisitorImplementation::Input& o); +``` +which takes the visitor and the input as arguments and does the switch-case. + +## Recursive Vistors + +Recursive visitors are similar to normal vistors but they continue "visiting" until the object is fully visited. For containers (e.g. dicts, lists) they offer two methods each: +```cpp + virtual void visitDictOnEnter(Input& element) {}; + virtual void visitDictOnExit(Input& element) {}; + virtual void visitListOnEnter(Input& element) {}; + virtual void visitListOnExit(Input& element) {}; +``` +The `*OnEnter` method is called before iterating over all children of the container. The `*OnExit` is called after the iteration. + +Further, in order to get the elements of a container, you must implement the methods: +```cpp + virtual MapElements getDictElements(Input&) = 0; + virtual ListElements getListElements(Input&) = 0; +``` +Again, Input can be any aron object (e.g. Variant or nlohmann::json). + +As for normal visitors, the Aron library offers convenience implementations for Variants and nlohmann::json inputs. + +To use the RecursiveVisitor, you have to use the function +```cpp + void visitRecursive(RecursiveVisitorImplementation& v, typename RecursiveVisitorImplementation::Input& o); +``` + +### Example + +Assume you want to count how many objects of each kind you have in a Variant. +```cpp + #include <RobotAPI/libraries/aron/core/data/visitor/variant/VariantVisitor.h> + class CountingRecursiveVisitor : public RecursiveConstVariantVisitor + { + public: + int dicts = 0; + int lists = 0; + int ndarrays = 0; + int ints = 0; + int floats = 0; + int longs = 0; + int doubles = 0; + int strings = 0; + int bools = 0; + public: + void visitAronVariantOnEnter(const data::DictPtr&) override { dicts++; } + void visitAronVariantOnEnter(const data::ListPtr&) override { lists++; } + void visitAronVariant(const data::NDArrayPtr&) override { ndarrays++; } + void visitAronVariant(const data::IntPtr&) override { ints++; } + void visitAronVariant(const data::LongPtr&) override { longs++; } + void visitAronVariant(const data::FloatPtr&) override { floats++; } + void visitAronVariant(const data::DoublePtr&) override { doubles++; } + void visitAronVariant(const data::BoolPtr&) override { strings++; } + void visitAronVariant(const data::StringPtr&) override { bools++; } + }; + + void countHowMany(const aron::data::VariantPtr& aron) + { + CountingRecursiveVisitor visitor; + aron::data::visitRecursive(visitor, aron); + + std::cout << "The aron has " << visitor.dicts << " dicts." << std::endl; + } +``` + +## Typed Visitors + +# Lessons Learned \ No newline at end of file diff --git a/etc/doxygen/pages/HowTos.dox b/etc/doxygen/pages/HowTos.dox index aed242e5dd4a966612bb69f31a30d8efc73e292d..73d1f6aa03ce74996e4fb74e9476b829dffb5f12 100644 --- a/etc/doxygen/pages/HowTos.dox +++ b/etc/doxygen/pages/HowTos.dox @@ -85,7 +85,7 @@ With the corresponding configuration in ./config/Armar3Config.cfg: \section RobotAPI-HowTos-RobotViewer How to inspect the robot's structure -Robots are usually defined in the Simox XML (https://gitlab.com/Simox/simox/wikis/FileFormat) or in the URDF format. To inspect the kinematic structure, visualizations and physical properties, you can use the <i>RobotViewer</i> tool which is part of the Simox library. In particlular you can visualize all coordinate frames that are present in the robot defintion. +Robots are usually defined in the Simox XML (https://git.h2t.iar.kit.edu/sw/simox/simox/-/wikis/FileFormat) or in the URDF format. To inspect the kinematic structure, visualizations and physical properties, you can use the <i>RobotViewer</i> tool which is part of the Simox library. In particlular you can visualize all coordinate frames that are present in the robot defintion. Start it with the following command: \code RobotViewer --robot path/to/robot.xml @@ -96,7 +96,7 @@ Start it with the following command: \section RobotAPI-HowTos-RemoteRobot-Access How to access a RobotStateComponent The RobotStateComponent provides several methods for accessing the current configuration of the robot and for getting a snapshot of the current state which is compatible with -models of the Simox/VirtualRobot framework. With these models the whole functionality of Simox (https://gitlab.com/Simox/simox) can be used, e.g. IK solving, collision detection or motion and grasp planning. +models of the Simox/VirtualRobot framework. With these models the whole functionality of Simox (https://git.h2t.iar.kit.edu/sw/simox/simox) can be used, e.g. IK solving, collision detection or motion and grasp planning. See also \ref RobotAPI-RemoteRobot-Overview. \par Creating a synchronized model (RemoteRobot) diff --git a/etc/doxygen/pages/Tutorials.dox b/etc/doxygen/pages/Tutorials.dox index ca71a9b1d96933319cdbda29d65d4d0e6b1d5e78..ff5d3d89165100062c7016e19466717f3decd6be 100644 --- a/etc/doxygen/pages/Tutorials.dox +++ b/etc/doxygen/pages/Tutorials.dox @@ -8,6 +8,6 @@ Tutorials related to RobotAPI: \li \ref Component-ArVizExample (Example component for how to use ArViz) -\li <a href="https://gitlab.com/ArmarX/meta/Academy/-/tree/master/tutorials/100_beginner/301_memory_server_and_client_tutorial_cpp">Memory Server and Client Tutorial</a> +\li <a href="https://git.h2t.iar.kit.edu/sw/armarx/meta/academy/-/tree/master/tutorials/100_beginner/301_memory_server_and_client_tutorial_cpp">Memory Server and Client Tutorial</a> */ diff --git a/etc/doxygen/pages/armarpose.dox b/etc/doxygen/pages/armarpose.dox index 4dcacff7b984c98f7b2070a6db9dbcbc260309a4..66d53a3a8b52b3c67aac0dba6150573969e18b4f 100644 --- a/etc/doxygen/pages/armarpose.dox +++ b/etc/doxygen/pages/armarpose.dox @@ -23,7 +23,8 @@ Use this variable if you specify global poses and an empty Agent-string. Empty f \section FramedPose-FramedPositionCreation Creation of new FramedPositions To create a new FramedPosition (FramedOrientation, FramedVector and FramedPose work analogously) one needs to know the position, the coordinate frame name and the agent name. -The coordinate frame is usually the name of the RobotNode, e.g. the tcp of the robot. All nodes of a robot can be inspected with the <a href="https://gitlab.com/Simox/simox/wikis/Examples">Simox tool *RobotViewer*</a>. +The coordinate frame is usually the name of the RobotNode, e.g. the tcp of the robot. +All nodes of a robot can be inspected with the <a href="https://git.h2t.iar.kit.edu/sw/simox/simox/-/wikis/Examples">Simox tool *RobotViewer*</a>. The agent name can be retrieved via the \ref armarx::RobotStateComponent like this: \code diff --git a/scenarios/ArVizExample/config/ArVizInteractExample.cfg b/scenarios/ArVizExample/config/ArVizInteractExample.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0892ab764555b0fba8759653513371035dc9b45d --- /dev/null +++ b/scenarios/ArVizExample/config/ArVizInteractExample.cfg @@ -0,0 +1,204 @@ +# ================================================================== +# ArVizInteractExample properties +# ================================================================== + +# ArmarX.AdditionalPackages: List of additional ArmarX packages which should be in the list of default packages. If you have custom packages, which should be found by the gui or other apps, specify them here. Comma separated List. +# Attributes: +# - Default: Default value not mapped. +# - Case sensitivity: yes +# - Required: no +# ArmarX.AdditionalPackages = Default value not mapped. + + +# ArmarX.ApplicationName: Application name +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.ApplicationName = "" + + +# ArmarX.ArVizInteractExample.ArVizStorageName: Name of the ArViz storage +# Attributes: +# - Default: ArVizStorage +# - Case sensitivity: yes +# - Required: no +# ArmarX.ArVizInteractExample.ArVizStorageName = ArVizStorage + + +# ArmarX.ArVizInteractExample.ArVizTopicName: Name of the ArViz topic +# Attributes: +# - Default: ArVizTopic +# - Case sensitivity: yes +# - Required: no +# ArmarX.ArVizInteractExample.ArVizTopicName = ArVizTopic + + +# ArmarX.ArVizInteractExample.EnableProfiling: enable profiler which is used for logging performance events +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ArVizInteractExample.EnableProfiling = false + + +# ArmarX.ArVizInteractExample.MinimumLoggingLevel: Local logging level only for this component +# Attributes: +# - Default: Undefined +# - Case sensitivity: yes +# - Required: no +# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning} +# ArmarX.ArVizInteractExample.MinimumLoggingLevel = Undefined + + +# ArmarX.ArVizInteractExample.ObjectName: Name of IceGrid well-known object +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.ArVizInteractExample.ObjectName = "" + + +# ArmarX.CachePath: Path for cache files. If relative path AND env. variable ARMARX_CONFIG_DIR is set, the cache path will be made relative to ARMARX_CONFIG_DIR. Otherwise if relative it will be relative to the default ArmarX config dir (${ARMARX_WORKSPACE}/armarx_config) +# Attributes: +# - Default: mongo/.cache +# - Case sensitivity: yes +# - Required: no +# ArmarX.CachePath = mongo/.cache + + +# ArmarX.Config: Comma-separated list of configuration files +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.Config = "" + + +# ArmarX.DataPath: Semicolon-separated search list for data files +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.DataPath = "" + + +# ArmarX.DefaultPackages: List of ArmarX packages which are accessible by default. Comma separated List. If you want to add your own packages and use all default ArmarX packages, use the property 'AdditionalPackages'. +# Attributes: +# - Default: Default value not mapped. +# - Case sensitivity: yes +# - Required: no +# ArmarX.DefaultPackages = Default value not mapped. + + +# ArmarX.DependenciesConfig: Path to the (usually generated) config file containing all data paths of all dependent projects. This property usually does not need to be edited. +# Attributes: +# - Default: ./config/dependencies.cfg +# - Case sensitivity: yes +# - Required: no +# ArmarX.DependenciesConfig = ./config/dependencies.cfg + + +# ArmarX.DisableLogging: Turn logging off in whole application +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.DisableLogging = false + + +# ArmarX.EnableProfiling: Enable profiling of CPU load produced by this application +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.EnableProfiling = false + + +# ArmarX.LoadLibraries: Libraries to load at start up of the application. Must be enabled by the Application with enableLibLoading(). Format: PackageName:LibraryName;... or /absolute/path/to/library;... +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.LoadLibraries = "" + + +# ArmarX.LoggingGroup: The logging group is transmitted with every ArmarX log message over Ice in order to group the message in the GUI. +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.LoggingGroup = "" + + +# ArmarX.RedirectStdout: Redirect std::cout and std::cerr to ArmarXLog +# Attributes: +# - Default: true +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.RedirectStdout = true + + +# ArmarX.RemoteHandlesDeletionTimeout: The timeout (in ms) before a remote handle deletes the managed object after the use count reached 0. This time can be used by a client to increment the count again (may be required when transmitting remote handles) +# Attributes: +# - Default: 3000 +# - Case sensitivity: yes +# - Required: no +# ArmarX.RemoteHandlesDeletionTimeout = 3000 + + +# ArmarX.SecondsStartupDelay: The startup will be delayed by this number of seconds (useful for debugging) +# Attributes: +# - Default: 0 +# - Case sensitivity: yes +# - Required: no +# ArmarX.SecondsStartupDelay = 0 + + +# ArmarX.StartDebuggerOnCrash: If this application crashes (segmentation fault) qtcreator will attach to this process and start the debugger. +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.StartDebuggerOnCrash = false + + +# ArmarX.ThreadPoolSize: Size of the ArmarX ThreadPool that is always running. +# Attributes: +# - Default: 1 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ThreadPoolSize = 1 + + +# ArmarX.TopicSuffix: Suffix appended to all topic names for outgoing topics. This is mainly used to direct all topics to another name for TopicReplaying purposes. +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.TopicSuffix = "" + + +# ArmarX.UseTimeServer: Enable using a global Timeserver (e.g. from ArmarXSimulator) +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.UseTimeServer = false + + +# ArmarX.Verbosity: Global logging level for whole application +# Attributes: +# - Default: Info +# - Case sensitivity: yes +# - Required: no +# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning} +# ArmarX.Verbosity = Info + + diff --git a/scenarios/AronComponentConfigExample/AronComponentConfigExample.scx b/scenarios/AronComponentConfigExample/AronComponentConfigExample.scx new file mode 100644 index 0000000000000000000000000000000000000000..250a99e0a034d4addcef5a6039bf3b4f61e9bd24 --- /dev/null +++ b/scenarios/AronComponentConfigExample/AronComponentConfigExample.scx @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<scenario name="AronComponentConfigExample" creation="2022-11-02.11:11:59 AM" globalConfigName="./config/global.cfg" package="RobotAPI" deploymentType="local" nodeName="NodeMain"> + <application name="AronComponentConfigExample" instance="" package="RobotAPI" nodeName="" enabled="true" iceAutoRestart="false"/> + <application name="RemoteGuiProviderApp" instance="" package="ArmarXGui" nodeName="" enabled="true" iceAutoRestart="false"/> +</scenario> + diff --git a/scenarios/AronComponentConfigExample/config/AronComponentConfigExample.cfg b/scenarios/AronComponentConfigExample/config/AronComponentConfigExample.cfg new file mode 100644 index 0000000000000000000000000000000000000000..dcf2233099e0acef6a620567979cc71e1da2cc29 --- /dev/null +++ b/scenarios/AronComponentConfigExample/config/AronComponentConfigExample.cfg @@ -0,0 +1,344 @@ +# ================================================================== +# AronComponentConfigExample properties +# ================================================================== + +# ArmarX.AdditionalPackages: List of additional ArmarX packages which should be in the list of default packages. If you have custom packages, which should be found by the gui or other apps, specify them here. Comma separated List. +# Attributes: +# - Default: Default value not mapped. +# - Case sensitivity: yes +# - Required: no +# ArmarX.AdditionalPackages = Default value not mapped. + + +# ArmarX.ApplicationName: Application name +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.ApplicationName = "" + + +# ArmarX.CachePath: Path for cache files. If relative path AND env. variable ARMARX_CONFIG_DIR is set, the cache path will be made relative to ARMARX_CONFIG_DIR. Otherwise if relative it will be relative to the default ArmarX config dir (${ARMARX_WORKSPACE}/armarx_config) +# Attributes: +# - Default: mongo/.cache +# - Case sensitivity: yes +# - Required: no +# ArmarX.CachePath = mongo/.cache + + +# ArmarX.ComponentConfigTest.EnableProfiling: enable profiler which is used for logging performance events +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ComponentConfigTest.EnableProfiling = false + + +# ArmarX.ComponentConfigTest.MinimumLoggingLevel: Local logging level only for this component +# Attributes: +# - Default: Undefined +# - Case sensitivity: yes +# - Required: no +# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning} +# ArmarX.ComponentConfigTest.MinimumLoggingLevel = Undefined + + +# ArmarX.ComponentConfigTest.ObjectName: Name of IceGrid well-known object +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.ComponentConfigTest.ObjectName = "" + + +# ArmarX.ComponentConfigTest.RemoteGuiName: Name of the remote gui provider +# Attributes: +# - Default: RemoteGuiProvider +# - Case sensitivity: yes +# - Required: no +# ArmarX.ComponentConfigTest.RemoteGuiName = RemoteGuiProvider + + +# ArmarX.ComponentConfigTest.boolMember: +# Attributes: +# - Default: true +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ComponentConfigTest.boolMember = true + + +# ArmarX.ComponentConfigTest.floatMember: +# Attributes: +# - Default: 100 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ComponentConfigTest.floatMember = 100 + + +# ArmarX.ComponentConfigTest.intMember: +# Attributes: +# - Default: 1000 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ComponentConfigTest.intMember = 1000 + + +# ArmarX.ComponentConfigTest.stringMember: +# Attributes: +# - Default: initial +# - Case sensitivity: yes +# - Required: no +# ArmarX.ComponentConfigTest.stringMember = initial + + +# ArmarX.ComponentConfigTest.subMember.boolMember: +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ComponentConfigTest.subMember.boolMember = false + + +# ArmarX.ComponentConfigTest.subMember.doubleMember: +# Attributes: +# - Default: 0 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ComponentConfigTest.subMember.doubleMember = 0 + + +# ArmarX.ComponentConfigTest.subMember.floatMember: +# Attributes: +# - Default: 0 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ComponentConfigTest.subMember.floatMember = 0 + + +# ArmarX.ComponentConfigTest.subMember.intMember: +# Attributes: +# - Default: 0 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ComponentConfigTest.subMember.intMember = 0 + + +# ArmarX.ComponentConfigTest.subMember.stringMember: +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.ComponentConfigTest.subMember.stringMember = "" + + +# ArmarX.ComponentConfigTest.subMember.subsubMember.boolMember: +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ComponentConfigTest.subMember.subsubMember.boolMember = false + + +# ArmarX.ComponentConfigTest.subMember.subsubMember.enumMember: +# Attributes: +# - Default: 1 +# - Case sensitivity: yes +# - Required: no +# - Possible values: {Bar, Baz, Foo, Qux} +# ArmarX.ComponentConfigTest.subMember.subsubMember.enumMember = 1 + + +# ArmarX.ComponentConfigTest.subMember.subsubMember.floatMember: +# Attributes: +# - Default: 0 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ComponentConfigTest.subMember.subsubMember.floatMember = 0 + + +# ArmarX.ComponentConfigTest.subMember.subsubMember.intDictMember: +# Attributes: +# - Default: int1:1,int2:2 +# - Case sensitivity: yes +# - Required: no +ArmarX.ComponentConfigTest.subMember.subsubMember.intDictMember = int1:1,int2:2,int3:3,int5:4 + + +# ArmarX.ComponentConfigTest.subMember.subsubMember.intListMember: +# Attributes: +# - Default: 1, 2, 3, 4, 5, 6 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ComponentConfigTest.subMember.subsubMember.intListMember = 1, 2, 3, 4, 5, 6 + + +# ArmarX.ComponentConfigTest.subMember.subsubMember.intMember: +# Attributes: +# - Default: 0 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ComponentConfigTest.subMember.subsubMember.intMember = 0 + + +# ArmarX.ComponentConfigTest.subMember.subsubMember.stringDictMember: +# Attributes: +# - Default: string1:blub,string2:duh +# - Case sensitivity: yes +# - Required: no +# ArmarX.ComponentConfigTest.subMember.subsubMember.stringDictMember = string1:blub,string2:duh + + +# ArmarX.ComponentConfigTest.subMember.subsubMember.stringListMember: +# Attributes: +# - Default: a, b, c, d, e +# - Case sensitivity: yes +# - Required: no +# ArmarX.ComponentConfigTest.subMember.subsubMember.stringListMember = a, b, c, d, e + + +# ArmarX.ComponentConfigTest.subMember.subsubMember.stringMember: +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.ComponentConfigTest.subMember.subsubMember.stringMember = "" + + +# ArmarX.Config: Comma-separated list of configuration files +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.Config = "" + + +# ArmarX.DataPath: Semicolon-separated search list for data files +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.DataPath = "" + + +# ArmarX.DefaultPackages: List of ArmarX packages which are accessible by default. Comma separated List. If you want to add your own packages and use all default ArmarX packages, use the property 'AdditionalPackages'. +# Attributes: +# - Default: Default value not mapped. +# - Case sensitivity: yes +# - Required: no +# ArmarX.DefaultPackages = Default value not mapped. + + +# ArmarX.DependenciesConfig: Path to the (usually generated) config file containing all data paths of all dependent projects. This property usually does not need to be edited. +# Attributes: +# - Default: ./config/dependencies.cfg +# - Case sensitivity: yes +# - Required: no +# ArmarX.DependenciesConfig = ./config/dependencies.cfg + + +# ArmarX.DisableLogging: Turn logging off in whole application +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.DisableLogging = false + + +# ArmarX.EnableProfiling: Enable profiling of CPU load produced by this application +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.EnableProfiling = false + + +# ArmarX.LoadLibraries: Libraries to load at start up of the application. Must be enabled by the Application with enableLibLoading(). Format: PackageName:LibraryName;... or /absolute/path/to/library;... +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.LoadLibraries = "" + + +# ArmarX.LoggingGroup: The logging group is transmitted with every ArmarX log message over Ice in order to group the message in the GUI. +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.LoggingGroup = "" + + +# ArmarX.RedirectStdout: Redirect std::cout and std::cerr to ArmarXLog +# Attributes: +# - Default: true +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.RedirectStdout = true + + +# ArmarX.RemoteHandlesDeletionTimeout: The timeout (in ms) before a remote handle deletes the managed object after the use count reached 0. This time can be used by a client to increment the count again (may be required when transmitting remote handles) +# Attributes: +# - Default: 3000 +# - Case sensitivity: yes +# - Required: no +# ArmarX.RemoteHandlesDeletionTimeout = 3000 + + +# ArmarX.SecondsStartupDelay: The startup will be delayed by this number of seconds (useful for debugging) +# Attributes: +# - Default: 0 +# - Case sensitivity: yes +# - Required: no +# ArmarX.SecondsStartupDelay = 0 + + +# ArmarX.StartDebuggerOnCrash: If this application crashes (segmentation fault) qtcreator will attach to this process and start the debugger. +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.StartDebuggerOnCrash = false + + +# ArmarX.ThreadPoolSize: Size of the ArmarX ThreadPool that is always running. +# Attributes: +# - Default: 1 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ThreadPoolSize = 1 + + +# ArmarX.TopicSuffix: Suffix appended to all topic names for outgoing topics. This is mainly used to direct all topics to another name for TopicReplaying purposes. +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.TopicSuffix = "" + + +# ArmarX.UseTimeServer: Enable using a global Timeserver (e.g. from ArmarXSimulator) +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.UseTimeServer = false + + +# ArmarX.Verbosity: Global logging level for whole application +# Attributes: +# - Default: Info +# - Case sensitivity: yes +# - Required: no +# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning} +# ArmarX.Verbosity = Info + + diff --git a/scenarios/AronComponentConfigExample/config/RemoteGuiProviderApp.cfg b/scenarios/AronComponentConfigExample/config/RemoteGuiProviderApp.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4b6abea40d72afd7d313ee47a9b191f3b26de30d --- /dev/null +++ b/scenarios/AronComponentConfigExample/config/RemoteGuiProviderApp.cfg @@ -0,0 +1,196 @@ +# ================================================================== +# RemoteGuiProviderApp properties +# ================================================================== + +# ArmarX.AdditionalPackages: List of additional ArmarX packages which should be in the list of default packages. If you have custom packages, which should be found by the gui or other apps, specify them here. Comma separated List. +# Attributes: +# - Default: Default value not mapped. +# - Case sensitivity: yes +# - Required: no +# ArmarX.AdditionalPackages = Default value not mapped. + + +# ArmarX.ApplicationName: Application name +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.ApplicationName = "" + + +# ArmarX.CachePath: Path for cache files. If relative path AND env. variable ARMARX_CONFIG_DIR is set, the cache path will be made relative to ARMARX_CONFIG_DIR. Otherwise if relative it will be relative to the default ArmarX config dir (${ARMARX_WORKSPACE}/armarx_config) +# Attributes: +# - Default: mongo/.cache +# - Case sensitivity: yes +# - Required: no +# ArmarX.CachePath = mongo/.cache + + +# ArmarX.Config: Comma-separated list of configuration files +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.Config = "" + + +# ArmarX.DataPath: Semicolon-separated search list for data files +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.DataPath = "" + + +# ArmarX.DefaultPackages: List of ArmarX packages which are accessible by default. Comma separated List. If you want to add your own packages and use all default ArmarX packages, use the property 'AdditionalPackages'. +# Attributes: +# - Default: Default value not mapped. +# - Case sensitivity: yes +# - Required: no +# ArmarX.DefaultPackages = Default value not mapped. + + +# ArmarX.DependenciesConfig: Path to the (usually generated) config file containing all data paths of all dependent projects. This property usually does not need to be edited. +# Attributes: +# - Default: ./config/dependencies.cfg +# - Case sensitivity: yes +# - Required: no +# ArmarX.DependenciesConfig = ./config/dependencies.cfg + + +# ArmarX.DisableLogging: Turn logging off in whole application +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.DisableLogging = false + + +# ArmarX.EnableProfiling: Enable profiling of CPU load produced by this application +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.EnableProfiling = false + + +# ArmarX.LoadLibraries: Libraries to load at start up of the application. Must be enabled by the Application with enableLibLoading(). Format: PackageName:LibraryName;... or /absolute/path/to/library;... +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.LoadLibraries = "" + + +# ArmarX.LoggingGroup: The logging group is transmitted with every ArmarX log message over Ice in order to group the message in the GUI. +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.LoggingGroup = "" + + +# ArmarX.RedirectStdout: Redirect std::cout and std::cerr to ArmarXLog +# Attributes: +# - Default: true +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.RedirectStdout = true + + +# ArmarX.RemoteGuiProvider.EnableProfiling: enable profiler which is used for logging performance events +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.RemoteGuiProvider.EnableProfiling = false + + +# ArmarX.RemoteGuiProvider.MinimumLoggingLevel: Local logging level only for this component +# Attributes: +# - Default: Undefined +# - Case sensitivity: yes +# - Required: no +# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning} +# ArmarX.RemoteGuiProvider.MinimumLoggingLevel = Undefined + + +# ArmarX.RemoteGuiProvider.ObjectName: Name of IceGrid well-known object +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.RemoteGuiProvider.ObjectName = "" + + +# ArmarX.RemoteGuiProvider.TopicName: Name of the topic on which updates to the remote state are reported. +# Attributes: +# - Default: RemoteGuiTopic +# - Case sensitivity: yes +# - Required: no +# ArmarX.RemoteGuiProvider.TopicName = RemoteGuiTopic + + +# ArmarX.RemoteHandlesDeletionTimeout: The timeout (in ms) before a remote handle deletes the managed object after the use count reached 0. This time can be used by a client to increment the count again (may be required when transmitting remote handles) +# Attributes: +# - Default: 3000 +# - Case sensitivity: yes +# - Required: no +# ArmarX.RemoteHandlesDeletionTimeout = 3000 + + +# ArmarX.SecondsStartupDelay: The startup will be delayed by this number of seconds (useful for debugging) +# Attributes: +# - Default: 0 +# - Case sensitivity: yes +# - Required: no +# ArmarX.SecondsStartupDelay = 0 + + +# ArmarX.StartDebuggerOnCrash: If this application crashes (segmentation fault) qtcreator will attach to this process and start the debugger. +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.StartDebuggerOnCrash = false + + +# ArmarX.ThreadPoolSize: Size of the ArmarX ThreadPool that is always running. +# Attributes: +# - Default: 1 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ThreadPoolSize = 1 + + +# ArmarX.TopicSuffix: Suffix appended to all topic names for outgoing topics. This is mainly used to direct all topics to another name for TopicReplaying purposes. +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.TopicSuffix = "" + + +# ArmarX.UseTimeServer: Enable using a global Timeserver (e.g. from ArmarXSimulator) +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.UseTimeServer = false + + +# ArmarX.Verbosity: Global logging level for whole application +# Attributes: +# - Default: Info +# - Case sensitivity: yes +# - Required: no +# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning} +# ArmarX.Verbosity = Info + + diff --git a/scenarios/AronComponentConfigExample/config/global.cfg b/scenarios/AronComponentConfigExample/config/global.cfg new file mode 100644 index 0000000000000000000000000000000000000000..44dde159548b3d54011a075a37f6ac0d7fc41f14 --- /dev/null +++ b/scenarios/AronComponentConfigExample/config/global.cfg @@ -0,0 +1,4 @@ +# ================================================================== +# Global Config from Scenario AronComponentConfigExample +# ================================================================== + diff --git a/scenarios/ArticulatedObjectWriterExample/ArticulatedObjectWriterExample.scx b/scenarios/ArticulatedObjectWriterExample/ArticulatedObjectWriterExample.scx new file mode 100644 index 0000000000000000000000000000000000000000..9e4ef2810eae6db0c1a475e9b220fae7e18418b6 --- /dev/null +++ b/scenarios/ArticulatedObjectWriterExample/ArticulatedObjectWriterExample.scx @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<scenario name="ArticulatedObjectWriterExample" creation="2022-10-10.18:54:39" globalConfigName="./config/global.cfg" package="RobotAPI" deploymentType="local" nodeName="NodeMain"> + <application name="ArticulatedObjectLocalizerExample" instance="" package="RobotAPI" nodeName="" enabled="true" iceAutoRestart="false"/> + <application name="MemoryNameSystem" instance="" package="RobotAPI" nodeName="" enabled="true" iceAutoRestart="false"/> + <application name="RemoteGuiProviderApp" instance="" package="ArmarXGui" nodeName="" enabled="true" iceAutoRestart="false"/> + <application name="ObjectMemory" instance="" package="RobotAPI" nodeName="" enabled="true" iceAutoRestart="false"/> + <application name="ArVizStorage" instance="" package="RobotAPI" nodeName="" enabled="true" iceAutoRestart="false"/> + <application name="RobotStateMemory" instance="" package="RobotAPI" nodeName="" enabled="true" iceAutoRestart="false"/> +</scenario> + diff --git a/scenarios/ArticulatedObjectWriterExample/config/ArVizStorage.cfg b/scenarios/ArticulatedObjectWriterExample/config/ArVizStorage.cfg new file mode 100644 index 0000000000000000000000000000000000000000..302ac28c37dd28de3e68fb4fe4c2174faa4ec3bf --- /dev/null +++ b/scenarios/ArticulatedObjectWriterExample/config/ArVizStorage.cfg @@ -0,0 +1,212 @@ +# ================================================================== +# ArVizStorage properties +# ================================================================== + +# ArmarX.AdditionalPackages: List of additional ArmarX packages which should be in the list of default packages. If you have custom packages, which should be found by the gui or other apps, specify them here. Comma separated List. +# Attributes: +# - Default: Default value not mapped. +# - Case sensitivity: yes +# - Required: no +# ArmarX.AdditionalPackages = Default value not mapped. + + +# ArmarX.ApplicationName: Application name +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.ApplicationName = "" + + +# ArmarX.ArVizStorage.EnableProfiling: enable profiler which is used for logging performance events +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ArVizStorage.EnableProfiling = false + + +# ArmarX.ArVizStorage.HistoryPath: Destination path where the history is serialized to +# Attributes: +# - Default: RobotAPI/ArVizStorage +# - Case sensitivity: yes +# - Required: no +# ArmarX.ArVizStorage.HistoryPath = RobotAPI/ArVizStorage + + +# ArmarX.ArVizStorage.MaxHistorySize: How many layer updates are saved in the history until they are compressed +# Attributes: +# - Default: 1000 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ArVizStorage.MaxHistorySize = 1000 + + +# ArmarX.ArVizStorage.MinimumLoggingLevel: Local logging level only for this component +# Attributes: +# - Default: Undefined +# - Case sensitivity: yes +# - Required: no +# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning} +# ArmarX.ArVizStorage.MinimumLoggingLevel = Undefined + + +# ArmarX.ArVizStorage.ObjectName: Name of IceGrid well-known object +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.ArVizStorage.ObjectName = "" + + +# ArmarX.ArVizStorage.TopicName: Layer updates are sent over this topic. +# Attributes: +# - Default: ArVizTopic +# - Case sensitivity: yes +# - Required: no +# ArmarX.ArVizStorage.TopicName = ArVizTopic + + +# ArmarX.CachePath: Path for cache files. If relative path AND env. variable ARMARX_CONFIG_DIR is set, the cache path will be made relative to ARMARX_CONFIG_DIR. Otherwise if relative it will be relative to the default ArmarX config dir (${ARMARX_WORKSPACE}/armarx_config) +# Attributes: +# - Default: mongo/.cache +# - Case sensitivity: yes +# - Required: no +# ArmarX.CachePath = mongo/.cache + + +# ArmarX.Config: Comma-separated list of configuration files +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.Config = "" + + +# ArmarX.DataPath: Semicolon-separated search list for data files +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.DataPath = "" + + +# ArmarX.DefaultPackages: List of ArmarX packages which are accessible by default. Comma separated List. If you want to add your own packages and use all default ArmarX packages, use the property 'AdditionalPackages'. +# Attributes: +# - Default: Default value not mapped. +# - Case sensitivity: yes +# - Required: no +# ArmarX.DefaultPackages = Default value not mapped. + + +# ArmarX.DependenciesConfig: Path to the (usually generated) config file containing all data paths of all dependent projects. This property usually does not need to be edited. +# Attributes: +# - Default: ./config/dependencies.cfg +# - Case sensitivity: yes +# - Required: no +# ArmarX.DependenciesConfig = ./config/dependencies.cfg + + +# ArmarX.DisableLogging: Turn logging off in whole application +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.DisableLogging = false + + +# ArmarX.EnableProfiling: Enable profiling of CPU load produced by this application +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.EnableProfiling = false + + +# ArmarX.LoadLibraries: Libraries to load at start up of the application. Must be enabled by the Application with enableLibLoading(). Format: PackageName:LibraryName;... or /absolute/path/to/library;... +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.LoadLibraries = "" + + +# ArmarX.LoggingGroup: The logging group is transmitted with every ArmarX log message over Ice in order to group the message in the GUI. +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.LoggingGroup = "" + + +# ArmarX.RedirectStdout: Redirect std::cout and std::cerr to ArmarXLog +# Attributes: +# - Default: true +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.RedirectStdout = true + + +# ArmarX.RemoteHandlesDeletionTimeout: The timeout (in ms) before a remote handle deletes the managed object after the use count reached 0. This time can be used by a client to increment the count again (may be required when transmitting remote handles) +# Attributes: +# - Default: 3000 +# - Case sensitivity: yes +# - Required: no +# ArmarX.RemoteHandlesDeletionTimeout = 3000 + + +# ArmarX.SecondsStartupDelay: The startup will be delayed by this number of seconds (useful for debugging) +# Attributes: +# - Default: 0 +# - Case sensitivity: yes +# - Required: no +# ArmarX.SecondsStartupDelay = 0 + + +# ArmarX.StartDebuggerOnCrash: If this application crashes (segmentation fault) qtcreator will attach to this process and start the debugger. +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.StartDebuggerOnCrash = false + + +# ArmarX.ThreadPoolSize: Size of the ArmarX ThreadPool that is always running. +# Attributes: +# - Default: 1 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ThreadPoolSize = 1 + + +# ArmarX.TopicSuffix: Suffix appended to all topic names for outgoing topics. This is mainly used to direct all topics to another name for TopicReplaying purposes. +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.TopicSuffix = "" + + +# ArmarX.UseTimeServer: Enable using a global Timeserver (e.g. from ArmarXSimulator) +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.UseTimeServer = false + + +# ArmarX.Verbosity: Global logging level for whole application +# Attributes: +# - Default: Info +# - Case sensitivity: yes +# - Required: no +# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning} +# ArmarX.Verbosity = Info + + diff --git a/scenarios/ArticulatedObjectWriterExample/config/ArticulatedObjectLocalizerExample.cfg b/scenarios/ArticulatedObjectWriterExample/config/ArticulatedObjectLocalizerExample.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e6c221120c7a8f33693caf9dc5fa229875dabb4a --- /dev/null +++ b/scenarios/ArticulatedObjectWriterExample/config/ArticulatedObjectLocalizerExample.cfg @@ -0,0 +1,269 @@ +# ================================================================== +# ArticulatedObjectLocalizerExample properties +# ================================================================== + +# ArmarX.AdditionalPackages: List of additional ArmarX packages which should be in the list of default packages. If you have custom packages, which should be found by the gui or other apps, specify them here. Comma separated List. +# Attributes: +# - Default: Default value not mapped. +# - Case sensitivity: yes +# - Required: no +# ArmarX.AdditionalPackages = Default value not mapped. + + +# ArmarX.ApplicationName: Application name +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.ApplicationName = "" + + +# ArmarX.ArticulatedObjectLocalizerExample.EnableProfiling: enable profiler which is used for logging performance events +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ArticulatedObjectLocalizerExample.EnableProfiling = false + + +# ArmarX.ArticulatedObjectLocalizerExample.MinimumLoggingLevel: Local logging level only for this component +# Attributes: +# - Default: Undefined +# - Case sensitivity: yes +# - Required: no +# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning} +# ArmarX.ArticulatedObjectLocalizerExample.MinimumLoggingLevel = Undefined + + +# ArmarX.ArticulatedObjectLocalizerExample.ObjectName: Name of IceGrid well-known object +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.ArticulatedObjectLocalizerExample.ObjectName = "" + + +# ArmarX.ArticulatedObjectLocalizerExample.mem.obj.articulated.CoreSegment: Name of the memory core segment to use for object classes. +# Attributes: +# - Default: Class +# - Case sensitivity: yes +# - Required: no +# ArmarX.ArticulatedObjectLocalizerExample.mem.obj.articulated.CoreSegment = Class + + +# ArmarX.ArticulatedObjectLocalizerExample.mem.obj.articulated.MemoryName: +# Attributes: +# - Default: Object +# - Case sensitivity: yes +# - Required: no +# ArmarX.ArticulatedObjectLocalizerExample.mem.obj.articulated.MemoryName = Object + + +# ArmarX.ArticulatedObjectLocalizerExample.mem.obj.articulated.read.ProviderName: +# Attributes: +# - Default: PriorKnowledgeData +# - Case sensitivity: yes +# - Required: no +# ArmarX.ArticulatedObjectLocalizerExample.mem.obj.articulated.read.ProviderName = PriorKnowledgeData + + +# ArmarX.ArticulatedObjectLocalizerExample.mem.obj.articulated.write.ProviderName: Name of this provider +# Attributes: +# - Case sensitivity: yes +# - Required: yes +ArmarX.ArticulatedObjectLocalizerExample.mem.obj.articulated.write.ProviderName = ExampleProvider + + +# ArmarX.ArticulatedObjectLocalizerExample.mns.MemoryNameSystemEnabled: Whether to use (and depend on) the Memory Name System (MNS). +# Set to false to use this memory as a stand-alone. +# Attributes: +# - Default: true +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ArticulatedObjectLocalizerExample.mns.MemoryNameSystemEnabled = true + + +# ArmarX.ArticulatedObjectLocalizerExample.mns.MemoryNameSystemName: Name of the Memory Name System (MNS) component. +# Attributes: +# - Default: MemoryNameSystem +# - Case sensitivity: yes +# - Required: no +# ArmarX.ArticulatedObjectLocalizerExample.mns.MemoryNameSystemName = MemoryNameSystem + + +# ArmarX.ArticulatedObjectLocalizerExample.p.obj.class: +# Attributes: +# - Default: mobile-dishwasher +# - Case sensitivity: yes +# - Required: no +ArmarX.ArticulatedObjectLocalizerExample.p.obj.class = cabinet + + +# ArmarX.ArticulatedObjectLocalizerExample.p.obj.dataset: +# Attributes: +# - Default: Kitchen +# - Case sensitivity: yes +# - Required: no +ArmarX.ArticulatedObjectLocalizerExample.p.obj.dataset = RBO-articulated-object-dataset + + +# ArmarX.ArticulatedObjectLocalizerExample.tpc.pub.DebugObserver: Name of the `DebugObserver` topic to publish data to. +# Attributes: +# - Default: DebugObserver +# - Case sensitivity: yes +# - Required: no +# ArmarX.ArticulatedObjectLocalizerExample.tpc.pub.DebugObserver = DebugObserver + + +# ArmarX.ArticulatedObjectLocalizerExample.updateFrequency: Memory update frequency (write). +# Attributes: +# - Default: 25 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ArticulatedObjectLocalizerExample.updateFrequency = 25 + + +# ArmarX.CachePath: Path for cache files. If relative path AND env. variable ARMARX_CONFIG_DIR is set, the cache path will be made relative to ARMARX_CONFIG_DIR. Otherwise if relative it will be relative to the default ArmarX config dir (${ARMARX_WORKSPACE}/armarx_config) +# Attributes: +# - Default: mongo/.cache +# - Case sensitivity: yes +# - Required: no +# ArmarX.CachePath = mongo/.cache + + +# ArmarX.Config: Comma-separated list of configuration files +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.Config = "" + + +# ArmarX.DataPath: Semicolon-separated search list for data files +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.DataPath = "" + + +# ArmarX.DefaultPackages: List of ArmarX packages which are accessible by default. Comma separated List. If you want to add your own packages and use all default ArmarX packages, use the property 'AdditionalPackages'. +# Attributes: +# - Default: Default value not mapped. +# - Case sensitivity: yes +# - Required: no +# ArmarX.DefaultPackages = Default value not mapped. + + +# ArmarX.DependenciesConfig: Path to the (usually generated) config file containing all data paths of all dependent projects. This property usually does not need to be edited. +# Attributes: +# - Default: ./config/dependencies.cfg +# - Case sensitivity: yes +# - Required: no +# ArmarX.DependenciesConfig = ./config/dependencies.cfg + + +# ArmarX.DisableLogging: Turn logging off in whole application +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.DisableLogging = false + + +# ArmarX.EnableProfiling: Enable profiling of CPU load produced by this application +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.EnableProfiling = false + + +# ArmarX.LoadLibraries: Libraries to load at start up of the application. Must be enabled by the Application with enableLibLoading(). Format: PackageName:LibraryName;... or /absolute/path/to/library;... +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.LoadLibraries = "" + + +# ArmarX.LoggingGroup: The logging group is transmitted with every ArmarX log message over Ice in order to group the message in the GUI. +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.LoggingGroup = "" + + +# ArmarX.RedirectStdout: Redirect std::cout and std::cerr to ArmarXLog +# Attributes: +# - Default: true +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.RedirectStdout = true + + +# ArmarX.RemoteHandlesDeletionTimeout: The timeout (in ms) before a remote handle deletes the managed object after the use count reached 0. This time can be used by a client to increment the count again (may be required when transmitting remote handles) +# Attributes: +# - Default: 3000 +# - Case sensitivity: yes +# - Required: no +# ArmarX.RemoteHandlesDeletionTimeout = 3000 + + +# ArmarX.SecondsStartupDelay: The startup will be delayed by this number of seconds (useful for debugging) +# Attributes: +# - Default: 0 +# - Case sensitivity: yes +# - Required: no +# ArmarX.SecondsStartupDelay = 0 + + +# ArmarX.StartDebuggerOnCrash: If this application crashes (segmentation fault) qtcreator will attach to this process and start the debugger. +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.StartDebuggerOnCrash = false + + +# ArmarX.ThreadPoolSize: Size of the ArmarX ThreadPool that is always running. +# Attributes: +# - Default: 1 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ThreadPoolSize = 1 + + +# ArmarX.TopicSuffix: Suffix appended to all topic names for outgoing topics. This is mainly used to direct all topics to another name for TopicReplaying purposes. +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.TopicSuffix = "" + + +# ArmarX.UseTimeServer: Enable using a global Timeserver (e.g. from ArmarXSimulator) +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.UseTimeServer = false + + +# ArmarX.Verbosity: Global logging level for whole application +# Attributes: +# - Default: Info +# - Case sensitivity: yes +# - Required: no +# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning} +# ArmarX.Verbosity = Info + + diff --git a/scenarios/ArticulatedObjectWriterExample/config/MemoryNameSystem.cfg b/scenarios/ArticulatedObjectWriterExample/config/MemoryNameSystem.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b8bc70a66ca7f32a628886ad1bf13e373f9750d3 --- /dev/null +++ b/scenarios/ArticulatedObjectWriterExample/config/MemoryNameSystem.cfg @@ -0,0 +1,196 @@ +# ================================================================== +# MemoryNameSystem properties +# ================================================================== + +# ArmarX.AdditionalPackages: List of additional ArmarX packages which should be in the list of default packages. If you have custom packages, which should be found by the gui or other apps, specify them here. Comma separated List. +# Attributes: +# - Default: Default value not mapped. +# - Case sensitivity: yes +# - Required: no +# ArmarX.AdditionalPackages = Default value not mapped. + + +# ArmarX.ApplicationName: Application name +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.ApplicationName = "" + + +# ArmarX.CachePath: Path for cache files. If relative path AND env. variable ARMARX_CONFIG_DIR is set, the cache path will be made relative to ARMARX_CONFIG_DIR. Otherwise if relative it will be relative to the default ArmarX config dir (${ARMARX_WORKSPACE}/armarx_config) +# Attributes: +# - Default: mongo/.cache +# - Case sensitivity: yes +# - Required: no +# ArmarX.CachePath = mongo/.cache + + +# ArmarX.Config: Comma-separated list of configuration files +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.Config = "" + + +# ArmarX.DataPath: Semicolon-separated search list for data files +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.DataPath = "" + + +# ArmarX.DefaultPackages: List of ArmarX packages which are accessible by default. Comma separated List. If you want to add your own packages and use all default ArmarX packages, use the property 'AdditionalPackages'. +# Attributes: +# - Default: Default value not mapped. +# - Case sensitivity: yes +# - Required: no +# ArmarX.DefaultPackages = Default value not mapped. + + +# ArmarX.DependenciesConfig: Path to the (usually generated) config file containing all data paths of all dependent projects. This property usually does not need to be edited. +# Attributes: +# - Default: ./config/dependencies.cfg +# - Case sensitivity: yes +# - Required: no +# ArmarX.DependenciesConfig = ./config/dependencies.cfg + + +# ArmarX.DisableLogging: Turn logging off in whole application +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.DisableLogging = false + + +# ArmarX.EnableProfiling: Enable profiling of CPU load produced by this application +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.EnableProfiling = false + + +# ArmarX.LoadLibraries: Libraries to load at start up of the application. Must be enabled by the Application with enableLibLoading(). Format: PackageName:LibraryName;... or /absolute/path/to/library;... +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.LoadLibraries = "" + + +# ArmarX.LoggingGroup: The logging group is transmitted with every ArmarX log message over Ice in order to group the message in the GUI. +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.LoggingGroup = "" + + +# ArmarX.MemoryNameSystem.EnableProfiling: enable profiler which is used for logging performance events +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.MemoryNameSystem.EnableProfiling = false + + +# ArmarX.MemoryNameSystem.MinimumLoggingLevel: Local logging level only for this component +# Attributes: +# - Default: Undefined +# - Case sensitivity: yes +# - Required: no +# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning} +# ArmarX.MemoryNameSystem.MinimumLoggingLevel = Undefined + + +# ArmarX.MemoryNameSystem.ObjectName: Name of IceGrid well-known object +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.MemoryNameSystem.ObjectName = "" + + +# ArmarX.MemoryNameSystem.RemoteGuiName: Name of the remote gui provider +# Attributes: +# - Default: RemoteGuiProvider +# - Case sensitivity: yes +# - Required: no +# ArmarX.MemoryNameSystem.RemoteGuiName = RemoteGuiProvider + + +# ArmarX.RedirectStdout: Redirect std::cout and std::cerr to ArmarXLog +# Attributes: +# - Default: true +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.RedirectStdout = true + + +# ArmarX.RemoteHandlesDeletionTimeout: The timeout (in ms) before a remote handle deletes the managed object after the use count reached 0. This time can be used by a client to increment the count again (may be required when transmitting remote handles) +# Attributes: +# - Default: 3000 +# - Case sensitivity: yes +# - Required: no +# ArmarX.RemoteHandlesDeletionTimeout = 3000 + + +# ArmarX.SecondsStartupDelay: The startup will be delayed by this number of seconds (useful for debugging) +# Attributes: +# - Default: 0 +# - Case sensitivity: yes +# - Required: no +# ArmarX.SecondsStartupDelay = 0 + + +# ArmarX.StartDebuggerOnCrash: If this application crashes (segmentation fault) qtcreator will attach to this process and start the debugger. +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.StartDebuggerOnCrash = false + + +# ArmarX.ThreadPoolSize: Size of the ArmarX ThreadPool that is always running. +# Attributes: +# - Default: 1 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ThreadPoolSize = 1 + + +# ArmarX.TopicSuffix: Suffix appended to all topic names for outgoing topics. This is mainly used to direct all topics to another name for TopicReplaying purposes. +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.TopicSuffix = "" + + +# ArmarX.UseTimeServer: Enable using a global Timeserver (e.g. from ArmarXSimulator) +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.UseTimeServer = false + + +# ArmarX.Verbosity: Global logging level for whole application +# Attributes: +# - Default: Info +# - Case sensitivity: yes +# - Required: no +# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning} +# ArmarX.Verbosity = Info + + diff --git a/scenarios/ArticulatedObjectWriterExample/config/ObjectMemory.cfg b/scenarios/ArticulatedObjectWriterExample/config/ObjectMemory.cfg new file mode 100644 index 0000000000000000000000000000000000000000..95961b39febd5772f9f3ee485552631f407b73cc --- /dev/null +++ b/scenarios/ArticulatedObjectWriterExample/config/ObjectMemory.cfg @@ -0,0 +1,701 @@ +# ================================================================== +# ObjectMemory properties +# ================================================================== + +# ArmarX.AdditionalPackages: List of additional ArmarX packages which should be in the list of default packages. If you have custom packages, which should be found by the gui or other apps, specify them here. Comma separated List. +# Attributes: +# - Default: Default value not mapped. +# - Case sensitivity: yes +# - Required: no +# ArmarX.AdditionalPackages = Default value not mapped. + + +# ArmarX.ApplicationName: Application name +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.ApplicationName = "" + + +# ArmarX.CachePath: Path for cache files. If relative path AND env. variable ARMARX_CONFIG_DIR is set, the cache path will be made relative to ARMARX_CONFIG_DIR. Otherwise if relative it will be relative to the default ArmarX config dir (${ARMARX_WORKSPACE}/armarx_config) +# Attributes: +# - Default: mongo/.cache +# - Case sensitivity: yes +# - Required: no +# ArmarX.CachePath = mongo/.cache + + +# ArmarX.Config: Comma-separated list of configuration files +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.Config = "" + + +# ArmarX.DataPath: Semicolon-separated search list for data files +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.DataPath = "" + + +# ArmarX.DefaultPackages: List of ArmarX packages which are accessible by default. Comma separated List. If you want to add your own packages and use all default ArmarX packages, use the property 'AdditionalPackages'. +# Attributes: +# - Default: Default value not mapped. +# - Case sensitivity: yes +# - Required: no +# ArmarX.DefaultPackages = Default value not mapped. + + +# ArmarX.DependenciesConfig: Path to the (usually generated) config file containing all data paths of all dependent projects. This property usually does not need to be edited. +# Attributes: +# - Default: ./config/dependencies.cfg +# - Case sensitivity: yes +# - Required: no +# ArmarX.DependenciesConfig = ./config/dependencies.cfg + + +# ArmarX.DisableLogging: Turn logging off in whole application +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.DisableLogging = false + + +# ArmarX.EnableProfiling: Enable profiling of CPU load produced by this application +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.EnableProfiling = false + + +# ArmarX.LoadLibraries: Libraries to load at start up of the application. Must be enabled by the Application with enableLibLoading(). Format: PackageName:LibraryName;... or /absolute/path/to/library;... +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.LoadLibraries = "" + + +# ArmarX.LoggingGroup: The logging group is transmitted with every ArmarX log message over Ice in order to group the message in the GUI. +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.LoggingGroup = "" + + +# ArmarX.ObjectMemory.ArVizStorageName: Name of the ArViz storage +# Attributes: +# - Default: ArVizStorage +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.ArVizStorageName = ArVizStorage + + +# ArmarX.ObjectMemory.ArVizTopicName: Name of the ArViz topic +# Attributes: +# - Default: ArVizTopic +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.ArVizTopicName = ArVizTopic + + +# ArmarX.ObjectMemory.EnableProfiling: enable profiler which is used for logging performance events +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ObjectMemory.EnableProfiling = false + + +# ArmarX.ObjectMemory.MinimumLoggingLevel: Local logging level only for this component +# Attributes: +# - Default: Undefined +# - Case sensitivity: yes +# - Required: no +# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning} +# ArmarX.ObjectMemory.MinimumLoggingLevel = Undefined + + +# ArmarX.ObjectMemory.ObjectName: Name of IceGrid well-known object +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.ObjectName = "" + + +# ArmarX.ObjectMemory.RemoteGuiName: Name of the remote gui provider +# Attributes: +# - Default: RemoteGuiProvider +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.RemoteGuiName = RemoteGuiProvider + + +# ArmarX.ObjectMemory.cmp.KinematicUnitObserverName: Name of the kinematic unit observer. +# Attributes: +# - Default: KinematicUnitObserver +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.cmp.KinematicUnitObserverName = KinematicUnitObserver + + +# ArmarX.ObjectMemory.mem.MemoryName: Name of this memory server. +# Attributes: +# - Default: Object +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.MemoryName = Object + + +# ArmarX.ObjectMemory.mem.attachments.CoreSegmentName: Name of the object instance core segment. +# Attributes: +# - Default: Attachments +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.attachments.CoreSegmentName = Attachments + + +# ArmarX.ObjectMemory.mem.attachments.MaxHistorySize: Maximal size of object poses history (-1 for infinite). +# Attributes: +# - Default: -1 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.attachments.MaxHistorySize = -1 + + +# ArmarX.ObjectMemory.mem.cls.Floor.EntityName: Object class entity of the floor. +# Attributes: +# - Default: Building/floor-20x20 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.cls.Floor.EntityName = Building/floor-20x20 + + +# ArmarX.ObjectMemory.mem.cls.Floor.Height: Height (z) of the floor plane. +# Set slightly below 0 to avoid z-fighting when drawing planes on the ground. +# Attributes: +# - Default: -1 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.cls.Floor.Height = -1 + + +# ArmarX.ObjectMemory.mem.cls.Floor.LayerName: Layer to draw the floor on. +# Attributes: +# - Default: Floor +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.cls.Floor.LayerName = Floor + + +# ArmarX.ObjectMemory.mem.cls.Floor.Show: Whether to show the floor. +# Attributes: +# - Default: true +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ObjectMemory.mem.cls.Floor.Show = true + + +# ArmarX.ObjectMemory.mem.cls.LoadFromObjectsPackage: If true, load the objects from the objects package on startup. +# Attributes: +# - Default: true +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ObjectMemory.mem.cls.LoadFromObjectsPackage = true + + +# ArmarX.ObjectMemory.mem.cls.ObjectsPackage: Name of the objects package to load from. +# Attributes: +# - Default: PriorKnowledgeData +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.cls.ObjectsPackage = PriorKnowledgeData + + +# ArmarX.ObjectMemory.mem.cls.seg.CoreMaxHistorySize: Maximal size of the Class entity histories (-1 for infinite). +# Attributes: +# - Default: -1 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.cls.seg.CoreMaxHistorySize = -1 + + +# ArmarX.ObjectMemory.mem.cls.seg.CoreSegmentName: Name of the Class core segment. +# Attributes: +# - Default: Class +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.cls.seg.CoreSegmentName = Class + + +# ArmarX.ObjectMemory.mem.inst.DiscardSnapshotsWhileAttached: If true, no new snapshots are stored while an object is attached to a robot node. +# If false, new snapshots are stored, but the attachment is kept in the new snapshots. +# Attributes: +# - Default: true +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ObjectMemory.mem.inst.DiscardSnapshotsWhileAttached = true + + +# ArmarX.ObjectMemory.mem.inst.calibration.offset: Offset for the node to be calibrated. +# Attributes: +# - Default: 0 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.inst.calibration.offset = 0 + + +# ArmarX.ObjectMemory.mem.inst.calibration.robotName: Name of robot whose note can be calibrated. +# If not given, the 'fallbackName' is used. +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.inst.calibration.robotName = "" + + +# ArmarX.ObjectMemory.mem.inst.calibration.robotNode: Robot node which can be calibrated. +# Attributes: +# - Default: Neck_2_Pitch +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.inst.calibration.robotNode = Neck_2_Pitch + + +# ArmarX.ObjectMemory.mem.inst.decay.delaySeconds: Duration after latest localization before decay starts. +# Attributes: +# - Default: 5 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.inst.decay.delaySeconds = 5 + + +# ArmarX.ObjectMemory.mem.inst.decay.durationSeconds: How long to reach minimal confidence. +# Attributes: +# - Default: 20 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.inst.decay.durationSeconds = 20 + + +# ArmarX.ObjectMemory.mem.inst.decay.enabled: If true, object poses decay over time when not localized anymore. +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ObjectMemory.mem.inst.decay.enabled = false + + +# ArmarX.ObjectMemory.mem.inst.decay.maxConfidence: Confidence when decay starts. +# Attributes: +# - Default: 1 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.inst.decay.maxConfidence = 1 + + +# ArmarX.ObjectMemory.mem.inst.decay.minConfidence: Confidence after decay duration. +# Attributes: +# - Default: 0 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.inst.decay.minConfidence = 0 + + +# ArmarX.ObjectMemory.mem.inst.decay.removeObjectsBelowConfidence: Remove objects whose confidence is lower than this value. +# Attributes: +# - Default: 0.100000001 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.inst.decay.removeObjectsBelowConfidence = 0.100000001 + + +# ArmarX.ObjectMemory.mem.inst.head.checkHeadVelocity: If true, check whether the head is moving and discard updates in the meantime. +# Attributes: +# - Default: true +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ObjectMemory.mem.inst.head.checkHeadVelocity = true + + +# ArmarX.ObjectMemory.mem.inst.head.discardIntervalAfterMoveMS: For how long new updates are ignored after moving the head. +# Attributes: +# - Default: 100 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.inst.head.discardIntervalAfterMoveMS = 100 + + +# ArmarX.ObjectMemory.mem.inst.head.maxJointVelocity: If a head joint's velocity is higher, the head is considered moving. +# Attributes: +# - Default: 0.0500000007 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.inst.head.maxJointVelocity = 0.0500000007 + + +# ArmarX.ObjectMemory.mem.inst.robots.FallbackName: Robot name to use as fallback if the robot name is not specified in a provided object pose. +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.inst.robots.FallbackName = "" + + +# ArmarX.ObjectMemory.mem.inst.scene.10_Package: ArmarX package containing the scene snapshots. +# Scene snapshots are expected to be located in Package/data/Package/Scenes/*.json. +# Attributes: +# - Default: PriorKnowledgeData +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.inst.scene.10_Package = PriorKnowledgeData + + +# ArmarX.ObjectMemory.mem.inst.scene.11_Directory: Directory in Package/data/Package/ containing the scene snapshots. +# Attributes: +# - Default: scenes +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.inst.scene.11_Directory = scenes + + +# ArmarX.ObjectMemory.mem.inst.scene.12_SnapshotToLoad: Scene to load on startup (e.g. 'Scene_2021-06-24_20-20-03'). +# You can also specify paths relative to 'Package/scenes/'. +# You can also specify a ; separated list of scenes. +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.inst.scene.12_SnapshotToLoad = "" + + +# ArmarX.ObjectMemory.mem.inst.seg.CoreMaxHistorySize: Maximal size of the Instance entity histories (-1 for infinite). +# Attributes: +# - Default: 64 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.inst.seg.CoreMaxHistorySize = 64 + + +# ArmarX.ObjectMemory.mem.inst.seg.CoreSegmentName: Name of the Instance core segment. +# Attributes: +# - Default: Instance +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.inst.seg.CoreSegmentName = Instance + + +# ArmarX.ObjectMemory.mem.inst.visu.alpha: Alpha of objects (1 = solid, 0 = transparent). +# Attributes: +# - Default: 1 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.inst.visu.alpha = 1 + + +# ArmarX.ObjectMemory.mem.inst.visu.alphaByConfidence: If true, use the pose confidence as alpha (if < 1.0). +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ObjectMemory.mem.inst.visu.alphaByConfidence = false + + +# ArmarX.ObjectMemory.mem.inst.visu.enabled: Enable or disable visualization of objects. +# Attributes: +# - Default: true +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ObjectMemory.mem.inst.visu.enabled = true + + +# ArmarX.ObjectMemory.mem.inst.visu.frequenzyHz: Frequency of visualization. +# Attributes: +# - Default: 25 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.inst.visu.frequenzyHz = 25 + + +# ArmarX.ObjectMemory.mem.inst.visu.gaussians.position: Enable showing pose gaussians (orientation part). +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ObjectMemory.mem.inst.visu.gaussians.position = false + + +# ArmarX.ObjectMemory.mem.inst.visu.gaussians.positionDisplaced: Displace center orientation (co)variance circle arrows along their rotation axis. +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ObjectMemory.mem.inst.visu.gaussians.positionDisplaced = false + + +# ArmarX.ObjectMemory.mem.inst.visu.gaussians.positionScale: Scaling of pose gaussians (orientation part). +# Attributes: +# - Default: 100 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.inst.visu.gaussians.positionScale = 100 + + +# ArmarX.ObjectMemory.mem.inst.visu.inGlobalFrame: If true, show global poses. If false, show poses in robot frame. +# Attributes: +# - Default: true +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ObjectMemory.mem.inst.visu.inGlobalFrame = true + + +# ArmarX.ObjectMemory.mem.inst.visu.objectFrames: Enable showing object frames. +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ObjectMemory.mem.inst.visu.objectFrames = false + + +# ArmarX.ObjectMemory.mem.inst.visu.objectFramesScale: Scaling of object frames. +# Attributes: +# - Default: 1 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.inst.visu.objectFramesScale = 1 + + +# ArmarX.ObjectMemory.mem.inst.visu.oobbs: Enable showing oriented bounding boxes. +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ObjectMemory.mem.inst.visu.oobbs = false + + +# ArmarX.ObjectMemory.mem.inst.visu.predictions.linear.ghostAlpha: Alpha of linear prediction ghosts. +# Attributes: +# - Default: 0.699999988 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.inst.visu.predictions.linear.ghostAlpha = 0.699999988 + + +# ArmarX.ObjectMemory.mem.inst.visu.predictions.linear.showArrow: Show arrows from current object poses to the linearly predicted ones. +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ObjectMemory.mem.inst.visu.predictions.linear.showArrow = false + + +# ArmarX.ObjectMemory.mem.inst.visu.predictions.linear.showFrame: Show frames at linearly predicted object poses. +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ObjectMemory.mem.inst.visu.predictions.linear.showFrame = false + + +# ArmarX.ObjectMemory.mem.inst.visu.predictions.linear.showGhost: Show ghosts at linearly predicted object poses. +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ObjectMemory.mem.inst.visu.predictions.linear.showGhost = false + + +# ArmarX.ObjectMemory.mem.inst.visu.predictions.linear.timeOffset: The offset (in seconds) to the current time to make predictions for. +# Attributes: +# - Default: 1 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.inst.visu.predictions.linear.timeOffset = 1 + + +# ArmarX.ObjectMemory.mem.inst.visu.predictions.linear.timeWindow: The time window (in seconds) into the past to perform the regression on. +# Attributes: +# - Default: 2 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.inst.visu.predictions.linear.timeWindow = 2 + + +# ArmarX.ObjectMemory.mem.inst.visu.useArticulatedModels: Prefer articulated object models if available. +# Attributes: +# - Default: true +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ObjectMemory.mem.inst.visu.useArticulatedModels = true + + +# ArmarX.ObjectMemory.mem.ltm.configuration: +# Attributes: +# - Default: {} +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.ltm.configuration = {} + + +# ArmarX.ObjectMemory.mem.ltm.enabled: +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ObjectMemory.mem.ltm.enabled = false + + +# ArmarX.ObjectMemory.mem.robot_state.Memory: +# Attributes: +# - Default: RobotState +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.robot_state.Memory = RobotState + + +# ArmarX.ObjectMemory.mem.robot_state.localizationSegment: Name of the localization memory core segment to use. +# Attributes: +# - Default: Localization +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mem.robot_state.localizationSegment = Localization + + +# ArmarX.ObjectMemory.mns.MemoryNameSystemEnabled: Whether to use (and depend on) the Memory Name System (MNS). +# Set to false to use this memory as a stand-alone. +# Attributes: +# - Default: true +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.ObjectMemory.mns.MemoryNameSystemEnabled = true + + +# ArmarX.ObjectMemory.mns.MemoryNameSystemName: Name of the Memory Name System (MNS) component. +# Attributes: +# - Default: MemoryNameSystem +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.mns.MemoryNameSystemName = MemoryNameSystem + + +# ArmarX.ObjectMemory.prediction.TimeWindow: Duration of time window into the past to use for predictions when requested via the PredictingMemoryInterface (in seconds). +# Attributes: +# - Default: 2 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.prediction.TimeWindow = 2 + + +# ArmarX.ObjectMemory.tpc.pub.DebugObserver: Name of the `DebugObserver` topic to publish data to. +# Attributes: +# - Default: DebugObserver +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.tpc.pub.DebugObserver = DebugObserver + + +# ArmarX.ObjectMemory.tpc.sub.ObjectPoseTopic: Name of the `ObjectPoseTopic` topic to subscribe to. +# Attributes: +# - Default: ObjectPoseTopic +# - Case sensitivity: yes +# - Required: no +# ArmarX.ObjectMemory.tpc.sub.ObjectPoseTopic = ObjectPoseTopic + + +# ArmarX.RedirectStdout: Redirect std::cout and std::cerr to ArmarXLog +# Attributes: +# - Default: true +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.RedirectStdout = true + + +# ArmarX.RemoteHandlesDeletionTimeout: The timeout (in ms) before a remote handle deletes the managed object after the use count reached 0. This time can be used by a client to increment the count again (may be required when transmitting remote handles) +# Attributes: +# - Default: 3000 +# - Case sensitivity: yes +# - Required: no +# ArmarX.RemoteHandlesDeletionTimeout = 3000 + + +# ArmarX.SecondsStartupDelay: The startup will be delayed by this number of seconds (useful for debugging) +# Attributes: +# - Default: 0 +# - Case sensitivity: yes +# - Required: no +# ArmarX.SecondsStartupDelay = 0 + + +# ArmarX.StartDebuggerOnCrash: If this application crashes (segmentation fault) qtcreator will attach to this process and start the debugger. +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.StartDebuggerOnCrash = false + + +# ArmarX.ThreadPoolSize: Size of the ArmarX ThreadPool that is always running. +# Attributes: +# - Default: 1 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ThreadPoolSize = 1 + + +# ArmarX.TopicSuffix: Suffix appended to all topic names for outgoing topics. This is mainly used to direct all topics to another name for TopicReplaying purposes. +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.TopicSuffix = "" + + +# ArmarX.UseTimeServer: Enable using a global Timeserver (e.g. from ArmarXSimulator) +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.UseTimeServer = false + + +# ArmarX.Verbosity: Global logging level for whole application +# Attributes: +# - Default: Info +# - Case sensitivity: yes +# - Required: no +# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning} +# ArmarX.Verbosity = Info + + diff --git a/scenarios/ArticulatedObjectWriterExample/config/RemoteGuiProviderApp.cfg b/scenarios/ArticulatedObjectWriterExample/config/RemoteGuiProviderApp.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4b6abea40d72afd7d313ee47a9b191f3b26de30d --- /dev/null +++ b/scenarios/ArticulatedObjectWriterExample/config/RemoteGuiProviderApp.cfg @@ -0,0 +1,196 @@ +# ================================================================== +# RemoteGuiProviderApp properties +# ================================================================== + +# ArmarX.AdditionalPackages: List of additional ArmarX packages which should be in the list of default packages. If you have custom packages, which should be found by the gui or other apps, specify them here. Comma separated List. +# Attributes: +# - Default: Default value not mapped. +# - Case sensitivity: yes +# - Required: no +# ArmarX.AdditionalPackages = Default value not mapped. + + +# ArmarX.ApplicationName: Application name +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.ApplicationName = "" + + +# ArmarX.CachePath: Path for cache files. If relative path AND env. variable ARMARX_CONFIG_DIR is set, the cache path will be made relative to ARMARX_CONFIG_DIR. Otherwise if relative it will be relative to the default ArmarX config dir (${ARMARX_WORKSPACE}/armarx_config) +# Attributes: +# - Default: mongo/.cache +# - Case sensitivity: yes +# - Required: no +# ArmarX.CachePath = mongo/.cache + + +# ArmarX.Config: Comma-separated list of configuration files +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.Config = "" + + +# ArmarX.DataPath: Semicolon-separated search list for data files +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.DataPath = "" + + +# ArmarX.DefaultPackages: List of ArmarX packages which are accessible by default. Comma separated List. If you want to add your own packages and use all default ArmarX packages, use the property 'AdditionalPackages'. +# Attributes: +# - Default: Default value not mapped. +# - Case sensitivity: yes +# - Required: no +# ArmarX.DefaultPackages = Default value not mapped. + + +# ArmarX.DependenciesConfig: Path to the (usually generated) config file containing all data paths of all dependent projects. This property usually does not need to be edited. +# Attributes: +# - Default: ./config/dependencies.cfg +# - Case sensitivity: yes +# - Required: no +# ArmarX.DependenciesConfig = ./config/dependencies.cfg + + +# ArmarX.DisableLogging: Turn logging off in whole application +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.DisableLogging = false + + +# ArmarX.EnableProfiling: Enable profiling of CPU load produced by this application +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.EnableProfiling = false + + +# ArmarX.LoadLibraries: Libraries to load at start up of the application. Must be enabled by the Application with enableLibLoading(). Format: PackageName:LibraryName;... or /absolute/path/to/library;... +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.LoadLibraries = "" + + +# ArmarX.LoggingGroup: The logging group is transmitted with every ArmarX log message over Ice in order to group the message in the GUI. +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.LoggingGroup = "" + + +# ArmarX.RedirectStdout: Redirect std::cout and std::cerr to ArmarXLog +# Attributes: +# - Default: true +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.RedirectStdout = true + + +# ArmarX.RemoteGuiProvider.EnableProfiling: enable profiler which is used for logging performance events +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.RemoteGuiProvider.EnableProfiling = false + + +# ArmarX.RemoteGuiProvider.MinimumLoggingLevel: Local logging level only for this component +# Attributes: +# - Default: Undefined +# - Case sensitivity: yes +# - Required: no +# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning} +# ArmarX.RemoteGuiProvider.MinimumLoggingLevel = Undefined + + +# ArmarX.RemoteGuiProvider.ObjectName: Name of IceGrid well-known object +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.RemoteGuiProvider.ObjectName = "" + + +# ArmarX.RemoteGuiProvider.TopicName: Name of the topic on which updates to the remote state are reported. +# Attributes: +# - Default: RemoteGuiTopic +# - Case sensitivity: yes +# - Required: no +# ArmarX.RemoteGuiProvider.TopicName = RemoteGuiTopic + + +# ArmarX.RemoteHandlesDeletionTimeout: The timeout (in ms) before a remote handle deletes the managed object after the use count reached 0. This time can be used by a client to increment the count again (may be required when transmitting remote handles) +# Attributes: +# - Default: 3000 +# - Case sensitivity: yes +# - Required: no +# ArmarX.RemoteHandlesDeletionTimeout = 3000 + + +# ArmarX.SecondsStartupDelay: The startup will be delayed by this number of seconds (useful for debugging) +# Attributes: +# - Default: 0 +# - Case sensitivity: yes +# - Required: no +# ArmarX.SecondsStartupDelay = 0 + + +# ArmarX.StartDebuggerOnCrash: If this application crashes (segmentation fault) qtcreator will attach to this process and start the debugger. +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.StartDebuggerOnCrash = false + + +# ArmarX.ThreadPoolSize: Size of the ArmarX ThreadPool that is always running. +# Attributes: +# - Default: 1 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ThreadPoolSize = 1 + + +# ArmarX.TopicSuffix: Suffix appended to all topic names for outgoing topics. This is mainly used to direct all topics to another name for TopicReplaying purposes. +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.TopicSuffix = "" + + +# ArmarX.UseTimeServer: Enable using a global Timeserver (e.g. from ArmarXSimulator) +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.UseTimeServer = false + + +# ArmarX.Verbosity: Global logging level for whole application +# Attributes: +# - Default: Info +# - Case sensitivity: yes +# - Required: no +# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning} +# ArmarX.Verbosity = Info + + diff --git a/scenarios/ArticulatedObjectWriterExample/config/RobotStateMemory.cfg b/scenarios/ArticulatedObjectWriterExample/config/RobotStateMemory.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5839620e5e3c5df7e080f39405a021bdbcd4a0ea --- /dev/null +++ b/scenarios/ArticulatedObjectWriterExample/config/RobotStateMemory.cfg @@ -0,0 +1,361 @@ +# ================================================================== +# RobotStateMemory properties +# ================================================================== + +# ArmarX.AdditionalPackages: List of additional ArmarX packages which should be in the list of default packages. If you have custom packages, which should be found by the gui or other apps, specify them here. Comma separated List. +# Attributes: +# - Default: Default value not mapped. +# - Case sensitivity: yes +# - Required: no +# ArmarX.AdditionalPackages = Default value not mapped. + + +# ArmarX.ApplicationName: Application name +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.ApplicationName = "" + + +# ArmarX.CachePath: Path for cache files. If relative path AND env. variable ARMARX_CONFIG_DIR is set, the cache path will be made relative to ARMARX_CONFIG_DIR. Otherwise if relative it will be relative to the default ArmarX config dir (${ARMARX_WORKSPACE}/armarx_config) +# Attributes: +# - Default: mongo/.cache +# - Case sensitivity: yes +# - Required: no +# ArmarX.CachePath = mongo/.cache + + +# ArmarX.Config: Comma-separated list of configuration files +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.Config = "" + + +# ArmarX.DataPath: Semicolon-separated search list for data files +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.DataPath = "" + + +# ArmarX.DefaultPackages: List of ArmarX packages which are accessible by default. Comma separated List. If you want to add your own packages and use all default ArmarX packages, use the property 'AdditionalPackages'. +# Attributes: +# - Default: Default value not mapped. +# - Case sensitivity: yes +# - Required: no +# ArmarX.DefaultPackages = Default value not mapped. + + +# ArmarX.DependenciesConfig: Path to the (usually generated) config file containing all data paths of all dependent projects. This property usually does not need to be edited. +# Attributes: +# - Default: ./config/dependencies.cfg +# - Case sensitivity: yes +# - Required: no +# ArmarX.DependenciesConfig = ./config/dependencies.cfg + + +# ArmarX.DisableLogging: Turn logging off in whole application +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.DisableLogging = false + + +# ArmarX.EnableProfiling: Enable profiling of CPU load produced by this application +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.EnableProfiling = false + + +# ArmarX.LoadLibraries: Libraries to load at start up of the application. Must be enabled by the Application with enableLibLoading(). Format: PackageName:LibraryName;... or /absolute/path/to/library;... +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.LoadLibraries = "" + + +# ArmarX.LoggingGroup: The logging group is transmitted with every ArmarX log message over Ice in order to group the message in the GUI. +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.LoggingGroup = "" + + +# ArmarX.RedirectStdout: Redirect std::cout and std::cerr to ArmarXLog +# Attributes: +# - Default: true +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.RedirectStdout = true + + +# ArmarX.RemoteHandlesDeletionTimeout: The timeout (in ms) before a remote handle deletes the managed object after the use count reached 0. This time can be used by a client to increment the count again (may be required when transmitting remote handles) +# Attributes: +# - Default: 3000 +# - Case sensitivity: yes +# - Required: no +# ArmarX.RemoteHandlesDeletionTimeout = 3000 + + +# ArmarX.RobotStateMemory.ArVizStorageName: Name of the ArViz storage +# Attributes: +# - Default: ArVizStorage +# - Case sensitivity: yes +# - Required: no +# ArmarX.RobotStateMemory.ArVizStorageName = ArVizStorage + + +# ArmarX.RobotStateMemory.ArVizTopicName: Name of the ArViz topic +# Attributes: +# - Default: ArVizTopic +# - Case sensitivity: yes +# - Required: no +# ArmarX.RobotStateMemory.ArVizTopicName = ArVizTopic + + +# ArmarX.RobotStateMemory.DebugObserverTopicName: Name of the topic the DebugObserver listens on +# Attributes: +# - Default: DebugObserver +# - Case sensitivity: yes +# - Required: no +# ArmarX.RobotStateMemory.DebugObserverTopicName = DebugObserver + + +# ArmarX.RobotStateMemory.EnableProfiling: enable profiler which is used for logging performance events +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.RobotStateMemory.EnableProfiling = false + + +# ArmarX.RobotStateMemory.MinimumLoggingLevel: Local logging level only for this component +# Attributes: +# - Default: Undefined +# - Case sensitivity: yes +# - Required: no +# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning} +# ArmarX.RobotStateMemory.MinimumLoggingLevel = Undefined + + +# ArmarX.RobotStateMemory.ObjectName: Name of IceGrid well-known object +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.RobotStateMemory.ObjectName = "" + + +# ArmarX.RobotStateMemory.RobotUnit.SensorValuePrefix: Prefix of all sensor values. +# Attributes: +# - Default: sens.* +# - Case sensitivity: yes +# - Required: no +# ArmarX.RobotStateMemory.RobotUnit.SensorValuePrefix = sens.* + + +# ArmarX.RobotStateMemory.RobotUnit.UpdateFrequency: The frequency to store values in Hz. All other values get discarded. Minimum is 1, max is 100.000000. +# Attributes: +# - Default: 50 +# - Case sensitivity: yes +# - Required: no +# ArmarX.RobotStateMemory.RobotUnit.UpdateFrequency = 50 + + +# ArmarX.RobotStateMemory.RobotUnitName: Name of the RobotUnit +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.RobotStateMemory.RobotUnitName = "" + + +# ArmarX.RobotStateMemory.WaitForRobotUnit: Add the robot unit as dependency to the component. This memory requires a running RobotUnit, therefore we should add it as explicit dependency. +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.RobotStateMemory.WaitForRobotUnit = false + + +# ArmarX.RobotStateMemory.mem.MemoryName: Name of this memory server. +# Attributes: +# - Default: RobotState +# - Case sensitivity: yes +# - Required: no +# ArmarX.RobotStateMemory.mem.MemoryName = RobotState + + +# ArmarX.RobotStateMemory.mem.desc.seg.CoreMaxHistorySize: Maximal size of the Description entity histories (-1 for infinite). +# Attributes: +# - Default: -1 +# - Case sensitivity: yes +# - Required: no +# ArmarX.RobotStateMemory.mem.desc.seg.CoreMaxHistorySize = -1 + + +# ArmarX.RobotStateMemory.mem.desc.seg.CoreSegmentName: Name of the Description core segment. +# Attributes: +# - Default: Description +# - Case sensitivity: yes +# - Required: no +# ArmarX.RobotStateMemory.mem.desc.seg.CoreSegmentName = Description + + +# ArmarX.RobotStateMemory.mem.loc.seg.CoreMaxHistorySize: Maximal size of the Localization entity histories (-1 for infinite). +# Attributes: +# - Default: 1024 +# - Case sensitivity: yes +# - Required: no +# ArmarX.RobotStateMemory.mem.loc.seg.CoreMaxHistorySize = 1024 + + +# ArmarX.RobotStateMemory.mem.loc.seg.CoreSegmentName: Name of the Localization core segment. +# Attributes: +# - Default: Localization +# - Case sensitivity: yes +# - Required: no +# ArmarX.RobotStateMemory.mem.loc.seg.CoreSegmentName = Localization + + +# ArmarX.RobotStateMemory.mem.ltm.configuration: +# Attributes: +# - Default: {} +# - Case sensitivity: yes +# - Required: no +# ArmarX.RobotStateMemory.mem.ltm.configuration = {} + + +# ArmarX.RobotStateMemory.mem.ltm.enabled: +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.RobotStateMemory.mem.ltm.enabled = false + + +# ArmarX.RobotStateMemory.mem.prop.seg.CoreMaxHistorySize: Maximal size of the Proprioception entity histories (-1 for infinite). +# Attributes: +# - Default: 1024 +# - Case sensitivity: yes +# - Required: no +# ArmarX.RobotStateMemory.mem.prop.seg.CoreMaxHistorySize = 1024 + + +# ArmarX.RobotStateMemory.mem.prop.seg.CoreSegmentName: Name of the Proprioception core segment. +# Attributes: +# - Default: Proprioception +# - Case sensitivity: yes +# - Required: no +# ArmarX.RobotStateMemory.mem.prop.seg.CoreSegmentName = Proprioception + + +# ArmarX.RobotStateMemory.mem.visu.enabled: Enable or disable visualization of objects. +# Attributes: +# - Default: true +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.RobotStateMemory.mem.visu.enabled = true + + +# ArmarX.RobotStateMemory.mem.visu.frequenzyHz: Frequency of visualization. +# Attributes: +# - Default: 25 +# - Case sensitivity: yes +# - Required: no +# ArmarX.RobotStateMemory.mem.visu.frequenzyHz = 25 + + +# ArmarX.RobotStateMemory.mns.MemoryNameSystemEnabled: Whether to use (and depend on) the Memory Name System (MNS). +# Set to false to use this memory as a stand-alone. +# Attributes: +# - Default: true +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.RobotStateMemory.mns.MemoryNameSystemEnabled = true + + +# ArmarX.RobotStateMemory.mns.MemoryNameSystemName: Name of the Memory Name System (MNS) component. +# Attributes: +# - Default: MemoryNameSystem +# - Case sensitivity: yes +# - Required: no +# ArmarX.RobotStateMemory.mns.MemoryNameSystemName = MemoryNameSystem + + +# ArmarX.RobotStateMemory.prediction.TimeWindow: Duration of time window into the past to use for predictions when requested via the PredictingMemoryInterface (in seconds). +# Attributes: +# - Default: 2 +# - Case sensitivity: yes +# - Required: no +# ArmarX.RobotStateMemory.prediction.TimeWindow = 2 + + +# ArmarX.SecondsStartupDelay: The startup will be delayed by this number of seconds (useful for debugging) +# Attributes: +# - Default: 0 +# - Case sensitivity: yes +# - Required: no +# ArmarX.SecondsStartupDelay = 0 + + +# ArmarX.StartDebuggerOnCrash: If this application crashes (segmentation fault) qtcreator will attach to this process and start the debugger. +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.StartDebuggerOnCrash = false + + +# ArmarX.ThreadPoolSize: Size of the ArmarX ThreadPool that is always running. +# Attributes: +# - Default: 1 +# - Case sensitivity: yes +# - Required: no +# ArmarX.ThreadPoolSize = 1 + + +# ArmarX.TopicSuffix: Suffix appended to all topic names for outgoing topics. This is mainly used to direct all topics to another name for TopicReplaying purposes. +# Attributes: +# - Default: "" +# - Case sensitivity: yes +# - Required: no +# ArmarX.TopicSuffix = "" + + +# ArmarX.UseTimeServer: Enable using a global Timeserver (e.g. from ArmarXSimulator) +# Attributes: +# - Default: false +# - Case sensitivity: yes +# - Required: no +# - Possible values: {0, 1, false, no, true, yes} +# ArmarX.UseTimeServer = false + + +# ArmarX.Verbosity: Global logging level for whole application +# Attributes: +# - Default: Info +# - Case sensitivity: yes +# - Required: no +# - Possible values: {Debug, Error, Fatal, Important, Info, Undefined, Verbose, Warning} +# ArmarX.Verbosity = Info + + diff --git a/scenarios/ArticulatedObjectWriterExample/config/global.cfg b/scenarios/ArticulatedObjectWriterExample/config/global.cfg new file mode 100644 index 0000000000000000000000000000000000000000..fdfd38bb91a262ada278ef24d00788bd824755ed --- /dev/null +++ b/scenarios/ArticulatedObjectWriterExample/config/global.cfg @@ -0,0 +1,4 @@ +# ================================================================== +# Global Config from Scenario ArticulatedObjectWriterExample +# ================================================================== + diff --git a/source/RobotAPI/components/AronComponentConfigExample/AronComponentConfigExample.cpp b/source/RobotAPI/components/AronComponentConfigExample/AronComponentConfigExample.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1b2b3df5038078ad16a14af3cb977767129e096d --- /dev/null +++ b/source/RobotAPI/components/AronComponentConfigExample/AronComponentConfigExample.cpp @@ -0,0 +1,119 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package robdekon + * @author Christoph Pohl ( christoph dot pohl at kit dot edu ) + * @date 06.09.22 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include <RobotAPI/libraries/aron_component_config/PropertyDefinitionVisitors.h> +#include <RobotAPI/libraries/aron_component_config/RemoteGui.h> +#include <ArmarXCore/libraries/DecoupledSingleComponent/Decoupled.h> +#include "AronComponentConfigExample.h" + +namespace armarx +{ + + void + AronComponentConfigExample::onInitComponent() + { + + } + + void + AronComponentConfigExample::onConnectComponent() + { + remote_gui_plugin_->createOrUpdateTab(aron_component_config_plugin_->buildRemoteGui("Config"), + [this](armarx::RemoteGui::TabProxy& prx) + { + prx.receiveUpdates(); + std::lock_guard lock(write_mutex); + if (aron_component_config_plugin_->updateRemoteGui(prx)) + { + remote_gui_plugin_->createOrUpdateTab("", + aron_component_config_plugin_ + ->buildRemoteGui( + "Config")); + } + prx.sendUpdates(); + }); + periodicTask = new SimplePeriodicTask<>([&, this] + { + std::lock_guard lock(write_mutex); + ARMARX_TRACE; + auto& config = + aron_component_config_plugin_->config_.getWriteBuffer(); +// ARMARX_INFO << VAROUT(config.orientation) << VAROUT(config.pose) << VAROUT(config.position); + config.intMember--; + aron_component_config_plugin_->config_.commitWrite(); + }, 1000); + periodicTask->start(); + } + + void + AronComponentConfigExample::onDisconnectComponent() + { + } + + void + AronComponentConfigExample::onExitComponent() + { + } + + armarx::PropertyDefinitionsPtr + AronComponentConfigExample::createPropertyDefinitions() + { + armarx::PropertyDefinitionsPtr defs = new AronComponentConfigExamplePropertyDefinitions(getConfigIdentifier()); + auto& config = aron_component_config_plugin_->config_.getWriteBuffer(); + config.boolMember = true; + config.floatMember = 100.0f; + config.intMember = 1000; + config.stringMember = "initial"; + config.longMember = 0; + config.subMember + .subsubMember + .intListMember + .insert(config.subMember.subsubMember.intListMember.end(), {1, 2, 3, 4, 5, 6}); + config.subMember + .subsubMember + .stringListMember + .insert(config.subMember.subsubMember.stringListMember.end(), {"a", "b", "c", "d", "e"}); + config.subMember.subsubMember.intDictMember.emplace("int1", 1); + config.subMember.subsubMember.intDictMember.emplace("int2", 2); + config.subMember.subsubMember.stringDictMember.emplace("string1", "blub"); + config.subMember.subsubMember.stringDictMember.emplace("string2", "duh"); + aron_component_config_plugin_->config_.commitWrite(); + return defs; + } + + std::string + AronComponentConfigExample::getDefaultName() const + { + return "ComponentConfigTest"; + } + + AronComponentConfigExample::AronComponentConfigExample() + { + addPlugin(remote_gui_plugin_, ""); + addPlugin(aron_component_config_plugin_, ""); + } + + AronComponentConfigExamplePropertyDefinitions::AronComponentConfigExamplePropertyDefinitions(std::string prefix) : + armarx::ComponentPropertyDefinitions(std::move(prefix)) + { + } +} \ No newline at end of file diff --git a/source/RobotAPI/components/AronComponentConfigExample/AronComponentConfigExample.h b/source/RobotAPI/components/AronComponentConfigExample/AronComponentConfigExample.h new file mode 100644 index 0000000000000000000000000000000000000000..e466b0a6ae20979766da06f839d31f45b76c3574 --- /dev/null +++ b/source/RobotAPI/components/AronComponentConfigExample/AronComponentConfigExample.h @@ -0,0 +1,69 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package robdekon + * @author Christoph Pohl ( christoph dot pohl at kit dot edu ) + * @date 06.09.22 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +#include <ArmarXCore/core/Component.h> +#include <RobotAPI/components/AronComponentConfigExample/aron/ComponentConfig.aron.generated.h> +#include <RobotAPI/libraries/aron_component_config/ComponentPlugin.h> + +namespace armarx +{ + + class AronComponentConfigExamplePropertyDefinitions : + public armarx::ComponentPropertyDefinitions + { + public: + AronComponentConfigExamplePropertyDefinitions(std::string prefix); + }; + + class AronComponentConfigExample : + virtual public armarx::Component + { + public: + std::string getDefaultName() const override; + + /// @see armarx::ManagedIceObject::onInitComponent() + void onInitComponent() override; + + /// @see armarx::ManagedIceObject::onConnectComponent() + void onConnectComponent() override; + + /// @see armarx::ManagedIceObject::onDisconnectComponent() + void onDisconnectComponent() override; + + /// @see armarx::ManagedIceObject::onExitComponent() + void onExitComponent() override; + + /// @see PropertyUser::createPropertyDefinitions() + armarx::PropertyDefinitionsPtr createPropertyDefinitions() override; + + AronComponentConfigExample(); + private: + SimplePeriodicTask<>::pointer_type periodicTask; + std::experimental::observer_ptr<plugins::RemoteGuiComponentPlugin> remote_gui_plugin_{nullptr}; + std::experimental::observer_ptr<plugins::AronComponentConfigPlugin<armarx::component_config::aron::TestConfig>> + aron_component_config_plugin_{nullptr}; + std::mutex write_mutex; + + }; +} \ No newline at end of file diff --git a/source/RobotAPI/components/AronComponentConfigExample/CMakeLists.txt b/source/RobotAPI/components/AronComponentConfigExample/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..c219bee7094345ac6eb814b9568f711d37431f59 --- /dev/null +++ b/source/RobotAPI/components/AronComponentConfigExample/CMakeLists.txt @@ -0,0 +1,26 @@ +armarx_component_set_name("AronComponentConfigExample") + +set(COMPONENT_LIBS + ArmarXCore ArmarXCoreInterfaces + RobotAPICore RobotAPIInterfaces RobotAPIComponentPlugins # for ArViz and other plugins + aron_component_config + ) + +set(SOURCES + AronComponentConfigExample.cpp + ) +set(HEADERS + AronComponentConfigExample.h + ) + +armarx_add_component("${SOURCES}" "${HEADERS}") + +armarx_enable_aron_file_generation_for_target( + TARGET_NAME + ${ARMARX_COMPONENT_NAME} + ARON_FILES + aron/ComponentConfig.xml +) + +#generate the application +armarx_generate_and_add_component_executable() \ No newline at end of file diff --git a/source/RobotAPI/components/AronComponentConfigExample/aron/ComponentConfig.xml b/source/RobotAPI/components/AronComponentConfigExample/aron/ComponentConfig.xml new file mode 100644 index 0000000000000000000000000000000000000000..aabd27602d4f4ef4f0313dd00af36ccfa9c2a9dd --- /dev/null +++ b/source/RobotAPI/components/AronComponentConfigExample/aron/ComponentConfig.xml @@ -0,0 +1,105 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<AronTypeDefinition> + + <GenerateTypes> + + <IntEnum name='armarx::component_config::aron::EnumTest'> + <EnumValue key="Foo" value="0"/> + <EnumValue key="Bar" value="1"/> + <EnumValue key="Baz" value="2"/> + <EnumValue key="Qux" value="3"/> + </IntEnum> + + <Object name='armarx::component_config::aron::SubSubConfig'> + <ObjectChild key='stringMember'> + <string/> + </ObjectChild> + <ObjectChild key='intMember'> + <int/> + </ObjectChild> + <ObjectChild key='floatMember'> + <float/> + </ObjectChild> + <ObjectChild key='longMember'> + <long/> + </ObjectChild> + <ObjectChild key='boolMember'> + <bool/> + </ObjectChild> + <ObjectChild key='enumMember'> + <armarx::component_config::aron::EnumTest/> + </ObjectChild> + <ObjectChild key='stringListMember'> + <List> + <string/> + </List> + </ObjectChild> + <ObjectChild key='intListMember'> + <List> + <int/> + </List> + </ObjectChild> + <ObjectChild key='stringDictMember'> + <Dict> + <string/> + </Dict> + </ObjectChild> + <ObjectChild key='intDictMember'> + <Dict> + <int/> + </Dict> + </ObjectChild> + </Object> + + <Object name='armarx::component_config::aron::SubConfig'> + <ObjectChild key='stringMember'> + <string/> + </ObjectChild> + <ObjectChild key='intMember'> + <int/> + </ObjectChild> + <ObjectChild key='floatMember'> + <float/> + </ObjectChild> + <ObjectChild key='doubleMember'> + <double/> + </ObjectChild> + <ObjectChild key='boolMember'> + <bool/> + </ObjectChild> + <ObjectChild key='subsubMember'> + <armarx::component_config::aron::SubSubConfig /> + </ObjectChild> + </Object> + + <Object name='armarx::component_config::aron::TestConfig'> + <ObjectChild key='stringMember'> + <string/> + </ObjectChild> + <ObjectChild key='intMember'> + <int/> + </ObjectChild> + <ObjectChild key='floatMember'> + <float/> + </ObjectChild> + <ObjectChild key='longMember'> + <long/> + </ObjectChild> + <ObjectChild key='boolMember'> + <bool/> + </ObjectChild> + <ObjectChild key='subMember'> + <armarx::component_config::aron::SubConfig /> + </ObjectChild> + <ObjectChild key='position'> + <framedposition /> + </ObjectChild> + <ObjectChild key='pose'> + <framedpose /> + </ObjectChild> + <ObjectChild key='orientation'> + <framedorientation /> + </ObjectChild> + </Object> + </GenerateTypes> +</AronTypeDefinition> diff --git a/source/RobotAPI/components/ArticulatedObjectLocalizerExample/ArticulatedObjectLocalizerExample.cpp b/source/RobotAPI/components/ArticulatedObjectLocalizerExample/ArticulatedObjectLocalizerExample.cpp index 8e172a97d95ed3ce515743a877c8c5bb3ed168d1..77943d887c6833b87a730b1ce45b926273795ad2 100644 --- a/source/RobotAPI/components/ArticulatedObjectLocalizerExample/ArticulatedObjectLocalizerExample.cpp +++ b/source/RobotAPI/components/ArticulatedObjectLocalizerExample/ArticulatedObjectLocalizerExample.cpp @@ -32,29 +32,25 @@ #include <VirtualRobot/VirtualRobot.h> #include <VirtualRobot/XML/RobotIO.h> -#include <ArmarXCore/core/services/tasks/PeriodicTask.h> #include <ArmarXCore/core/PackagePath.h> #include <ArmarXCore/core/exceptions/local/ExpressionException.h> #include <ArmarXCore/core/logging/Logging.h> -#include <ArmarXCore/core/system/ArmarXDataPath.h> +#include <ArmarXCore/core/services/tasks/PeriodicTask.h> #include <ArmarXCore/core/time/CycleUtil.h> -#include <RobotAPI/libraries/armem/client/query/Builder.h> -#include <RobotAPI/libraries/armem/client/query/query_fns.h> #include <RobotAPI/libraries/armem/core/Time.h> -#include <RobotAPI/libraries/armem/core/wm/ice_conversions.h> -#include <RobotAPI/libraries/armem/server/MemoryRemoteGui.h> #include <RobotAPI/libraries/armem_objects/types.h> namespace armarx::articulated_object { - ArticulatedObjectLocalizerExample::ArticulatedObjectLocalizerExample() : - articulatedObjectWriter(new ::armarx::armem::articulated_object::ArticulatedObjectWriter(memoryNameSystem())), - articulatedObjectReader(new ::armarx::armem::articulated_object::ArticulatedObjectReader(memoryNameSystem())) + ArticulatedObjectLocalizerExample::ArticulatedObjectLocalizerExample() { + addPlugin(articulatedObjectReaderPlugin); + addPlugin(articulatedObjectWriterPlugin); } - armarx::PropertyDefinitionsPtr ArticulatedObjectLocalizerExample::createPropertyDefinitions() + armarx::PropertyDefinitionsPtr + ArticulatedObjectLocalizerExample::createPropertyDefinitions() { armarx::PropertyDefinitionsPtr defs = new ComponentPropertyDefinitions(getConfigIdentifier()); @@ -63,60 +59,74 @@ namespace armarx::articulated_object defs->optional(p.updateFrequency, "updateFrequency", "Memory update frequency (write)."); - // Reader will override some properties of writer. - articulatedObjectWriter->registerPropertyDefinitions(defs); - articulatedObjectReader->registerPropertyDefinitions(defs); + defs->optional(p.obj.dataset, "p.obj.dataset", ""); + defs->optional(p.obj.className, "p.obj.class", ""); + return defs; } - std::string ArticulatedObjectLocalizerExample::getDefaultName() const + std::string + ArticulatedObjectLocalizerExample::getDefaultName() const { return "ArticulatedObjectLocalizerExample"; } - void ArticulatedObjectLocalizerExample::onInitComponent() + void + ArticulatedObjectLocalizerExample::onInitComponent() { + auto& articulatedObjectReader = articulatedObjectReaderPlugin->get(); + auto& articulatedObjectWriter = articulatedObjectWriterPlugin->get(); + // Reader overwrote property registered property of articulatedObjectWriter. - articulatedObjectWriter->setProviderName(articulatedObjectReader->getProviderName()); + articulatedObjectWriter.setProviderName(articulatedObjectReader.getProviderName()); } - void ArticulatedObjectLocalizerExample::onConnectComponent() + void + ArticulatedObjectLocalizerExample::onConnectComponent() { - articulatedObjectWriter->connect(); - articulatedObjectReader->connect(); - ARMARX_IMPORTANT << "Running example."; start = armem::Time::Now(); task = new PeriodicTask<ArticulatedObjectLocalizerExample>( - this, &ArticulatedObjectLocalizerExample::run, + this, + &ArticulatedObjectLocalizerExample::run, static_cast<int>(1000.f / p.updateFrequency)); task->start(); } - void ArticulatedObjectLocalizerExample::onDisconnectComponent() + void + ArticulatedObjectLocalizerExample::onDisconnectComponent() { task->stop(); } - void ArticulatedObjectLocalizerExample::onExitComponent() + void + ArticulatedObjectLocalizerExample::onExitComponent() { } - VirtualRobot::RobotPtr ArticulatedObjectLocalizerExample::createDishwasher() + VirtualRobot::RobotPtr + ArticulatedObjectLocalizerExample::createArticulatedObject() { - const std::string dishwasherName = "Kitchen/mobile-dishwasher"; + auto& articulatedObjectReader = articulatedObjectReaderPlugin->get(); + + const std::string dishwasherName = p.obj.dataset + "/" + p.obj.className; - const auto descriptions = articulatedObjectReader->queryDescriptions(armem::Time::Now()); + const auto descriptions = articulatedObjectReader.queryDescriptions(armem::Time::Now()); ARMARX_INFO << "Found " << descriptions.size() << " articulated object descriptions"; + for(const auto& description: descriptions) + { + ARMARX_INFO << "- " << description.name; + } + const auto it = std::find_if( - descriptions.begin(), - descriptions.end(), - [&](const armem::articulated_object::ArticulatedObjectDescription & desc) -> bool - { return desc.name == dishwasherName; }); + descriptions.begin(), + descriptions.end(), + [&](const armem::articulated_object::ArticulatedObjectDescription& desc) -> bool + { return desc.name == dishwasherName; }); if (it == descriptions.end()) { @@ -133,21 +143,21 @@ namespace armarx::articulated_object return nullptr; } - obj->setName("MobileDishwasher0"); - obj->setType(it->name); + obj->setName("0"); // aka instance name + obj->setType(it->name); // aka dataset/class name return obj; } - - void ArticulatedObjectLocalizerExample::run() + void + ArticulatedObjectLocalizerExample::run() { - if (dishwasher == nullptr) + if (articulatedObject == nullptr) { - dishwasher = createDishwasher(); + articulatedObject = createArticulatedObject(); - if (dishwasher == nullptr) // still + if (articulatedObject == nullptr) // still { return; } @@ -156,21 +166,24 @@ namespace armarx::articulated_object ARMARX_DEBUG << "Reporting articulated objects"; const armem::Time now = armem::Time::Now(); - const float t = float((now - start).toSecondsDouble()); + const float t = static_cast<float>((now - start).toSecondsDouble()); // move joints at certain frequency const float k = (1 + std::sin(t / (M_2_PIf32))) / 2; // in [0,1] - const std::map<std::string, float> jointValues + auto jointValues = articulatedObject->getJointValues(); + + for (auto& [name, jointValue] : jointValues) { - {"dishwasher_door_joint", M_PIf32 / 2 * k}, - {"drawer_joint", 350 * k} - }; + const auto node = articulatedObject->getRobotNode(name); + jointValue = node->unscaleJointValue(k, 0, 1); + } - dishwasher->setGlobalPose(simox::math::pose(Eigen::Vector3f(1000, 0, 0))); - dishwasher->setJointValues(jointValues); + articulatedObject->setGlobalPose(simox::math::pose(Eigen::Vector3f(1000, 0, 0))); + articulatedObject->setJointValues(jointValues); - articulatedObjectWriter->storeArticulatedObject(dishwasher, now); + auto& articulatedObjectWriter = articulatedObjectWriterPlugin->get(); + articulatedObjectWriter.storeArticulatedObject(articulatedObject, now); } } // namespace armarx::articulated_object diff --git a/source/RobotAPI/components/ArticulatedObjectLocalizerExample/ArticulatedObjectLocalizerExample.h b/source/RobotAPI/components/ArticulatedObjectLocalizerExample/ArticulatedObjectLocalizerExample.h index d401eed5e741d3d797dfaa8a47f347f4616a53db..384068048dd1ab8d1457065d15873de08ff7b82b 100644 --- a/source/RobotAPI/components/ArticulatedObjectLocalizerExample/ArticulatedObjectLocalizerExample.h +++ b/source/RobotAPI/components/ArticulatedObjectLocalizerExample/ArticulatedObjectLocalizerExample.h @@ -3,17 +3,19 @@ #include <VirtualRobot/VirtualRobot.h> -#include <ArmarXCore/core/services/tasks/PeriodicTask.h> #include <ArmarXCore/core/Component.h> +#include <ArmarXCore/core/services/tasks/PeriodicTask.h> #include <ArmarXCore/interface/observers/ObserverInterface.h> #include <ArmarXCore/util/tasks.h> #include <ArmarXGui/libraries/ArmarXGuiComponentPlugins/LightweightRemoteGuiComponentPlugin.h> -#include <RobotAPI/libraries/armem/core/Time.h> +#include "RobotAPI/libraries/ArmarXObjects/ObjectID.h" +#include "RobotAPI/libraries/armem/client/plugins/ReaderWriterPlugin.h" #include <RobotAPI/interface/armem/mns/MemoryNameSystemInterface.h> #include <RobotAPI/interface/armem/server/MemoryInterface.h> #include <RobotAPI/libraries/armem/client/plugins.h> +#include <RobotAPI/libraries/armem/core/Time.h> #include <RobotAPI/libraries/armem/core/wm/memory_definitions.h> #include <RobotAPI/libraries/armem_objects/client/articulated_object/ArticulatedObjectReader.h> #include <RobotAPI/libraries/armem_objects/client/articulated_object/ArticulatedObjectWriter.h> @@ -53,8 +55,8 @@ namespace armarx::articulated_object void run(); private: - VirtualRobot::RobotPtr createDishwasher(); - std::shared_ptr<VirtualRobot::Robot> dishwasher; + VirtualRobot::RobotPtr createArticulatedObject(); + std::shared_ptr<VirtualRobot::Robot> articulatedObject; /// Reference timestamp for object movement armem::Time start; @@ -63,13 +65,23 @@ namespace armarx::articulated_object armarx::DebugObserverInterfacePrx debugObserver; - std::unique_ptr<::armarx::armem::articulated_object::ArticulatedObjectWriter> articulatedObjectWriter; - std::unique_ptr<::armarx::armem::articulated_object::ArticulatedObjectReader> - articulatedObjectReader; + armem::client::plugins::ReaderWriterPlugin< + ::armarx::armem::articulated_object::ArticulatedObjectWriter>* + articulatedObjectWriterPlugin = nullptr; + + armem::client::plugins::ReaderWriterPlugin< + ::armarx::armem::articulated_object::ArticulatedObjectReader>* + articulatedObjectReaderPlugin = nullptr; struct Properties { float updateFrequency{25.F}; + + struct + { + std::string dataset = "Kitchen"; + std::string className = "mobile-dishwasher"; + } obj; } p; }; diff --git a/source/RobotAPI/components/CMakeLists.txt b/source/RobotAPI/components/CMakeLists.txt index e6d7b93d5fd2260efd3958e2f1bfa9c8834b647f..11908aeda6ade0ff4b46f63d0590c88d007e51c9 100644 --- a/source/RobotAPI/components/CMakeLists.txt +++ b/source/RobotAPI/components/CMakeLists.txt @@ -3,6 +3,7 @@ add_subdirectory(units) add_subdirectory(armem) add_subdirectory(skills) +add_subdirectory(AronComponentConfigExample) add_subdirectory(ArticulatedObjectLocalizerExample) add_subdirectory(ArViz) diff --git a/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.h b/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.h index 9b0bacd5092012472d3f975e1c6d40357ba6594c..da5945c44c7e289081df35385ea7e75184d69c90 100644 --- a/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.h +++ b/source/RobotAPI/components/GamepadControlUnit/GamepadControlUnit.h @@ -31,6 +31,7 @@ #include <RobotAPI/interface/units/HandUnitInterface.h> #include <RobotAPI/interface/components/RobotHealthInterface.h> +#include <RobotAPI/interface/units/PlatformUnitInterface.h> namespace armarx { @@ -129,4 +130,3 @@ namespace armarx }; } - diff --git a/source/RobotAPI/components/RobotState/RobotStateComponent.cpp b/source/RobotAPI/components/RobotState/RobotStateComponent.cpp index 4d4d2399bb3ee5059d9788fb60f61cf23f78c2b0..a17005e6d573ff98accd7b40e9c45376ed8e85c4 100644 --- a/source/RobotAPI/components/RobotState/RobotStateComponent.cpp +++ b/source/RobotAPI/components/RobotState/RobotStateComponent.cpp @@ -38,8 +38,6 @@ #include <ArmarXCore/core/system/ArmarXDataPath.h> #include <ArmarXCore/core/time/TimeUtil.h> -#include <RobotAPI/interface/units/PlatformUnitInterface.h> - using namespace Eigen; using namespace Ice; @@ -72,7 +70,6 @@ namespace armarx defineOptionalProperty<int>("HistoryLength", 10000, "Number of entries in the robot state history").setMin(0); defineOptionalProperty<float>("RobotModelScaling", 1.0f, "Scaling of the robot model"); defineOptionalProperty<std::string>("TopicPrefix", "", "Prefix for the sensor value topic name."); - defineOptionalProperty<std::string>("PlatformTopicName", "PlatformState", "Topic where platform state is published."); defineOptionalProperty<std::string>("GlobalRobotPoseLocalizationTopicName", "GlobalRobotPoseLocalization", "Topic where the global robot pose can be reported."); } @@ -149,7 +146,6 @@ namespace armarx usingTopic(topicPrefix + robotNodeSetName + "State"); usingTopic(topicPrefix + getProperty<std::string>("GlobalRobotPoseLocalizationTopicName").getValue()); - usingTopic(topicPrefix + getProperty<std::string>("PlatformTopicName").getValue()); try { @@ -692,39 +688,4 @@ namespace armarx return Timestamped<FramedPosePtr> {time, new FramedPose(globalPose, armarx::GlobalFrame, "")}; } - - // legacy - void RobotStateComponent::reportPlatformPose(const PlatformPose& currentPose, const Current&) - { - const float z = 0; - const Eigen::Vector3f position(currentPose.x, currentPose.y, z); - const Eigen::Matrix3f orientation = - Eigen::AngleAxisf(currentPose.rotationAroundZ, Eigen::Vector3f::UnitZ()).toRotationMatrix(); - const Eigen::Matrix4f globalPose = math::Helpers::Pose(position, orientation); - - IceUtil::Time time = IceUtil::Time::microSeconds(currentPose.timestampInMicroSeconds); - // ARMARX_IMPORTANT << VAROUT(currentPose.timestampInMicroSeconds); - - TransformStamped stamped; - stamped.header.frame = armarx::GlobalFrame; - stamped.header.agent = _synchronized->getName(); - stamped.header.timestampInMicroSeconds = time.toMicroSeconds(); - stamped.header.parentFrame = ""; - stamped.transform = globalPose; - - this->reportGlobalRobotPose(stamped); - - /* - * old: - insertPose(time, globalPose); - - if (_sharedRobotServant) - { - _sharedRobotServant->setTimestamp(time); - } - */ - } - - - } diff --git a/source/RobotAPI/components/RobotState/RobotStateComponent.h b/source/RobotAPI/components/RobotState/RobotStateComponent.h index 685567a476bd7ecfd8d97981fa2cc205d53c43bd..d786dd0d67efc4b5e8fe07e02bef4f4b370588da 100644 --- a/source/RobotAPI/components/RobotState/RobotStateComponent.h +++ b/source/RobotAPI/components/RobotState/RobotStateComponent.h @@ -59,7 +59,7 @@ namespace armarx /** * \defgroup Component-RobotStateComponent RobotStateComponent * \ingroup RobotAPI-Components - * \brief Maintains a robot representation based on VirtualRobot (see [Simox](http://gitlab.com/Simox/simox)). + * \brief Maintains a robot representation based on VirtualRobot (see [Simox](https://git.h2t.iar.kit.edu/sw/simox/simox)). * * The robot can be loaded from a Simox robot XML file. * Upon request, an Ice proxy to a shared instance of this internal robot @@ -128,20 +128,6 @@ namespace armarx void setRobotStateObserver(RobotStateObserverPtr observer); - - // PlatformUnitListener interface - // TODO: Remove this interface and use GlobalRobotPoseLocalizationListener only. - /// Stores the platform pose in the pose history. - void reportPlatformPose(const PlatformPose& currentPose, const Ice::Current& = Ice::emptyCurrent) override; - /// Does nothing. - void reportNewTargetPose(Ice::Float newPlatformPositionX, Ice::Float newPlatformPositionY, Ice::Float newPlatformRotation, const Ice::Current& = Ice::emptyCurrent) override {} - /// Does nothing. - void reportPlatformVelocity(Ice::Float currentPlatformVelocityX, Ice::Float currentPlatformVelocityY, Ice::Float currentPlatformVelocityRotation, const Ice::Current& = Ice::emptyCurrent) override {} - /// Does nothing. - void reportPlatformOdometryPose(Ice::Float x, Ice::Float y, Ice::Float angle, const Ice::Current& = Ice::emptyCurrent) override {} - - - protected: // Component interface. @@ -239,4 +225,3 @@ namespace armarx }; } - diff --git a/source/RobotAPI/components/armem/addon/LegacyRobotStateMemoryAdapter/LegacyRobotStateMemoryAdapter.cpp b/source/RobotAPI/components/armem/addon/LegacyRobotStateMemoryAdapter/LegacyRobotStateMemoryAdapter.cpp index b82eefe899e35b8e4ef63b538221f6ec0adb9159..b8d85a279c6dc04485b03b4c31ff7e93b16e163c 100644 --- a/source/RobotAPI/components/armem/addon/LegacyRobotStateMemoryAdapter/LegacyRobotStateMemoryAdapter.cpp +++ b/source/RobotAPI/components/armem/addon/LegacyRobotStateMemoryAdapter/LegacyRobotStateMemoryAdapter.cpp @@ -21,6 +21,7 @@ */ #include "LegacyRobotStateMemoryAdapter.h" +#include <SimoxUtility/math/convert/mat3f_to_rpy.h> #include <RobotAPI/libraries/aron/common/aron_conversions.h> #include <RobotAPI/libraries/armem_robot_state/aron/Proprioception.aron.generated.h> @@ -211,17 +212,36 @@ namespace armarx::armem } - void LegacyRobotStateMemoryAdapter::reportPlatformPose(const PlatformPose& p, const Ice::Current &) + // void LegacyRobotStateMemoryAdapter::reportPlatformPose(const PlatformPose& p, const Ice::Current &) + // { + // ARMARX_DEBUG << "Got an update for platform pose"; + // std::lock_guard l(updateMutex); + // update.platformPose = p; + // updateTimestamps(p.timestampInMicroSeconds); + // } + + void LegacyRobotStateMemoryAdapter::reportGlobalRobotPose(const ::armarx::TransformStamped& transformStamped, const ::Ice::Current&) { + ARMARX_DEBUG << "Got an update for platform pose"; - std::lock_guard l(updateMutex); - update.platformPose = p; - updateTimestamps(p.timestampInMicroSeconds); - } - void LegacyRobotStateMemoryAdapter::reportNewTargetPose(Ice::Float, Ice::Float, Ice::Float, const Ice::Current &) - { + const Eigen::Isometry3f global_T_robot(transformStamped.transform); + const float yaw = simox::math::mat3f_to_rpy(global_T_robot.linear()).z(); + + armarx::PlatformPose p; + p.x = global_T_robot.translation().x(); + p.y = global_T_robot.translation().y(); + p.rotationAroundZ = yaw; + p.timestampInMicroSeconds = transformStamped.header.timestampInMicroSeconds; + + { + std::lock_guard l(updateMutex); + update.platformPose = p; + updateTimestamps(p.timestampInMicroSeconds); + } } + + void LegacyRobotStateMemoryAdapter::reportPlatformVelocity(Ice::Float f1, Ice::Float f2, Ice::Float f3, const Ice::Current &) { ARMARX_DEBUG << "Got an update for platform vels"; @@ -240,6 +260,8 @@ namespace armarx::armem update.platformOdometryPose = {f1, f2, f3}; updateTimestamps(now); } + + void LegacyRobotStateMemoryAdapter::commitArmar3RobotDescription() { diff --git a/source/RobotAPI/components/armem/addon/LegacyRobotStateMemoryAdapter/LegacyRobotStateMemoryAdapter.h b/source/RobotAPI/components/armem/addon/LegacyRobotStateMemoryAdapter/LegacyRobotStateMemoryAdapter.h index 9680d8c27a1e98e0e70c74308e5235f18bb4b1fc..71ab81f1a3582fafeed767ae7dcfc00f20cf0cad 100644 --- a/source/RobotAPI/components/armem/addon/LegacyRobotStateMemoryAdapter/LegacyRobotStateMemoryAdapter.h +++ b/source/RobotAPI/components/armem/addon/LegacyRobotStateMemoryAdapter/LegacyRobotStateMemoryAdapter.h @@ -59,11 +59,12 @@ namespace armarx::armem void reportJointMotorTemperatures(const NameValueMap&, Ice::Long, bool, const Ice::Current&) override; void reportJointStatuses(const NameStatusMap&, Ice::Long, bool, const Ice::Current&) override; - void reportPlatformPose(const PlatformPose &, const Ice::Current &) override; - void reportNewTargetPose(Ice::Float, Ice::Float, Ice::Float, const Ice::Current &) override; + // void reportPlatformPose(const PlatformPose &, const Ice::Current &) override; void reportPlatformVelocity(Ice::Float, Ice::Float, Ice::Float, const Ice::Current &) override; void reportPlatformOdometryPose(Ice::Float, Ice::Float, Ice::Float, const Ice::Current &) override; + void reportGlobalRobotPose(const ::armarx::TransformStamped&, const ::Ice::Current& = ::Ice::emptyCurrent) override; + protected: /// @see PropertyUser::createPropertyDefinitions() diff --git a/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.cpp b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.cpp index 07f3089ca3acaf5370ca5ff38f3d2f2e3187294e..6fe11f3196b211677110b31dd697a3eb4f055d5d 100644 --- a/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.cpp +++ b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.cpp @@ -32,20 +32,19 @@ #include <RobotAPI/libraries/armem/client/query.h> #include <RobotAPI/libraries/armem/core/Prediction.h> #include <RobotAPI/libraries/armem_objects/aron/ObjectInstance.aron.generated.h> +#include <RobotAPI/libraries/armem_objects/aron/Marker.aron.generated.h> +#include <RobotAPI/libraries/armem_objects/memory_ids.h> namespace armarx::armem::server::obj { - const std::string ObjectMemory::defaultMemoryName = "Object"; - - armarx::PropertyDefinitionsPtr ObjectMemory::createPropertyDefinitions() { armarx::PropertyDefinitionsPtr defs(new ComponentPropertyDefinitions(getConfigIdentifier())); const std::string prefix = "mem."; - workingMemory().name() = defaultMemoryName; + workingMemory().name() = objects::memoryID.memoryName; classSegment.defineProperties(defs, prefix + "cls."); instance::SegmentAdapter::defineProperties(defs, prefix + "inst."); @@ -67,6 +66,9 @@ namespace armarx::armem::server::obj "Duration of time window into the past to use for predictions" " when requested via the PredictingMemoryInterface (in seconds)."); + defs->optional(p.markerMemoryName, prefix + ".marker.Name", "Marker Memory Name"); + defs->optional(p.maxMarkerHistorySize, prefix + ".marker.maxHistorySize", "Maximum marker memory history size"); + return defs; } @@ -126,6 +128,13 @@ namespace armarx::armem::server::obj { attachmentSegment.init(); }); + + initSegmentWithCatch(p.markerMemoryName, [&]() + { + workingMemory() + .addCoreSegment(p.markerMemoryName, arondto::Marker::ToAronType()) + .setMaxHistorySize(p.maxMarkerHistorySize); + }); } diff --git a/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.h b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.h index 4eb71acf3b9374eff330ae463acc208872a918f2..566d1fec8a6ea1fe39f12edabbaaaa76b08ea9e0 100644 --- a/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.h +++ b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.h @@ -22,8 +22,8 @@ #pragma once -#include "RobotAPI/libraries/armem/client/plugins/ReaderWriterPlugin.h" -#include "RobotAPI/libraries/armem_robot_state/client/common/VirtualRobotReader.h" +#include <RobotAPI/libraries/armem/client/plugins/ReaderWriterPlugin.h> +#include <RobotAPI/libraries/armem_robot_state/client/common/VirtualRobotReader.h> #include <RobotAPI/libraries/armem_objects/server/class/Segment.h> #include <RobotAPI/libraries/armem_objects/server/instance/SegmentAdapter.h> #include <RobotAPI/libraries/armem_objects/server/attachments/Segment.h> @@ -66,11 +66,6 @@ namespace armarx::armem::server::obj , virtual public armarx::LightweightRemoteGuiComponentPluginUser , virtual public armarx::ArVizComponentPluginUser { - public: - - static const std::string defaultMemoryName; - - public: ObjectMemory(); @@ -134,6 +129,12 @@ namespace armarx::armem::server::obj }; std::unique_ptr<RemoteGuiTab> tab; + struct Properties { + int64_t maxMarkerHistorySize = -1; + std::string markerMemoryName = "Marker"; + }; + Properties p; + armem::client::plugins::ReaderWriterPlugin<robot_state::VirtualRobotReader>* virtualRobotReaderPlugin; }; diff --git a/source/RobotAPI/components/armem/server/RobotStateMemory/RobotStateMemory.cpp b/source/RobotAPI/components/armem/server/RobotStateMemory/RobotStateMemory.cpp index 8233df3d685339da7f43c134e588a21324a8ec79..e3f006eaf4a554d13705868eaf812955b2fcfb12 100644 --- a/source/RobotAPI/components/armem/server/RobotStateMemory/RobotStateMemory.cpp +++ b/source/RobotAPI/components/armem/server/RobotStateMemory/RobotStateMemory.cpp @@ -21,13 +21,14 @@ */ #include "RobotStateMemory.h" -#include "RobotAPI/libraries/armem/core/forward_declarations.h" +#include <RobotAPI/libraries/armem/core/forward_declarations.h> #include <RobotAPI/interface/core/PoseBase.h> #include <RobotAPI/libraries/core/Pose.h> #include <RobotAPI/libraries/armem/core/Prediction.h> #include <RobotAPI/libraries/armem_robot_state/server/proprioception/aron_conversions.h> #include <RobotAPI/libraries/armem_robot_state/server/common/Visu.h> +#include <RobotAPI/libraries/armem_robot_state/memory_ids.h> #include <RobotAPI/libraries/RobotAPIComponentPlugins/RobotUnitComponentPlugin.h> #include <ArmarXCore/core/exceptions/local/ExpressionException.h> @@ -82,7 +83,7 @@ namespace armarx::armem::server::robot_state const std::string prefix = "mem."; - setMemoryName("RobotState"); + setMemoryName(armem::robot_state::memoryID.memoryName); descriptionSegment.defineProperties(defs, prefix + "desc."); proprioceptionSegment.defineProperties(defs, prefix + "prop."); diff --git a/source/RobotAPI/components/units/PlatformUnit.cpp b/source/RobotAPI/components/units/PlatformUnit.cpp index 83da0bb8486a38a075e10c9c6fae5a273c254f51..a5414a34e838b6fd2268f7bfb26ddc527530624f 100644 --- a/source/RobotAPI/components/units/PlatformUnit.cpp +++ b/source/RobotAPI/components/units/PlatformUnit.cpp @@ -38,7 +38,7 @@ namespace armarx def->topic(odometryPrx); def->topic(globalPosePrx); - // def->topic(listenerPrx, listenerChannelName, ""); + def->topic(listenerPrx, "PlatformState"); def->component(robotStateComponent); @@ -50,17 +50,12 @@ namespace armarx { std::string platformName = getProperty<std::string>("PlatformName").getValue(); - listenerChannelName = platformName + "State"; - offeringTopic(listenerChannelName); - this->onInitPlatformUnit(); } void PlatformUnit::onConnectComponent() { - listenerPrx = getTopic<PlatformUnitListenerPrx>(listenerChannelName); - this->onStartPlatformUnit(); } diff --git a/source/RobotAPI/components/units/PlatformUnit.h b/source/RobotAPI/components/units/PlatformUnit.h index 1b0b9499a4f50e6ec0b64631aaf9f85c9fa5bca5..ee3c2a6999c0ba4f1f9560106f818826162c432f 100644 --- a/source/RobotAPI/components/units/PlatformUnit.h +++ b/source/RobotAPI/components/units/PlatformUnit.h @@ -117,7 +117,7 @@ namespace armarx protected: - std::string listenerChannelName; + // std::string listenerChannelName; /** * PlatformUnitListener proxy for publishing state updates */ diff --git a/source/RobotAPI/components/units/PlatformUnitObserver.cpp b/source/RobotAPI/components/units/PlatformUnitObserver.cpp index d0e0cd8e0162983b77708d5499b60c6e012d71ba..2db1b8dae17b84c6d0ef98fea1129cebd97f9e75 100644 --- a/source/RobotAPI/components/units/PlatformUnitObserver.cpp +++ b/source/RobotAPI/components/units/PlatformUnitObserver.cpp @@ -21,6 +21,8 @@ */ #include "PlatformUnitObserver.h" +#include <Eigen/src/Geometry/Transform.h> +#include <SimoxUtility/math/convert/mat3f_to_rpy.h> #include "PlatformUnit.h" @@ -54,13 +56,13 @@ namespace armarx offerConditionCheck("smaller", new ConditionCheckSmaller()); usingTopic(platformNodeName + "State"); + usingTopic("GlobalRobotPoseLocalization"); } void PlatformUnitObserver::onConnectObserver() { // register all channels offerChannel("platformPose", "Current Position of " + platformNodeName); - offerChannel("targetPose", "Target Position of " + platformNodeName); offerChannel("platformVelocity", "Current velocity of " + platformNodeName); offerChannel("platformOdometryPose", "Current Odometry Position of " + platformNodeName); @@ -69,10 +71,6 @@ namespace armarx offerDataField("platformPose", "positionY", VariantType::Float, "Current Y position of " + platformNodeName + " in mm"); offerDataField("platformPose", "rotation", VariantType::Float, "Current Rotation of " + platformNodeName + " in radian"); - offerDataField("targetPose", "positionX", VariantType::Float, "Target X position of " + platformNodeName + " in mm"); - offerDataField("targetPose", "positionY", VariantType::Float, "Target Y position of " + platformNodeName + " in mm"); - offerDataField("targetPose", "rotation", VariantType::Float, "Target Rotation of " + platformNodeName + " in radian"); - offerDataField("platformVelocity", "velocityX", VariantType::Float, "Current X velocity of " + platformNodeName + " in mm/s"); offerDataField("platformVelocity", "velocityY", VariantType::Float, "Current Y velocity of " + platformNodeName + " in mm/s"); offerDataField("platformVelocity", "velocityRotation", VariantType::Float, "Current Rotation velocity of " + platformNodeName + " in radian/s"); @@ -86,16 +84,16 @@ namespace armarx } - void PlatformUnitObserver::reportPlatformPose(PlatformPose const& currentPose, const Ice::Current& c) + void PlatformUnitObserver::reportGlobalRobotPose(const ::armarx::TransformStamped& transformStamped, const ::Ice::Current&) { - nameValueMapToDataFields("platformPose", currentPose.x, currentPose.y, currentPose.rotationAroundZ); - updateChannel("platformPose"); - } + const Eigen::Isometry3f global_T_robot(transformStamped.transform); + + const float x = global_T_robot.translation().x(); + const float y = global_T_robot.translation().y(); + const float rotationAroundZ = simox::math::mat3f_to_rpy(global_T_robot.linear()).z(); - void PlatformUnitObserver::reportNewTargetPose(::Ice::Float newPlatformPositionX, ::Ice::Float newPlatformPositionY, ::Ice::Float newPlatformRotation, const Ice::Current& c) - { - nameValueMapToDataFields("targetPose", newPlatformPositionX, newPlatformPositionY, newPlatformRotation); - updateChannel("targetPose"); + nameValueMapToDataFields("platformPose", x, y, rotationAroundZ); + updateChannel("platformPose"); } void PlatformUnitObserver::reportPlatformVelocity(::Ice::Float currentPlatformVelocityX, ::Ice::Float currentPlatformVelocityY, ::Ice::Float currentPlatformVelocityRotation, const Ice::Current& c) @@ -128,4 +126,6 @@ namespace armarx nameValueMapToDataFields("platformOdometryPose", x, y, angle); updateChannel("platformOdometryPose"); } + + } diff --git a/source/RobotAPI/components/units/PlatformUnitObserver.h b/source/RobotAPI/components/units/PlatformUnitObserver.h index 66b24989d267e30fb9a6f1ebe3e3f3bfa3a0dced..20cdfefcd7c380eccf2e1144b3d4206b239cf088 100644 --- a/source/RobotAPI/components/units/PlatformUnitObserver.h +++ b/source/RobotAPI/components/units/PlatformUnitObserver.h @@ -25,6 +25,7 @@ #include <ArmarXCore/core/system/ImportExport.h> #include <ArmarXCore/core/Component.h> +#include <RobotAPI/interface/core/RobotLocalization.h> #include <RobotAPI/interface/observers/PlatformUnitObserverInterface.h> #include <ArmarXCore/interface/observers/VariantBase.h> @@ -78,11 +79,13 @@ namespace armarx void onConnectObserver() override; // slice interface implementation - void reportPlatformPose(PlatformPose const& currentPose, const Ice::Current& c = Ice::emptyCurrent) override; - void reportNewTargetPose(::Ice::Float newPlatformPositionX, ::Ice::Float newPlatformPositionY, ::Ice::Float newPlatformRotation, const Ice::Current& c = Ice::emptyCurrent) override; void reportPlatformVelocity(::Ice::Float currentPlatformVelocityX, ::Ice::Float currentPlatformVelocityY, ::Ice::Float currentPlatformVelocityRotation, const Ice::Current& c = Ice::emptyCurrent) override; void reportPlatformOdometryPose(Ice::Float x, Ice::Float y, Ice::Float angle, const Ice::Current&) override; + // slice interface implementation + void reportGlobalRobotPose(const ::armarx::TransformStamped&, const ::Ice::Current& = ::Ice::emptyCurrent) override; + + std::string getDefaultName() const override { return "PlatformUnitObserver"; @@ -143,6 +146,5 @@ namespace armarx namespace armarx::channels::PlatformUnitObserver { const PlatformUnitDatafieldCreator platformPose("platformPose"); - const PlatformUnitDatafieldCreator targetPose("targetPose"); const PlatformUnitDatafieldCreator platformVelocity("platformVelocity"); } diff --git a/source/RobotAPI/components/units/PlatformUnitSimulation.cpp b/source/RobotAPI/components/units/PlatformUnitSimulation.cpp index 3c9cde6b67a1106976beee9032795262755a4be3..6abaa676025df57bbfbbde4f61ad147ac54e97eb 100644 --- a/source/RobotAPI/components/units/PlatformUnitSimulation.cpp +++ b/source/RobotAPI/components/units/PlatformUnitSimulation.cpp @@ -103,8 +103,6 @@ namespace armarx globalPosePrx->reportGlobalRobotPose(currentPose); - // legacy - listenerPrx->reportPlatformPose(toPlatformPose(currentPose)); simulationTask->start(); } @@ -229,8 +227,17 @@ namespace armarx odometryPrx->reportOdometryPose(platformPose); odometryPrx->reportOdometryVelocity(platformVelocity); - // legacy - listenerPrx->reportPlatformPose(toPlatformPose(platformPose)); + { + TransformStamped currentPose; + currentPose.header.parentFrame = GlobalFrame; + currentPose.header.frame = robotRootFrame; + currentPose.header.agent = agentName; + currentPose.header.timestampInMicroSeconds = TimeUtil::GetTime().toMicroSeconds(); + currentPose.transform = currentPlatformPose(); + + globalPosePrx->reportGlobalRobotPose(currentPose); + } + // legacy const auto& velo = platformVelocity.twist; @@ -259,9 +266,6 @@ namespace armarx TransformStamped targetPose; targetPose.header = header; targetPose.transform = VirtualRobot::MathTools::posrpy2eigen4f(targetPositionX, targetPositionY, 0, 0, 0, targetRotation); - - const auto tp = toPlatformPose(targetPose); - listenerPrx->reportNewTargetPose(tp.x, tp.y, tp.rotationAroundZ); } void armarx::PlatformUnitSimulation::move(float targetPlatformVelocityX, float targetPlatformVelocityY, float targetPlatformVelocityRotation, const Ice::Current& c) diff --git a/source/RobotAPI/components/units/RobotUnit/Units/PlatformSubUnit.h b/source/RobotAPI/components/units/RobotUnit/Units/PlatformSubUnit.h index 24f8ac9db2bd10eb6c9e8e7e2f36ac75931a69e0..93ea9a009c91a8c46b2c96ac0ac4917d0fb36850 100755 --- a/source/RobotAPI/components/units/RobotUnit/Units/PlatformSubUnit.h +++ b/source/RobotAPI/components/units/RobotUnit/Units/PlatformSubUnit.h @@ -61,7 +61,6 @@ namespace armarx // PlatformUnit interface void onInitPlatformUnit() override { - usingTopic("PlatformState"); } void onStartPlatformUnit() override { diff --git a/source/RobotAPI/gui-plugins/PlatformUnitPlugin/PlatformUnitGuiPlugin.cpp b/source/RobotAPI/gui-plugins/PlatformUnitPlugin/PlatformUnitGuiPlugin.cpp index 132f0b639df824fe91a3b6bd9f25427f50950d7d..a7c2374677fde81a140b3479a3dd626101d79525 100644 --- a/source/RobotAPI/gui-plugins/PlatformUnitPlugin/PlatformUnitGuiPlugin.cpp +++ b/source/RobotAPI/gui-plugins/PlatformUnitPlugin/PlatformUnitGuiPlugin.cpp @@ -26,6 +26,8 @@ #include <RobotAPI/gui-plugins/PlatformUnitPlugin/ui_PlatformUnitConfigDialog.h> #include <ArmarXCore/core/system/ArmarXDataPath.h> +#include <Eigen/Geometry> + // Qt headers #include <Qt> #include <QtGlobal> @@ -35,6 +37,8 @@ #include <QHBoxLayout> //std +#include <RobotAPI/interface/core/RobotLocalization.h> +#include <SimoxUtility/math/convert/mat3f_to_rpy.h> #include <memory> #include <cmath> @@ -86,8 +90,8 @@ PlatformUnitWidget::PlatformUnitWidget() : void PlatformUnitWidget::onInitComponent() { usingProxy(platformUnitProxyName); - usingTopic(platformName + "State"); - ARMARX_INFO << "Listening on Topic: " << platformName + "State"; + usingTopic("GlobalRobotPoseLocalization"); + // ARMARX_INFO << "Listening on Topic: " << platformName + "State"; } @@ -177,7 +181,6 @@ void PlatformUnitWidget::setNewPlatformPoseLabels(float x, float y, float alpha) ui.labelCurrentPositionX->setText(QString::number(x)); ui.labelCurrentPositionY->setText(QString::number(y)); ui.labelCurrentRotation->setText(QString::number(alpha)); - } @@ -203,26 +206,16 @@ void PlatformUnitWidget::stopControlTimer() } -void PlatformUnitWidget::reportPlatformPose(PlatformPose const& currentPose, const Ice::Current& c) +void PlatformUnitWidget::reportGlobalRobotPose(const ::armarx::TransformStamped& transformStamped, const ::Ice::Current&) { - // moved to qt thread for thread safety - QMetaObject::invokeMethod(this, "setNewPlatformPoseLabels", Q_ARG(float, currentPose.x), Q_ARG(float, currentPose.y), Q_ARG(float, currentPose.rotationAroundZ)); - platformRotation = currentPose.rotationAroundZ; -} + const Eigen::Isometry3f global_T_robot(transformStamped.transform); + const float x = global_T_robot.translation().x(); + const float y = global_T_robot.translation().y(); + const float yaw = simox::math::mat3f_to_rpy(global_T_robot.linear()).z(); - -void PlatformUnitWidget::reportNewTargetPose(::Ice::Float newPlatformPositionX, ::Ice::Float newPlatformPositionY, ::Ice::Float newPlatformRotation, const Ice::Current& c) -{ // moved to qt thread for thread safety - QMetaObject::invokeMethod(this, "setNewTargetPoseLabels", - Q_ARG(float, newPlatformPositionX), - Q_ARG(float, newPlatformPositionY), - Q_ARG(float, newPlatformRotation)); -} - -void PlatformUnitWidget::reportPlatformVelocity(::Ice::Float currentPlatformVelocityX, ::Ice::Float currentPlatformVelocityY, ::Ice::Float currentPlatformVelocityRotation, const Ice::Current& c) -{ - + QMetaObject::invokeMethod(this, "setNewPlatformPoseLabels", Q_ARG(float, x), Q_ARG(float, y), Q_ARG(float, yaw)); + platformRotation = yaw; } @@ -396,9 +389,3 @@ void KeyboardPlatformHookWidget::keyReleaseEvent(QKeyEvent* event) } QWidget::keyReleaseEvent(event); } - - -void armarx::PlatformUnitWidget::reportPlatformOdometryPose(Ice::Float, Ice::Float, Ice::Float, const Ice::Current&) -{ - // ignore for now -} diff --git a/source/RobotAPI/gui-plugins/PlatformUnitPlugin/PlatformUnitGuiPlugin.h b/source/RobotAPI/gui-plugins/PlatformUnitPlugin/PlatformUnitGuiPlugin.h index aeb8e8ce8f414bac77ec83e9e9237679b76873c8..7587750d212e51f88666dffcf236556370b432c3 100644 --- a/source/RobotAPI/gui-plugins/PlatformUnitPlugin/PlatformUnitGuiPlugin.h +++ b/source/RobotAPI/gui-plugins/PlatformUnitPlugin/PlatformUnitGuiPlugin.h @@ -30,6 +30,7 @@ #include <ArmarXGui/libraries/ArmarXGuiBase/ArmarXGuiPlugin.h> #include <ArmarXGui/libraries/ArmarXGuiBase/ArmarXComponentWidgetController.h> +#include <RobotAPI/interface/core/RobotLocalization.h> #include <RobotAPI/interface/units/PlatformUnitInterface.h> /* Qt headers */ @@ -101,7 +102,7 @@ namespace armarx */ class PlatformUnitWidget : public ArmarXComponentWidgetControllerTemplate<PlatformUnitWidget>, - public PlatformUnitListener + public GlobalRobotPoseLocalizationListener { Q_OBJECT public: @@ -116,11 +117,8 @@ namespace armarx void onExitComponent() override; // slice interface implementation - void reportPlatformPose(PlatformPose const& currentPose, const Ice::Current& c = Ice::emptyCurrent) override; - void reportNewTargetPose(::Ice::Float newPlatformPositionX, ::Ice::Float newPlatformPositionY, ::Ice::Float newPlatformRotation, const Ice::Current& c = Ice::emptyCurrent) override; - void reportPlatformVelocity(::Ice::Float currentPlatformVelocityX, ::Ice::Float currentPlatformVelocityY, ::Ice::Float currentPlatformVelocityRotation, const Ice::Current& c = Ice::emptyCurrent) override; - void reportPlatformOdometryPose(Ice::Float, Ice::Float, Ice::Float, const Ice::Current&) override; - + void reportGlobalRobotPose(const ::armarx::TransformStamped& transformStamped, const ::Ice::Current& = ::Ice::emptyCurrent) override; + // inherited of ArmarXWidget static QString GetWidgetName() { @@ -228,4 +226,3 @@ namespace armarx }; using PlatformUnitGuiPluginPtr = std::shared_ptr<PlatformUnitWidget>; } - diff --git a/source/RobotAPI/interface/armem/addon/LegacyRobotStateMemoryAdapterInterface.ice b/source/RobotAPI/interface/armem/addon/LegacyRobotStateMemoryAdapterInterface.ice index ffd72e20c51675c207869ae3c8c66e52b84c77fa..baad0e798bc8a3762ec28ac4394b1a3556e3c576 100644 --- a/source/RobotAPI/interface/armem/addon/LegacyRobotStateMemoryAdapterInterface.ice +++ b/source/RobotAPI/interface/armem/addon/LegacyRobotStateMemoryAdapterInterface.ice @@ -2,6 +2,7 @@ #include <RobotAPI/interface/units/KinematicUnitInterface.ice> #include <RobotAPI/interface/units/PlatformUnitInterface.ice> +#include <RobotAPI/interface/core/RobotLocalization.ice> module armarx { @@ -9,7 +10,7 @@ module armarx { module robot_state { - interface LegacyRobotStateMemoryAdapterInterface extends armarx::KinematicUnitListener, armarx::PlatformUnitListener + interface LegacyRobotStateMemoryAdapterInterface extends armarx::KinematicUnitListener, armarx::PlatformUnitListener, armarx::GlobalRobotPoseLocalizationListener { } } diff --git a/source/RobotAPI/interface/core/RobotState.ice b/source/RobotAPI/interface/core/RobotState.ice index a80b9b22c09d331e30f726dfb751c45543319fc5..6b6ad3bd501a57603a8da4226cd92e7f59ba1796 100644 --- a/source/RobotAPI/interface/core/RobotState.ice +++ b/source/RobotAPI/interface/core/RobotState.ice @@ -24,13 +24,14 @@ #pragma once #include <ArmarXCore/interface/events/SimulatorResetEvent.ice> -#include <RobotAPI/interface/units/KinematicUnitInterface.ice> -#include <RobotAPI/interface/units/PlatformUnitInterface.ice> -#include <RobotAPI/interface/core/FramedPoseBase.ice> - #include <ArmarXCore/interface/observers/Timestamp.ice> #include <ArmarXCore/interface/core/BasicTypes.ice> #include <ArmarXCore/interface/serialization/Eigen.ice> + +#include <RobotAPI/interface/units/KinematicUnitInterface.ice> +#include <RobotAPI/interface/core/FramedPoseBase.ice> +#include <RobotAPI/interface/core/RobotLocalization.ice> + #include <Ice/BuiltinSequences.ice> module armarx @@ -188,7 +189,6 @@ module armarx */ interface RobotStateComponentInterface extends KinematicUnitListener, - PlatformUnitListener, GlobalRobotPoseLocalizationListener, SimulatorResetEvent { diff --git a/source/RobotAPI/interface/observers/PlatformUnitObserverInterface.ice b/source/RobotAPI/interface/observers/PlatformUnitObserverInterface.ice index e7eddd170418f8ed671695807e3817e0522bf1da..20709f1fedeb65bb3766d2008607ee750a74965a 100644 --- a/source/RobotAPI/interface/observers/PlatformUnitObserverInterface.ice +++ b/source/RobotAPI/interface/observers/PlatformUnitObserverInterface.ice @@ -26,10 +26,11 @@ #include <ArmarXCore/interface/observers/ObserverInterface.ice> +#include <RobotAPI/interface/core/RobotLocalization.ice> + module armarx { - interface PlatformUnitObserverInterface extends ObserverInterface, PlatformUnitListener + interface PlatformUnitObserverInterface extends ObserverInterface, PlatformUnitListener, GlobalRobotPoseLocalizationListener { }; }; - diff --git a/source/RobotAPI/interface/units/PlatformUnitInterface.ice b/source/RobotAPI/interface/units/PlatformUnitInterface.ice index f7f62d13d0b490fd50284582096e0308fff90223..f83ad97cf10f83c8975a8c79f1b44deecd594d4e 100644 --- a/source/RobotAPI/interface/units/PlatformUnitInterface.ice +++ b/source/RobotAPI/interface/units/PlatformUnitInterface.ice @@ -24,22 +24,22 @@ #pragma once -#include <RobotAPI/interface/units/UnitInterface.ice> - -#include <ArmarXCore/interface/core/UserException.ice> #include <ArmarXCore/interface/core/BasicTypes.ice> +#include <ArmarXCore/interface/core/UserException.ice> + #include <RobotAPI/interface/core/GeometryBase.ice> #include <RobotAPI/interface/core/RobotLocalization.ice> +#include <RobotAPI/interface/units/UnitInterface.ice> module armarx -{ - /** +{ + /** * Implements an interface to an PlatformUnit. **/ interface PlatformUnitInterface extends SensorActorUnitInterface { - /** + /** * moveTo moves the platform to a global pose specified by: * @param targetPlatformPositionX Global x-coordinate of target position. * @param targetPlatformPositionY Global y-coordinate of target position. @@ -47,14 +47,20 @@ module armarx * @param postionalAccuracy Platform stops translating if distance to target position gets lower than this threshhold. * @param orientationalAccuracy Platform stops rotating if distance from current to target orientation gets lower than this threshhold. **/ - void moveTo(float targetPlatformPositionX, float targetPlatformPositionY, float targetPlatformRotation, float positionalAccuracy, float orientationalAccuracy); + void moveTo(float targetPlatformPositionX, + float targetPlatformPositionY, + float targetPlatformRotation, + float positionalAccuracy, + float orientationalAccuracy); /** * move moves the platform with given velocities. * @param targetPlatformVelocityX x-coordinate of target velocity defined in platform root. * @param targetPlatformVelocityY y-coordinate of target velocity defined in platform root. * @param targetPlatformVelocityRotation Target orientational velocity defined in platform root. **/ - void move(float targetPlatformVelocityX, float targetPlatformVelocityY, float targetPlatformVelocityRotation); + void move(float targetPlatformVelocityX, + float targetPlatformVelocityY, + float targetPlatformVelocityRotation); /** * moveRelative moves to a pose defined in platform coordinates. * @param targetPlatformOffsetX x-coordinate of target position defined in platform root. @@ -63,7 +69,11 @@ module armarx * @param postionalAccuracy Platform stops translating if distance to target position gets lower than this threshhold. * @param orientationalAccuracy Platform stops rotating if distance from current to target orientation gets lower than this threshhold. **/ - void moveRelative(float targetPlatformOffsetX, float targetPlatformOffsetY, float targetPlatformOffsetRotation, float positionalAccuracy, float orientationalAccuracy); + void moveRelative(float targetPlatformOffsetX, + float targetPlatformOffsetY, + float targetPlatformOffsetRotation, + float positionalAccuracy, + float orientationalAccuracy); /** * setMaxVelocities allows to specify max velocities in translation and orientation. * @param positionalVelocity Max translation velocity. @@ -84,42 +94,28 @@ module armarx float rotationAroundZ = 0.0f; }; - /** + /** * Implements an interface to an PlatformUnitListener. **/ interface PlatformUnitListener { /** - * reportPlatformPose reports current platform pose. - * @param currentPose Current global platform pose. - **/ - ["deprecate:reportPlatformPose() has been deprecated, use GlobalRobotPoseLocalizationListener::reportGlobalRobotPose() instead."] - void reportPlatformPose(PlatformPose currentPose); - - /** - * reportNewTargetPose reports target platform pose. - * @param newPlatformPositionX Global x-coordinate of target platform position. - * @param newPlatformPositionY Global y-coordinate of target platform position. - * @param newPlatformRotation Target global orientation of platform. - **/ - ["deprecate:reportNewTargetPose() has been deprecated, use ... instead."] - void reportNewTargetPose(float newPlatformPositionX, float newPlatformPositionY, float newPlatformRotation); - /** - * reportPlatformVelocity reports current platform velocities. - * @param currentPlatformVelocityX x-coordinate of current velocity defined in platform root. - * @param currentPlatformVelocityY y-coordinate of current velocity defined in platform root. - * @param currentPlatformVelocityRotation Current orientational velocity defined in platform root. - **/ - // ["deprecate:reportPlatformVelocity() has been deprecated, use OdometryListener::reportOdometryVelocity() instead."] - void reportPlatformVelocity(float currentPlatformVelocityX, float currentPlatformVelocityY, float currentPlatformVelocityRotation); + * reportPlatformVelocity reports current platform velocities. + * @param currentPlatformVelocityX x-coordinate of current velocity defined in platform root. + * @param currentPlatformVelocityY y-coordinate of current velocity defined in platform root. + * @param currentPlatformVelocityRotation Current orientational velocity defined in platform root. + **/ + // ["deprecate:reportPlatformVelocity() has been deprecated, use OdometryListener::reportOdometryVelocity() instead."] + void reportPlatformVelocity(float currentPlatformVelocityX, + float currentPlatformVelocityY, + float currentPlatformVelocityRotation); - ["deprecate:reportPlatformOdometryPose() has been deprecated, use OdometryListener::reportOdometryPose() instead."] - void reportPlatformOdometryPose(float x, float y, float angle); + ["deprecate:reportPlatformOdometryPose() has been deprecated, use " + "OdometryListener::reportOdometryPose() instead."] void + reportPlatformOdometryPose(float x, float y, float angle); }; interface PlatformSubUnitInterface extends PlatformUnitInterface { - }; - }; diff --git a/source/RobotAPI/libraries/ArmarXObjects/ObjectFinder.h b/source/RobotAPI/libraries/ArmarXObjects/ObjectFinder.h index ea3a7e9cb08f423716931086f309e6dabeedd1b9..708608528cd8d506d80f229a6c9c96896d18207a 100644 --- a/source/RobotAPI/libraries/ArmarXObjects/ObjectFinder.h +++ b/source/RobotAPI/libraries/ArmarXObjects/ObjectFinder.h @@ -18,8 +18,7 @@ namespace armarx /** * @brief Used to find objects in the ArmarX objects repository [1] (formerly [2]). * - * @see [1] https://gitlab.com/ArmarX/PriorKnowledgeData - * @see [2] https://gitlab.com/ArmarX/ArmarXObjects + * @see [1] https://git.h2t.iar.kit.edu/sw/armarx/prior-knowledge-data */ class ObjectFinder : Logging { diff --git a/source/RobotAPI/libraries/CMakeLists.txt b/source/RobotAPI/libraries/CMakeLists.txt index 099ad8b4b981aeed1cc9e274c25672a1014ee120..186941026aeb48777acad71d3a3ef969b858dc98 100644 --- a/source/RobotAPI/libraries/CMakeLists.txt +++ b/source/RobotAPI/libraries/CMakeLists.txt @@ -16,10 +16,12 @@ add_subdirectory(natik) add_subdirectory(ukfm) add_subdirectory(aron) +add_subdirectory(aron_component_config) add_subdirectory(armem) add_subdirectory(armem_grasping) add_subdirectory(armem_gui) +add_subdirectory(armem_locations) add_subdirectory(armem_motions) add_subdirectory(armem_mps) add_subdirectory(armem_objects) diff --git a/source/RobotAPI/libraries/armem/server/ltm/disk/EntitySnapshot.cpp b/source/RobotAPI/libraries/armem/server/ltm/disk/EntitySnapshot.cpp index 4d24c2e6bd15c0696bbbefd757db1fc4a895dbde..72ed4653638d77adf1c1dc760354c8dcf12d43d3 100644 --- a/source/RobotAPI/libraries/armem/server/ltm/disk/EntitySnapshot.cpp +++ b/source/RobotAPI/libraries/armem/server/ltm/disk/EntitySnapshot.cpp @@ -19,7 +19,7 @@ namespace armarx::armem::server::ltm::disk / EscapeSegmentName(id.providerSegmentName) / EscapeSegmentName(id.entityName) / std::to_string(id.timestamp.toSecondsSinceEpoch() / 3600 /* hours */) - / std::to_string(id.timestamp.toSecondsSinceEpoch()) / id.timestampStr()), + / std::to_string(id.timestamp.toSecondsSinceEpoch()) /* seconds */ / id.timestampStr()), currentMode(mode), currentExport(e) { diff --git a/source/RobotAPI/libraries/armem/server/wm/detail/Prediction.h b/source/RobotAPI/libraries/armem/server/wm/detail/Prediction.h index a438226d6f865764810a18cba5617f4d1288e696..3b2eccc022514313ceb0aaea7154e5c77258ea79 100644 --- a/source/RobotAPI/libraries/armem/server/wm/detail/Prediction.h +++ b/source/RobotAPI/libraries/armem/server/wm/detail/Prediction.h @@ -283,7 +283,7 @@ namespace armarx::armem::server::wm::detail // Get iterator to first entry of child ID (memory). std::vector<std::string> childItems = child.getItems(); - size_t index = parentLength; + int index = parentLength; ARMARX_CHECK_FITS_SIZE(index, childItems.size()); return childItems[index]; diff --git a/source/RobotAPI/libraries/armem_grasping/server/KnownGraspProviderSegment.cpp b/source/RobotAPI/libraries/armem_grasping/server/KnownGraspProviderSegment.cpp index f1ad93a2c87396e2f178d2ed522d39dcd7de95b9..708144660674c9e874cc82d83ffa9e5779cd9d83 100644 --- a/source/RobotAPI/libraries/armem_grasping/server/KnownGraspProviderSegment.cpp +++ b/source/RobotAPI/libraries/armem_grasping/server/KnownGraspProviderSegment.cpp @@ -66,9 +66,10 @@ namespace armarx::armem::grasping::segment retGrasp.quality = std::stof(graspNode.attribute_value("quality")); retGrasp.creator = graspNode.attribute_value("Creation"); - ARMARX_CHECK_EQUAL(graspNode.nodes().size(), 1); + ARMARX_CHECK(graspNode.nodes().size() == 2 or graspNode.nodes().size() == 1); RapidXmlReaderNode transformNode = graspNode.nodes()[0]; + ARMARX_CHECK_EQUAL(transformNode.name(), "Transform"); ARMARX_CHECK_EQUAL(transformNode.nodes().size(), 1); RapidXmlReaderNode matrixNode = transformNode.nodes()[0]; diff --git a/source/RobotAPI/libraries/armem_locations/CMakeLists.txt b/source/RobotAPI/libraries/armem_locations/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..22d418142d784080f8f4f99410a25a272d5c628f --- /dev/null +++ b/source/RobotAPI/libraries/armem_locations/CMakeLists.txt @@ -0,0 +1,30 @@ +set(LIB_NAME armem_locations) + +armarx_component_set_name("${LIB_NAME}") +armarx_set_target("Library: ${LIB_NAME}") + +armarx_add_library( + LIBS + ArmarXCoreInterfaces + ArmarXCore + ArmarXCoreObservers + + RobotAPI::Core + RobotAPI::armem + # aronjsonconverter + SOURCES + ./aron_conversions.cpp + + HEADERS + ./aron_conversions.h +) + +armarx_enable_aron_file_generation_for_target( + TARGET_NAME + "${LIB_NAME}" + ARON_FILES + aron/Location.xml +) + + +add_library(RobotAPI::armem_locations ALIAS armem_locations) diff --git a/source/RobotAPI/libraries/armem_locations/aron/Location.xml b/source/RobotAPI/libraries/armem_locations/aron/Location.xml new file mode 100644 index 0000000000000000000000000000000000000000..9a0539d5d40a3b3b91dc32ad2034077a815437ff --- /dev/null +++ b/source/RobotAPI/libraries/armem_locations/aron/Location.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<AronTypeDefinition> + <CodeIncludes> + </CodeIncludes> + <AronIncludes> + <Include include="<RobotAPI/libraries/armem/aron/MemoryID.xml>" autoinclude="true"/> + </AronIncludes> + + <GenerateTypes> + + <!-- + ToDo: Model regions. Ideas: + - Polygon (convex, non-convex) + - + --> + + + <Object name='armarx::navigation::location::arondto::ObjectRelativeLocation'> + + <ObjectChild key='objectInstanceID'> + <armarx::armem::arondto::MemoryID /> + </ObjectChild> + + <ObjectChild key='relativeRobotPose'> + <Pose /> + </ObjectChild> + + </Object> + + + <Object name='armarx::navigation::location::arondto::Location'> + + <ObjectChild key='globalRobotPose'> + <Pose /> + </ObjectChild> + + <ObjectChild key='relativeToObject'> + <armarx::navigation::location::arondto::ObjectRelativeLocation optional="true" /> + </ObjectChild> + + </Object> + + </GenerateTypes> +</AronTypeDefinition> diff --git a/source/RobotAPI/libraries/armem_locations/aron_conversions.cpp b/source/RobotAPI/libraries/armem_locations/aron_conversions.cpp new file mode 100644 index 0000000000000000000000000000000000000000..50ef19ce29d8432970e47071ac3dc4358cef6745 --- /dev/null +++ b/source/RobotAPI/libraries/armem_locations/aron_conversions.cpp @@ -0,0 +1,6 @@ +#include "aron_conversions.h" + +namespace armarx::armem +{ + +} diff --git a/source/RobotAPI/libraries/armem_locations/aron_conversions.h b/source/RobotAPI/libraries/armem_locations/aron_conversions.h new file mode 100644 index 0000000000000000000000000000000000000000..93e57fbcecc4f1e8347559d300a7a9272b24555b --- /dev/null +++ b/source/RobotAPI/libraries/armem_locations/aron_conversions.h @@ -0,0 +1,7 @@ +#pragma once + + +namespace armarx::armem +{ + +} diff --git a/source/RobotAPI/libraries/armem_objects/CMakeLists.txt b/source/RobotAPI/libraries/armem_objects/CMakeLists.txt index ac67c9ad6cc34d051144df93def583c94ce63187..63da8444d40d90e6c4e73a1a4fd755082f4914f9 100644 --- a/source/RobotAPI/libraries/armem_objects/CMakeLists.txt +++ b/source/RobotAPI/libraries/armem_objects/CMakeLists.txt @@ -20,6 +20,9 @@ armarx_add_library( HEADERS aron_conversions.h aron_forward_declarations.h + memory_ids.h + types.h + utils.h server/class/FloorVis.h server/class/Segment.h @@ -48,6 +51,9 @@ armarx_add_library( SOURCES aron_conversions.cpp + memory_ids.cpp + types.cpp + utils.cpp client/articulated_object/Reader.cpp client/articulated_object/Writer.cpp @@ -67,6 +73,8 @@ armarx_add_library( aron/Attachment.xml # aron/Constraint.xml + + aron/Marker.xml ) diff --git a/source/RobotAPI/libraries/armem_objects/aron/Marker.xml b/source/RobotAPI/libraries/armem_objects/aron/Marker.xml new file mode 100644 index 0000000000000000000000000000000000000000..0fa6542098e8d8d6542845927564a5026e192de7 --- /dev/null +++ b/source/RobotAPI/libraries/armem_objects/aron/Marker.xml @@ -0,0 +1,32 @@ +<!-- +Core segment type of Object/Marker +--> +<?xml version="1.0" encoding="UTF-8" ?> +<AronTypeDefinition> + <AronIncludes> + <Include include="<RobotAPI/libraries/aron/common/aron/framed.xml>" autoinclude="true" /> + </AronIncludes> + <GenerateTypes> + <Object name="armarx::armem::arondto::Marker"> + <ObjectChild key="name"> + <String /> + </ObjectChild> + <ObjectChild key="markerPose"> + <armarx::arondto::FramedPose /> + </ObjectChild> + <ObjectChild key="markerGlobal"> + <armarx::arondto::FramedPose /> + </ObjectChild> + <ObjectChild key="robotGlobal"> + <armarx::arondto::FramedPose /> + </ObjectChild> + <ObjectChild key="rgbCamera"> + <armarx::arondto::FramedPose /> + </ObjectChild> + <ObjectChild key="depthCamera"> + <armarx::arondto::FramedPose /> + </ObjectChild> + </Object> + </GenerateTypes> +</AronTypeDefinition> + diff --git a/source/RobotAPI/libraries/armem_objects/aron_conversions.cpp b/source/RobotAPI/libraries/armem_objects/aron_conversions.cpp index 8602178224b696fdcf026f50184628ee7a870dae..23b84e31aef6972059feb8cdf26f75fe3d4271ab 100644 --- a/source/RobotAPI/libraries/armem_objects/aron_conversions.cpp +++ b/source/RobotAPI/libraries/armem_objects/aron_conversions.cpp @@ -1,50 +1,55 @@ #include "aron_conversions.h" #include <RobotAPI/libraries/ArmarXObjects/aron_conversions.h> - -#include <RobotAPI/libraries/aron/common/aron_conversions.h> #include <RobotAPI/libraries/armem/core/aron_conversions.h> +#include <RobotAPI/libraries/aron/common/aron_conversions.h> namespace armarx::armem { - void fromAron(const arondto::ObjectInstance& dto, - objpose::arondto::ObjectPose& bo) + void + fromAron(const arondto::ObjectInstance& dto, objpose::arondto::ObjectPose& bo) { bo = dto.pose; } - void toAron(arondto::ObjectInstance& dto, const objpose::arondto::ObjectPose& bo) + void + toAron(arondto::ObjectInstance& dto, const objpose::arondto::ObjectPose& bo) { dto.pose = bo; } - void fromAron(const arondto::ObjectInstance& dto, objpose::ObjectPose& bo) + void + fromAron(const arondto::ObjectInstance& dto, objpose::ObjectPose& bo) { objpose::fromAron(dto.pose, bo); } - void toAron(arondto::ObjectInstance& dto, const objpose::ObjectPose& bo) + void + toAron(arondto::ObjectInstance& dto, const objpose::ObjectPose& bo) { objpose::toAron(dto.pose, bo); } /* Attachments */ - void fromAron(const arondto::attachment::AgentDescription& dto, attachment::AgentDescription& bo) + void + fromAron(const arondto::attachment::AgentDescription& dto, attachment::AgentDescription& bo) { fromAron(dto.id, bo.id); aron::fromAron(dto.frame, bo.frame); } - void toAron(arondto::attachment::AgentDescription& dto, const attachment::AgentDescription& bo) + void + toAron(arondto::attachment::AgentDescription& dto, const attachment::AgentDescription& bo) { toAron(dto.id, bo.id); aron::toAron(dto.frame, bo.frame); } - void fromAron(const arondto::attachment::ObjectAttachment& dto, attachment::ObjectAttachment& bo) + void + fromAron(const arondto::attachment::ObjectAttachment& dto, attachment::ObjectAttachment& bo) { fromAron(dto.agent, bo.agent); aron::fromAron(dto.transformation, bo.transformation); @@ -53,7 +58,8 @@ namespace armarx::armem // TODO aron::fromAron(dto.timestamp, bo.timestamp); } - void toAron(arondto::attachment::ObjectAttachment& dto, const attachment::ObjectAttachment& bo) + void + toAron(arondto::attachment::ObjectAttachment& dto, const attachment::ObjectAttachment& bo) { toAron(dto.agent, bo.agent); aron::toAron(dto.transformation, bo.transformation); @@ -63,7 +69,9 @@ namespace armarx::armem } - void fromAron(const arondto::attachment::ArticulatedObjectAttachment& dto, attachment::ArticulatedObjectAttachment& bo) + void + fromAron(const arondto::attachment::ArticulatedObjectAttachment& dto, + attachment::ArticulatedObjectAttachment& bo) { fromAron(dto.agent, bo.agent); aron::fromAron(dto.transformation, bo.transformation); @@ -72,7 +80,9 @@ namespace armarx::armem // TODO aron::fromAron(dto.timestamp, bo.timestamp); } - void toAron(arondto::attachment::ArticulatedObjectAttachment& dto, const attachment::ArticulatedObjectAttachment& bo) + void + toAron(arondto::attachment::ArticulatedObjectAttachment& dto, + const attachment::ArticulatedObjectAttachment& bo) { toAron(dto.agent, bo.agent); aron::toAron(dto.transformation, bo.transformation); @@ -81,16 +91,34 @@ namespace armarx::armem // TODO aron::toAron(dto.timestamp, bo.timestamp); } + void + toAron(arondto::Marker& dto, const marker::Marker& bo) + { + dto.name = bo.name; + dto.robotGlobal = bo.robotGlobal; + dto.rgbCamera = bo.rgbCamera; + dto.depthCamera = bo.depthCamera; + dto.markerPose = bo.markerPose; + dto.markerGlobal = bo.getGlobalMarkerPose(); + } + void + fromAron(const arondto::Marker& dto, marker::Marker& bo) + { + bo.name = dto.name; + bo.robotGlobal = dto.robotGlobal; + bo.rgbCamera = dto.rgbCamera; + bo.depthCamera = dto.depthCamera; + bo.markerPose = dto.markerPose; + } - -} // namespace armarx::armem +} // namespace armarx::armem armarx::armem::MemoryID armarx::armem::obj::makeObjectInstanceMemoryID(const objpose::ObjectPose& objectPose) { return MemoryID("Object/Instance") - .withProviderSegmentName(objectPose.providerName) - .withEntityName(objectPose.objectID.str()) - .withTimestamp(objectPose.timestamp); + .withProviderSegmentName(objectPose.providerName) + .withEntityName(objectPose.objectID.str()) + .withTimestamp(objectPose.timestamp); } diff --git a/source/RobotAPI/libraries/armem_objects/aron_conversions.h b/source/RobotAPI/libraries/armem_objects/aron_conversions.h index 61e89c37ec00aaabed94e1b20a2ba1b50be976a8..e27ed16c4cede302e2eecf2c013440d240162550 100644 --- a/source/RobotAPI/libraries/armem_objects/aron_conversions.h +++ b/source/RobotAPI/libraries/armem_objects/aron_conversions.h @@ -4,6 +4,7 @@ #include <RobotAPI/libraries/armem_objects/aron/ObjectInstance.aron.generated.h> #include <RobotAPI/libraries/armem_objects/aron/Attachment.aron.generated.h> +#include <RobotAPI/libraries/armem_objects/aron/Marker.aron.generated.h> #include <RobotAPI/libraries/armem_objects/types.h> @@ -26,6 +27,8 @@ namespace armarx::armem void fromAron(const arondto::attachment::ArticulatedObjectAttachment& dto, attachment::ArticulatedObjectAttachment& bo); void toAron(arondto::attachment::ArticulatedObjectAttachment& dto, const attachment::ArticulatedObjectAttachment& bo); + void fromAron(const arondto::Marker& dto, marker::Marker&bo); + void toAron(arondto::Marker& dto, const marker::Marker&bo); } // namespace armarx::armem diff --git a/source/RobotAPI/libraries/armem_objects/aron_forward_declarations.h b/source/RobotAPI/libraries/armem_objects/aron_forward_declarations.h index 9416a033d713f5c8dab28506538c1a56534dbb53..6a57255f1019c433f87d7f1f66faa3919a9087c8 100644 --- a/source/RobotAPI/libraries/armem_objects/aron_forward_declarations.h +++ b/source/RobotAPI/libraries/armem_objects/aron_forward_declarations.h @@ -5,4 +5,6 @@ namespace armarx::armem::arondto { class ObjectClass; class ObjectInstance; + class Marker; } + diff --git a/source/RobotAPI/libraries/armem_objects/client/articulated_object/ArticulatedObjectWriter.cpp b/source/RobotAPI/libraries/armem_objects/client/articulated_object/ArticulatedObjectWriter.cpp index 6cbb3ecdcfee0334df79a9d6728080c5bce55f5f..54049d8bbeb899b350dfab4906a125157ea527b9 100644 --- a/source/RobotAPI/libraries/armem_objects/client/articulated_object/ArticulatedObjectWriter.cpp +++ b/source/RobotAPI/libraries/armem_objects/client/articulated_object/ArticulatedObjectWriter.cpp @@ -28,7 +28,7 @@ namespace armarx::armem::articulated_object {"PriorKnowledgeData"}, obj.getFilename()), obj.getFilename()) }, - .instance = "", // TODO(fabian.reister): + .instance = obj.getName(), .config = { .timestamp = timestamp, .globalPose = Eigen::Affine3f(obj.getRootNode()->getGlobalPose()), diff --git a/source/RobotAPI/libraries/armem_objects/memory_ids.cpp b/source/RobotAPI/libraries/armem_objects/memory_ids.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ad77419a2e5d3288aefae77a038cca62808e81dd --- /dev/null +++ b/source/RobotAPI/libraries/armem_objects/memory_ids.cpp @@ -0,0 +1,35 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::ArmarXObjects::armem_objects + * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) + * @date 2022 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "memory_ids.h" + + +namespace armarx::armem +{ + + const MemoryID objects::memoryID { "Object" }; + + const MemoryID objects::attachmentsSegmentID = memoryID.withCoreSegmentName("Attachments"); + const MemoryID objects::classSegmentID = memoryID.withCoreSegmentName("Class"); + const MemoryID objects::instaceSegmentID = memoryID.withCoreSegmentName("Instance"); + +} diff --git a/source/RobotAPI/libraries/armem_objects/memory_ids.h b/source/RobotAPI/libraries/armem_objects/memory_ids.h new file mode 100644 index 0000000000000000000000000000000000000000..50408b82f550fe2ecf80b4cc5d4930ee9b69b012 --- /dev/null +++ b/source/RobotAPI/libraries/armem_objects/memory_ids.h @@ -0,0 +1,38 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::ArmarXObjects::armem_objects + * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) + * @date 2022 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +#include <RobotAPI/libraries/armem/core/MemoryID.h> + + +namespace armarx::armem::objects +{ + + extern const MemoryID memoryID; + + extern const MemoryID attachmentsSegmentID; + extern const MemoryID classSegmentID; + extern const MemoryID instaceSegmentID; + + +} // namespace armarx::armem::objects diff --git a/source/RobotAPI/libraries/armem_objects/server/attachments/Segment.h b/source/RobotAPI/libraries/armem_objects/server/attachments/Segment.h index 4f8cd20ccd9a0ce456bb664f5f5eb8a25f1981e0..9f4636fa9484d8c9d4fdd4d0a825442f06340637 100644 --- a/source/RobotAPI/libraries/armem_objects/server/attachments/Segment.h +++ b/source/RobotAPI/libraries/armem_objects/server/attachments/Segment.h @@ -25,6 +25,7 @@ #include <RobotAPI/libraries/armem/core/forward_declarations.h> #include <RobotAPI/libraries/armem/server/forward_declarations.h> #include <RobotAPI/libraries/armem_objects/types.h> +#include <RobotAPI/libraries/armem_objects/memory_ids.h> #include <ArmarXCore/core/application/properties/forward_declarations.h> #include <ArmarXCore/core/logging/Logging.h> @@ -57,7 +58,7 @@ namespace armarx::armem::server::obj::attachments struct Properties { - std::string coreSegmentName = "Attachments"; + std::string coreSegmentName = objects::attachmentsSegmentID.coreSegmentName; int64_t maxHistorySize = -1; }; Properties p; diff --git a/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp b/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp index 3250a1cca34d47df08e4d9218c0bfeda729163b0..a95e98d011e52c7f6251a2119b66b971b9d5a045 100644 --- a/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp +++ b/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp @@ -5,6 +5,7 @@ #include <RobotAPI/libraries/ArmarXObjects/aron_conversions.h> #include <RobotAPI/libraries/armem/server/MemoryToIceAdapter.h> #include <RobotAPI/libraries/armem_objects/aron_conversions.h> +#include <RobotAPI/libraries/armem_objects/memory_ids.h> #include <RobotAPI/libraries/armem_objects/aron/ObjectClass.aron.generated.h> #include <ArmarXCore/core/application/properties/PropertyDefinitionContainer.h> @@ -22,7 +23,7 @@ namespace armarx::armem::server::obj::clazz { Segment::Segment(armem::server::MemoryToIceAdapter& memoryToIceAdapter) : - SpecializedCoreSegment(memoryToIceAdapter, "Class", arondto::ObjectClass::ToAronType(), -1) + SpecializedCoreSegment(memoryToIceAdapter, objects::classSegmentID.coreSegmentName, arondto::ObjectClass::ToAronType(), -1) { } diff --git a/source/RobotAPI/libraries/armem_objects/server/instance/Segment.cpp b/source/RobotAPI/libraries/armem_objects/server/instance/Segment.cpp index 9076cedadf778bb46f64f2c90388ff8d197436e7..7f3aee34f4d6382fd08eb466116b62a803293b80 100644 --- a/source/RobotAPI/libraries/armem_objects/server/instance/Segment.cpp +++ b/source/RobotAPI/libraries/armem_objects/server/instance/Segment.cpp @@ -6,6 +6,7 @@ #include <RobotAPI/libraries/armem_objects/aron/ObjectClass.aron.generated.h> #include <RobotAPI/libraries/armem_objects/aron/ObjectInstance.aron.generated.h> #include <RobotAPI/libraries/armem_objects/aron_conversions.h> +#include <RobotAPI/libraries/armem_objects/memory_ids.h> #include <RobotAPI/libraries/armem/core/aron_conversions.h> #include <RobotAPI/libraries/armem/core/error.h> @@ -15,6 +16,7 @@ #include <RobotAPI/libraries/armem/server/MemoryToIceAdapter.h> #include <RobotAPI/libraries/armem/util/util.h> + #include <RobotAPI/libraries/aron/common/aron_conversions.h> #include <RobotAPI/libraries/ArmarXObjects/ObjectFinder.h> @@ -51,7 +53,7 @@ namespace armarx::armem::server::obj::instance Segment::Segment(armem::server::MemoryToIceAdapter& memoryToIceAdapter) : SpecializedCoreSegment(memoryToIceAdapter, - "Instance", + objects::instaceSegmentID.coreSegmentName, arondto::ObjectInstance::ToAronType(), 64) { diff --git a/source/RobotAPI/libraries/armem_objects/types.cpp b/source/RobotAPI/libraries/armem_objects/types.cpp new file mode 100644 index 0000000000000000000000000000000000000000..58c02ecd6d2392a4367ec2731dc0a8d8d9a1d4f7 --- /dev/null +++ b/source/RobotAPI/libraries/armem_objects/types.cpp @@ -0,0 +1,64 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::ArmarXObjects::marker_pose_data + * @author Hawo Höfer ( uuujt at student dot kit dot edu ) + * @date 2022 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "types.h" + +#include "RobotAPI/libraries/core/FramedPose.h" +#include <RobotAPI/libraries/armem_objects/aron/Marker.aron.generated.h> + +#include "aron_forward_declarations.h" + + +namespace armarx::armem::marker +{ + Marker::Marker(const std::string& name, + const FramedPose& framedMarkerPose, + const FramedPose& framedRobotPose, + const FramedPose& framedRGBCameraPose, + const FramedPose& framedDepthCameraPose) : + name(name), + robotGlobal(framedRobotPose), + rgbCamera(framedRGBCameraPose), + depthCamera(framedDepthCameraPose), + markerPose(framedMarkerPose) + { + markerGlobal = getGlobalMarkerPose(); + } + + Marker::Marker(const armarx::armem::arondto::Marker& dto) : + name(dto.name), + robotGlobal(dto.robotGlobal), + rgbCamera(dto.rgbCamera), + depthCamera(dto.depthCamera), + markerPose(dto.markerPose) + { + markerGlobal = getGlobalMarkerPose(); + } + armarx::FramedPose + Marker::getGlobalMarkerPose() const + { + return {robotGlobal.toEigen() * depthCamera.toEigen() * markerPose.toEigen(), + GlobalFrame, + "marker"}; + } + +} // namespace armarx::armem::marker diff --git a/source/RobotAPI/libraries/armem_objects/types.h b/source/RobotAPI/libraries/armem_objects/types.h index 5ca91ff285e5fc92d1d3523a504379d582dda8b5..c7e4fe4897c46202543e3d12628cf22e8083b0b3 100644 --- a/source/RobotAPI/libraries/armem_objects/types.h +++ b/source/RobotAPI/libraries/armem_objects/types.h @@ -26,6 +26,9 @@ #include <RobotAPI/libraries/armem/core/MemoryID.h> #include <RobotAPI/libraries/armem/core/Time.h> #include <RobotAPI/libraries/armem_robot/types.h> +#include <RobotAPI/libraries/core/FramedPose.h> + +#include "aron_forward_declarations.h" namespace armarx::armem::attachment @@ -84,15 +87,39 @@ namespace armarx::armem::attachment armem::Time timestamp; bool active; - }; -} // namespace armarx::armem::attachment +} // namespace armarx::armem::attachment namespace armarx::armem::articulated_object { using ArticulatedObjectDescription = armarx::armem::robot::RobotDescription; - using ArticulatedObject = armarx::armem::robot::Robot; + using ArticulatedObject = armarx::armem::robot::Robot; using ArticulatedObjects = armarx::armem::robot::Robots; } // namespace armarx::armem::articulated_object + + +namespace armarx::armem::marker +{ + class Marker + { + + public: + Marker(const armarx::armem::arondto::Marker& dto); + Marker(const std::string& name, + const FramedPose& markerPose, + const FramedPose& robotPose, + const FramedPose& rgbCameraPose, + const FramedPose& depthCameraPose); + + std::string name; + FramedPose robotGlobal; + FramedPose rgbCamera; + FramedPose depthCamera; + FramedPose markerPose; + FramedPose markerGlobal; + + FramedPose getGlobalMarkerPose() const; + }; +} // namespace armarx::armem::marker diff --git a/source/RobotAPI/libraries/armem_objects/utils.cpp b/source/RobotAPI/libraries/armem_objects/utils.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e3025f5264ebcbc5a50de330cb229f792b6f421f --- /dev/null +++ b/source/RobotAPI/libraries/armem_objects/utils.cpp @@ -0,0 +1,45 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::ArmarXObjects::armem_objects + * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) + * @date 2022 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "utils.h" + +#include <RobotAPI/libraries/ArmarXObjects/ObjectPose.h> +#include <RobotAPI/libraries/armem/core/MemoryID.h> +#include <RobotAPI/libraries/armem_objects/memory_ids.h> + + +namespace armarx::armem +{ + + MemoryID + objects::reconstructObjectInstanceID(const objpose::ObjectPose& objectPose) + { + armem::MemoryID id = + armem::objects::instaceSegmentID.withProviderSegmentName(objectPose.providerName) + .withEntityName(objectPose.objectID.str()) + .withTimestamp(objectPose.timestamp) + .withInstanceIndex(0); + return id; + } + + +} // namespace armarx::armem diff --git a/source/RobotAPI/libraries/armem_objects/utils.h b/source/RobotAPI/libraries/armem_objects/utils.h new file mode 100644 index 0000000000000000000000000000000000000000..bc0068234ac8c55d4985d25ab17fab8040c987d7 --- /dev/null +++ b/source/RobotAPI/libraries/armem_objects/utils.h @@ -0,0 +1,36 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::ArmarXObjects::armem_objects + * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) + * @date 2022 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +#include <RobotAPI/libraries/armem/core/forward_declarations.h> +#include <RobotAPI/libraries/ArmarXObjects/forward_declarations.h> + + +namespace armarx::armem::objects +{ + + armem::MemoryID + reconstructObjectInstanceID(const objpose::ObjectPose& objectPose); + + +} // namespace armarx::armem::objects diff --git a/source/RobotAPI/libraries/armem_robot_state/CMakeLists.txt b/source/RobotAPI/libraries/armem_robot_state/CMakeLists.txt index aafe0978d9d41e95b51dfabfe49d33783e2791ea..a9c0ceb1b8cd552915819a052a2ffd73bbfdec29 100644 --- a/source/RobotAPI/libraries/armem_robot_state/CMakeLists.txt +++ b/source/RobotAPI/libraries/armem_robot_state/CMakeLists.txt @@ -38,6 +38,7 @@ armarx_add_library( client/localization/TransformWriter.h aron_conversions.h + memory_ids.h utils.h SOURCES @@ -52,6 +53,7 @@ armarx_add_library( client/localization/TransformWriter.cpp aron_conversions.cpp + memory_ids.cpp utils.cpp ) diff --git a/source/RobotAPI/libraries/armem_robot_state/common/localization/TransformHelper.h b/source/RobotAPI/libraries/armem_robot_state/common/localization/TransformHelper.h index ae1e0bc5d1d6a355483cbd60626990f2065ffd9b..80cdea39921497a5c2c369416d59115d7dffc4c5 100644 --- a/source/RobotAPI/libraries/armem_robot_state/common/localization/TransformHelper.h +++ b/source/RobotAPI/libraries/armem_robot_state/common/localization/TransformHelper.h @@ -22,6 +22,7 @@ #pragma once #include <vector> +#include <optional> #include <Eigen/Core> #include <Eigen/Geometry> diff --git a/source/RobotAPI/libraries/armem_robot_state/memory_ids.cpp b/source/RobotAPI/libraries/armem_robot_state/memory_ids.cpp new file mode 100644 index 0000000000000000000000000000000000000000..926c2e843e252efdc9c4711bbe2b03a3a7394bba --- /dev/null +++ b/source/RobotAPI/libraries/armem_robot_state/memory_ids.cpp @@ -0,0 +1,36 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::ArmarXObjects::armem_robot_state + * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) + * @date 2022 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "memory_ids.h" + + +namespace armarx::armem +{ + + const MemoryID robot_state::memoryID { "RobotState" }; + + const MemoryID robot_state::descriptionSegmentID { memoryID.withCoreSegmentName("Description") }; + const MemoryID robot_state::proprioceptionSegmentID { memoryID.withCoreSegmentName("Proprioception") }; + const MemoryID robot_state::localizationSegmentID { memoryID.withCoreSegmentName("Localization") }; + + +} diff --git a/source/RobotAPI/libraries/armem_robot_state/memory_ids.h b/source/RobotAPI/libraries/armem_robot_state/memory_ids.h new file mode 100644 index 0000000000000000000000000000000000000000..1d8008d4db8d7a71da0a8ca47420040060382ca6 --- /dev/null +++ b/source/RobotAPI/libraries/armem_robot_state/memory_ids.h @@ -0,0 +1,37 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI::ArmarXObjects::armem_robot_state + * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) + * @date 2022 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +#include <RobotAPI/libraries/armem/core/MemoryID.h> + + +namespace armarx::armem::robot_state +{ + + extern const MemoryID memoryID; + + extern const MemoryID descriptionSegmentID; + extern const MemoryID proprioceptionSegmentID; + extern const MemoryID localizationSegmentID; + +} // namespace armarx::armem::objects diff --git a/source/RobotAPI/libraries/armem_robot_state/server/common/Visu.cpp b/source/RobotAPI/libraries/armem_robot_state/server/common/Visu.cpp index e68119affae5664f232dba25c679a8cce9fbdd10..1607132e51d9370e3ea746193d835f265bf529ff 100644 --- a/source/RobotAPI/libraries/armem_robot_state/server/common/Visu.cpp +++ b/source/RobotAPI/libraries/armem_robot_state/server/common/Visu.cpp @@ -42,8 +42,8 @@ namespace armarx::armem::server::robot_state void Visu::defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string& prefix) { - defs->optional( - p.enabled, prefix + "enabled", "Enable or disable visualization of objects."); + defs->optional(p.enabled, prefix + "enabled", "Enable or disable visualization of objects."); + defs->optional(p.framesEnabled, prefix + "famesEnabled", "Enable or disable visualization of frames."); defs->optional(p.frequencyHz, prefix + "frequenzyHz", "Frequency of visualization."); } @@ -199,10 +199,15 @@ namespace armarx::armem::server::robot_state ARMARX_DEBUG << "Visualize " << robots.size() << " robots ..."; viz::Layer layer = arviz.layer("Robots"); visualizeRobots(layer, robots); + std::vector layers{layer}; ARMARX_DEBUG << "Visualize frames ..."; - viz::Layer layerFrames = arviz.layer("Frames"); - visualizeFrames(layerFrames, frames); + if(p.framesEnabled) + { + viz::Layer layerFrames = arviz.layer("Frames"); + visualizeFrames(layerFrames, frames); + layers.push_back(layerFrames); + } TIMING_END_STREAM(tVisuBuildLayers, ARMARX_DEBUG); @@ -211,7 +216,7 @@ namespace armarx::armem::server::robot_state ARMARX_DEBUG << "Commit visualization ..."; TIMING_START(tVisuCommit); - arviz.commit({layer, layerFrames}); + arviz.commit(layers); TIMING_END_STREAM(tVisuCommit, ARMARX_DEBUG); TIMING_END_STREAM(tVisuTotal, ARMARX_DEBUG); diff --git a/source/RobotAPI/libraries/armem_robot_state/server/common/Visu.h b/source/RobotAPI/libraries/armem_robot_state/server/common/Visu.h index ce69772c1b1c55553c62e39d3db5e8e4503d2592..66222e0cf8dc6cf6043e6db35ebb7ba00e0cab00 100644 --- a/source/RobotAPI/libraries/armem_robot_state/server/common/Visu.h +++ b/source/RobotAPI/libraries/armem_robot_state/server/common/Visu.h @@ -84,6 +84,7 @@ namespace armarx::armem::server::robot_state struct Properties { bool enabled = true; + bool framesEnabled = false; float frequencyHz = 25; } p; diff --git a/source/RobotAPI/libraries/armem_robot_state/server/description/Segment.cpp b/source/RobotAPI/libraries/armem_robot_state/server/description/Segment.cpp index f6cba1d8c22086497f7eb537c6a3e16fa2e2faf4..ec68b26342c527923fc997d94d53796e968e1083 100644 --- a/source/RobotAPI/libraries/armem_robot_state/server/description/Segment.cpp +++ b/source/RobotAPI/libraries/armem_robot_state/server/description/Segment.cpp @@ -20,13 +20,14 @@ #include <RobotAPI/libraries/armem_robot/aron_conversions.h> #include <RobotAPI/libraries/armem_robot/robot_conversions.h> #include <RobotAPI/libraries/armem_robot_state/aron/Proprioception.aron.generated.h> +#include <RobotAPI/libraries/armem_robot_state/memory_ids.h> namespace armarx::armem::server::robot_state::description { Segment::Segment(armem::server::MemoryToIceAdapter& memoryToIceAdapter) : - Base(memoryToIceAdapter, "Description", arondto::RobotDescription::ToAronType()) + Base(memoryToIceAdapter, armem::robot_state::descriptionSegmentID.coreSegmentName, arondto::RobotDescription::ToAronType()) { } diff --git a/source/RobotAPI/libraries/armem_robot_state/server/localization/Segment.cpp b/source/RobotAPI/libraries/armem_robot_state/server/localization/Segment.cpp index c41908c9ac35ca17519e4c7400eb04903791699b..3cadfeccb0a86bd6672dd1af8fc072086dca4fa4 100644 --- a/source/RobotAPI/libraries/armem_robot_state/server/localization/Segment.cpp +++ b/source/RobotAPI/libraries/armem_robot_state/server/localization/Segment.cpp @@ -27,13 +27,14 @@ #include <RobotAPI/libraries/armem_robot_state/common/localization/TransformHelper.h> #include <RobotAPI/libraries/armem_robot_state/common/localization/types.h> #include <RobotAPI/libraries/armem_robot_state/client/common/constants.h> +#include <RobotAPI/libraries/armem_robot_state/memory_ids.h> namespace armarx::armem::server::robot_state::localization { Segment::Segment(armem::server::MemoryToIceAdapter& memoryToIceAdapter) : - Base(memoryToIceAdapter, "Localization", arondto::Transform::ToAronType(), 1024) + Base(memoryToIceAdapter, armem::robot_state::localizationSegmentID.coreSegmentName, arondto::Transform::ToAronType(), 1024) { } diff --git a/source/RobotAPI/libraries/armem_robot_state/server/proprioception/Segment.cpp b/source/RobotAPI/libraries/armem_robot_state/server/proprioception/Segment.cpp index 3351772f3344698e006c06a92b86dcaff0868801..99c330e7661d35c5b161c26e1d18b45af2d91ce9 100644 --- a/source/RobotAPI/libraries/armem_robot_state/server/proprioception/Segment.cpp +++ b/source/RobotAPI/libraries/armem_robot_state/server/proprioception/Segment.cpp @@ -13,6 +13,7 @@ #include <RobotAPI/libraries/armem/core/MemoryID.h> #include <RobotAPI/libraries/armem/util/prediction_helpers.h> #include <RobotAPI/libraries/armem_robot_state/aron/Proprioception.aron.generated.h> +#include <RobotAPI/libraries/armem_robot_state/memory_ids.h> namespace armarx::armem::server::robot_state::proprioception @@ -20,7 +21,7 @@ namespace armarx::armem::server::robot_state::proprioception Segment::Segment(armem::server::MemoryToIceAdapter& memoryToIceAdapter) : Base(memoryToIceAdapter, - "Proprioception", + armem::robot_state::proprioceptionSegmentID.coreSegmentName, arondto::Proprioception::ToAronType(), 1024) { diff --git a/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/Generator.cpp b/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/Generator.cpp index 8b2d2cf94cbb3334341b3159b4c73bb9dc7cdc76..add1b800c01ad8186008d55574559e0705527a4b 100644 --- a/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/Generator.cpp +++ b/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/Generator.cpp @@ -209,7 +209,7 @@ namespace armarx::aron::codegenerator::cpp doc << "@brief writeType() - This method returns a new type from the class structure using a type writer implementation. This function is static. \n"; doc << "@return - the result of the writer implementation"; - CppMethodPtr m = CppMethodPtr(new CppMethod("template<class WriterT>\nstatic typename WriterT::ReturnType writeType(WriterT& " + ARON_WRITER_ACCESSOR + ", std::vector<std::string> " + ARON_TEMPLATE_INSTANTIATIONS_ACCESSOR + " = {}, armarx::aron::type::Maybe "+ ARON_MAYBE_TYPE_ACCESSOR +" = armarx::aron::type::Maybe::NONE, const armarx::aron::Path& "+ARON_PATH_ACCESSOR+" = armarx::aron::Path())", doc.str())); + CppMethodPtr m = CppMethodPtr(new CppMethod("template<class WriterT>\nstatic typename WriterT::ReturnType writeType(WriterT& " + ARON_WRITER_ACCESSOR + ", std::vector<std::string> " + ARON_TEMPLATE_INSTANTIATIONS_ACCESSOR + " = {}, armarx::aron::type::Maybe "+ ARON_MAYBE_TYPE_ACCESSOR +" = ::armarx::aron::type::Maybe::NONE, const ::armarx::aron::Path& "+ARON_PATH_ACCESSOR+" = ::armarx::aron::Path())", doc.str())); CppBlockPtr b = std::make_shared<CppBlock>(); b->addLine("using _Aron_T [[maybe_unused]] = typename WriterT::ReturnType;"); @@ -226,7 +226,7 @@ namespace armarx::aron::codegenerator::cpp doc << "@param w - The writer implementation\n"; doc << "@return - the result of the writer implementation"; - CppMethodPtr m = CppMethodPtr(new CppMethod("template<class WriterT>\ntypename WriterT::ReturnType write(WriterT& " + ARON_WRITER_ACCESSOR + ", const armarx::aron::Path& "+ARON_PATH_ACCESSOR+" = armarx::aron::Path()) const", doc.str())); + CppMethodPtr m = CppMethodPtr(new CppMethod("template<class WriterT>\ntypename WriterT::ReturnType write(WriterT& " + ARON_WRITER_ACCESSOR + ", const ::armarx::aron::Path& "+ARON_PATH_ACCESSOR+" = armarx::aron::Path()) const", doc.str())); CppBlockPtr b = std::make_shared<CppBlock>(); b->addLine("using _Aron_T [[maybe_unused]] = typename WriterT::ReturnType;"); @@ -234,7 +234,7 @@ namespace armarx::aron::codegenerator::cpp std::string dummy; b->addBlock(this->getWriteBlock("", Path(), dummy)); b->addLine("catch(const std::exception& " + ARON_VARIABLE_PREFIX + "_e)"); - b->addLineAsBlock("throw armarx::aron::error::AronException(__PRETTY_FUNCTION__, std::string(\"An error occured during the write method of an aron generated class. The full error log was:\\n\") + " + ARON_VARIABLE_PREFIX + "_e.what());"); + b->addLineAsBlock("throw ::armarx::aron::error::AronException(__PRETTY_FUNCTION__, std::string(\"An error occured during the write method of an aron generated class. The full error log was:\\n\") + " + ARON_VARIABLE_PREFIX + "_e.what());"); m->setBlock(b); return m; @@ -254,12 +254,12 @@ namespace armarx::aron::codegenerator::cpp b->addLine("this->resetSoft();"); b->addLine("if (" + ARON_READER_ACCESSOR + ".readNull(input))"); - b->addLineAsBlock("throw armarx::aron::error::AronException(__PRETTY_FUNCTION__, \"The input to the read method must not be null.\");"); + b->addLineAsBlock("throw ::armarx::aron::error::AronException(__PRETTY_FUNCTION__, \"The input to the read method must not be null.\");"); b->addLine("try"); b->addBlock(this->getReadBlock("", "input")); b->addLine("catch(const std::exception& " + ARON_VARIABLE_PREFIX + "_e)"); - b->addLineAsBlock("throw armarx::aron::error::AronException(__PRETTY_FUNCTION__, std::string(\"An error occured during the read method of an aron generated class. The full error log was:\\n\") + " + ARON_VARIABLE_PREFIX + "_e.what());"); + b->addLineAsBlock("throw ::armarx::aron::error::AronException(__PRETTY_FUNCTION__, std::string(\"An error occured during the read method of an aron generated class. The full error log was:\\n\") + " + ARON_VARIABLE_PREFIX + "_e.what());"); m->setBlock(b); return m; } diff --git a/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/any/AnyObject.cpp b/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/any/AnyObject.cpp index b81341ae2bf19f38cbb9928eafdbf9d3f0f9ffe5..e3c2913dd52b5924ea7d02f9c5a402626788f7e2 100644 --- a/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/any/AnyObject.cpp +++ b/source/RobotAPI/libraries/aron/codegeneration/codegenerator/codewriter/cpp/generator/any/AnyObject.cpp @@ -59,7 +59,7 @@ namespace armarx::aron::codegenerator::cpp::generator std::string escaped_accessor = this->EscapeAccessor(cppAccessor); variantAccessor = Generator::ARON_VARIANT_RETURN_ACCESSOR + "_" + escaped_accessor; - block_if_data->addLine(variantAccessor + " = armarx::aron::data::readAndWrite<armarx::aron::data::FromVariantConverter<WriterT>>(" + cppAccessor + "); // of " + cppAccessor); + block_if_data->addLine(variantAccessor + " = ::armarx::aron::data::readAndWrite<::armarx::aron::data::FromVariantConverter<WriterT>>(" + cppAccessor + "); // of " + cppAccessor); return block_if_data; } @@ -69,7 +69,7 @@ namespace armarx::aron::codegenerator::cpp::generator auto block_if_data = std::make_shared<CppBlock>(); std::string escaped_accessor = this->EscapeAccessor(cppAccessor); - block_if_data->addLine(cppAccessor + " = armarx::aron::data::Dict::DynamicCastAndCheck(armarx::aron::data::readAndWrite<aron::data::ToVariantConverter<ReaderT>>(" + variantAccessor + ")); // of " + cppAccessor); + block_if_data->addLine(cppAccessor + " = ::armarx::aron::data::Dict::DynamicCastAndCheck(::armarx::aron::data::readAndWrite<::armarx::aron::data::ToVariantConverter<ReaderT>>(" + variantAccessor + ")); // of " + cppAccessor); return block_if_data; } @@ -81,7 +81,7 @@ namespace armarx::aron::codegenerator::cpp::generator variantAccessor = ARON_VARIANT_RETURN_ACCESSOR + "_" + escaped_accessor; b->addLine("auto " + variantAccessor + " = " + ARON_WRITER_ACCESSOR + ".writeAnyObject(" + conversion::Maybe2CppString.at(type.getMaybe()) + ", " + - "armarx::aron::Path("+ARON_PATH_ACCESSOR+", {"+simox::alg::join(p.getPath(), ", ")+"})); // of " + typeAccessor); + "::armarx::aron::Path("+ARON_PATH_ACCESSOR+", {"+simox::alg::join(p.getPath(), ", ")+"})); // of " + typeAccessor); return b; } } diff --git a/source/RobotAPI/libraries/aron/converter/eigen/EigenConverter.h b/source/RobotAPI/libraries/aron/converter/eigen/EigenConverter.h index 6c45ffbdb7400b4d3bbc365559c3fa6563e1fd89..9d83042a1ce7e0254c827350a87d515f05761665 100644 --- a/source/RobotAPI/libraries/aron/converter/eigen/EigenConverter.h +++ b/source/RobotAPI/libraries/aron/converter/eigen/EigenConverter.h @@ -135,6 +135,16 @@ namespace armarx::aron::converter } } + template<typename T> + static data::NDArrayPtr ConvertFromQuaternion( + const Eigen::Quaternion<T>& quat) + { + data::NDArrayPtr ndArr(new data::NDArray); + ndArr->setShape({1, 4}); + ndArr->setData(sizeof(T) * 4, reinterpret_cast <const unsigned char* >(quat.coeffs().data())); + + return ndArr; + } template<typename T> static data::NDArrayPtr ConvertFromMatrix( @@ -148,6 +158,18 @@ namespace armarx::aron::converter return ndArr; } + template<typename T, int Rows = Eigen::Dynamic, int Cols = Eigen::Dynamic> + static data::NDArrayPtr ConvertFromMatrix( + const Eigen::Matrix < T, Rows, Cols >& mat) + { + data::NDArrayPtr ndArr(new data::NDArray); + + ndArr->setShape({Rows, Cols}); + ndArr->setData(sizeof(T) * mat.size(), reinterpret_cast <const unsigned char* >(mat.data())); + + return ndArr; + } + // Eigen::Array diff --git a/source/RobotAPI/libraries/aron_component_config/CMakeLists.txt b/source/RobotAPI/libraries/aron_component_config/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..5b6b176ca9b2e9d303251db890ab28939ac1544b --- /dev/null +++ b/source/RobotAPI/libraries/aron_component_config/CMakeLists.txt @@ -0,0 +1,60 @@ +#armarx_add_library(AronComponentConfig +# DEPENDENCIES +# ArmarXCoreInterfaces ArmarXCore ArmarXGuiComponentPlugins +# RobotAPIInterfaces RobotAPICore RobotAPIComponentPlugins +# SOURCES +# PropertyDefinitionVisitors.cpp +# RemoteGuiVisitors.cpp +# HEADERS +# PropertyDefinitionVisitors.h +# RemoteGui.h +# RemoteGuiVisitors.h +# Util.h +# ComponentPlugin.h +# ) + +set(LIB_NAME aron_component_config) + +armarx_component_set_name("${LIB_NAME}") +armarx_set_target("Library: ${LIB_NAME}") + +find_package(Simox QUIET) +armarx_build_if(Simox_FOUND "Simox not available") + +set(LIBS + ArmarXCoreInterfaces ArmarXCore ArmarXGuiComponentPlugins + RobotAPIInterfaces RobotAPICore RobotAPIComponentPlugins aroneigenconverter +) + +set(LIB_FILES + PropertyDefinitionVisitors.cpp + RemoteGuiVisitors.cpp + VariantHelperFactory.cpp +) + +set(LIB_HEADERS + PropertyDefinitionVisitors.h + RemoteGui.h + RemoteGuiVisitors.h + Util.h + ComponentPlugin.h + VariantHelperFactory.h +) + + +armarx_add_library( + LIB_NAME + "${LIB_NAME}" + SOURCES + "${LIB_FILES}" + HEADERS + "${LIB_HEADERS}" + LIBS + "${LIBS}" +) + +add_library( + RobotAPI::aron_component_config + ALIAS + aron_component_config +) diff --git a/source/RobotAPI/libraries/aron_component_config/ComponentPlugin.h b/source/RobotAPI/libraries/aron_component_config/ComponentPlugin.h new file mode 100644 index 0000000000000000000000000000000000000000..ae144f245b15cd28cdf0eee59245d7b9d8a94b28 --- /dev/null +++ b/source/RobotAPI/libraries/aron_component_config/ComponentPlugin.h @@ -0,0 +1,110 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package robdekon + * @author Christoph Pohl ( christoph dot pohl at kit dot edu ) + * @date 07.09.22 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +#include <experimental/memory> +#include <ArmarXCore/core/ManagedIceObject.h> +#include <ArmarXCore/core/ComponentPlugin.h> +#include <RobotAPI/libraries/aron/core/codegeneration/cpp/AronGeneratedClass.h> +#include <ArmarXGui/libraries/ArmarXGuiComponentPlugins/RemoteGuiComponentPlugin.h> +#include <RobotAPI/libraries/aron/core/data/visitor/RecursiveVisitor.h> +#include "PropertyDefinitionVisitors.h" +#include "RemoteGui.h" + + +namespace armarx::plugins +{ + template <typename T> concept isAronGenerated = std::is_base_of<armarx::aron::cpp::AronGeneratedClass, T>::value; + + template <typename AronStructT> + requires isAronGenerated<AronStructT> + class AronComponentConfigPlugin : public ComponentPlugin + { + protected: + void preOnInitComponent() override + { + armarx::aron::component_config::PropertyDefinitionGetterVisitor vis(parent<armarx::PropertyUser>()); + auto data = std::static_pointer_cast<armarx::aron::data::Variant>(config_.getUpToDateReadBuffer().toAron()); + auto type = config_.getUpToDateReadBuffer().ToAronType(); + armarx::aron::data::visitRecursive(vis, data, type); + config_.getWriteBuffer().fromAron(std::static_pointer_cast<armarx::aron::data::Dict>(data)); + config_.commitWrite(); + ManagedIceObjectPlugin::preOnInitComponent(); + } + + void postOnInitComponent() override + { + ManagedIceObjectPlugin::postOnInitComponent(); + } + + void preOnConnectComponent() override + { + ManagedIceObjectPlugin::preOnConnectComponent(); + } + + void postOnConnectComponent() override + { + ManagedIceObjectPlugin::postOnConnectComponent(); + } + + void postOnDisconnectComponent() override + { + ManagedIceObjectPlugin::postOnDisconnectComponent(); + } + + void postCreatePropertyDefinitions(armarx::PropertyDefinitionsPtr& properties) override + { + armarx::aron::component_config::PropertyDefinitionSetterVisitor vis(properties); + const auto& config = config_.getUpToDateReadBuffer(); + armarx::aron::data::visitRecursive(vis, config.toAron(), config.ToAronType()); + ComponentPlugin::postCreatePropertyDefinitions(properties); + } + + public: + RemoteGui::detail::GroupBoxBuilder buildRemoteGui(const std::string& name) + { + return RemoteGui::makeConfigGui(name, config_.getUpToDateReadBuffer()); + } + + bool updateRemoteGui(armarx::RemoteGui::TabProxy& prx) // prx has to be already updated; otherwise nothing will change + { + ARMARX_TRACE; + armarx::aron::component_config::GetValueFromMapVisitor vis(&prx); + auto& cfg = config_.getWriteBuffer(); + auto data = std::static_pointer_cast<armarx::aron::data::Variant>(cfg.toAron()); + auto type = cfg.ToAronType(); + armarx::aron::data::visitRecursive(vis, data, type); + cfg.fromAron(std::static_pointer_cast<armarx::aron::data::Dict>(data)); + config_.commitWrite(); + return vis.tabRebuildRequired(); + } + + AronComponentConfigPlugin(ManagedIceObject& parent, const std::string& prefix) : ComponentPlugin(parent, prefix) + { + + } + + armarx::WriteBufferedTripleBuffer<AronStructT> config_; + + }; +} \ No newline at end of file diff --git a/source/RobotAPI/libraries/aron_component_config/PropertyDefinitionVisitors.cpp b/source/RobotAPI/libraries/aron_component_config/PropertyDefinitionVisitors.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c8a21c747d81c4465a1c85281da518f4905001e6 --- /dev/null +++ b/source/RobotAPI/libraries/aron_component_config/PropertyDefinitionVisitors.cpp @@ -0,0 +1,338 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package robdekon + * @author Christoph Pohl ( christoph dot pohl at kit dot edu ) + * @date 06.09.22 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "PropertyDefinitionVisitors.h" + +#include <ArmarXCore/core/application/properties/PropertyDefinitionContainer.h> +#include <ArmarXCore/core/application/properties/PropertyDefinition.h> +#include <ArmarXCore/core/application/properties/PropertyUser.h> +#include <RobotAPI/libraries/aron/core/data/variant/All.h> +#include <RobotAPI/libraries/aron_component_config/VariantHelperFactory.h> + +#include "Util.h" + +#define INPUT_GUARD(i) \ +ARMARX_CHECK_NOT_NULL(i); \ +if (in_list_) return; + +namespace armarx::aron::component_config +{ + + void + PropertyDefinitionGetterVisitor::visitInt(DataInput& i, TypeInput& elementType) + { + INPUT_GUARD(i); + auto value = data::Int::DynamicCastAndCheck(i); + auto name = pathToName(i); + property_user_->getProperty(value->getValue(), name); + } + + void + PropertyDefinitionGetterVisitor::visitFloat(DataInput& f, TypeInput& elementType) + { + INPUT_GUARD(f); + auto value = data::Float::DynamicCastAndCheck(f); + auto name = pathToName(f); + property_user_->getProperty(value->getValue(), name); + } + + void + PropertyDefinitionGetterVisitor::visitDouble(DataInput& d, TypeInput& elementType) + { + INPUT_GUARD(d); + auto value = data::Double::DynamicCastAndCheck(d); + auto name = pathToName(d); + property_user_->getProperty(value->getValue(), name); + } + + void + PropertyDefinitionGetterVisitor::visitBool(DataInput& b, TypeInput& elementType) + { + INPUT_GUARD(b); + auto value = data::Bool::DynamicCastAndCheck(b); + auto name = pathToName(b); + property_user_->getProperty(value->getValue(), name); + } + + void + PropertyDefinitionGetterVisitor::visitString(DataInput& string, TypeInput& elementType) + { + INPUT_GUARD(string); + auto value = data::String::DynamicCastAndCheck(string); + auto name = pathToName(string); + auto property = property_user_->getProperty<std::string>(name); + if (not property.getValue().empty()){ + value->getValue() = property.getValueAndReplaceAllVars(); + } else + { + value->getValue() = ""; + } + } + + void + PropertyDefinitionGetterVisitor::visitListOnEnter(DataInput& o, TypeInput& t) + { + in_list_ = true; + const auto& name = pathToName(o); + const auto& type = type::List::DynamicCast(t)->getAcceptedType()->getDescriptor(); + if (std::find(implementedListDescriptors.begin(), implementedListDescriptors.end(), type) == + implementedListDescriptors.end()) + { + return; + } + auto old_list = data::List::DynamicCast(o); + old_list->clear(); + auto get_list = [this, & name]() -> std::vector<std::string> + { + std::string list; + property_user_->getProperty(list, name); + return simox::alg::split(list, ","); + }; + int i = 0; + std::vector<std::string> vector = get_list(); + std::for_each(vector.begin(), vector.end(), [&old_list, &i, &type](const auto& el) + { + old_list->addElement(factories::VariantHelper::make(type)->from_string(el, + old_list->getPath() + .withIndex(i))); + i++; + }); + + } + + void + PropertyDefinitionGetterVisitor::visitListOnExit(DataInput& o, TypeInput& t) + { + in_list_ = false; + } + + void + PropertyDefinitionGetterVisitor::visitIntEnum(DataInput& enumData, TypeInput& elementType) + { + auto data = data::Int::DynamicCastAndCheck(enumData); + auto name = pathToName(enumData); + property_user_->getProperty(data->getValue(), name); + } + + void + PropertyDefinitionGetterVisitor::visitUnknown(DataInput& unknown, TypeInput& elementType) + { + ARMARX_WARNING << "Unknown data encountered: " << (unknown ? unknown->getFullName() : "nullptr"); + } + + PropertyDefinitionGetterVisitor::PropertyDefinitionGetterVisitor(const armarx::PropertyUser& defs) : + property_user_(std::experimental::make_observer(&defs)), in_list_(false) + { + + } + + void + PropertyDefinitionGetterVisitor::visitDictOnEnter(std::shared_ptr<data::Variant>& o, + const std::shared_ptr<type::Variant>& t) + { + in_list_ = true; + const auto& name = pathToName(o); + const auto& type = type::Dict::DynamicCast(t)->getAcceptedType()->getDescriptor(); + if (std::find(implementedListDescriptors.begin(), implementedListDescriptors.end(), type) == + implementedListDescriptors.end()) + { + return; + } + auto old_dict = data::Dict::DynamicCast(o); + old_dict->clear(); + auto get_list = [this, & name]() -> std::vector<std::string> + { + std::string list; + property_user_->getProperty(list, name); + return simox::alg::split(list, ","); + }; + std::vector<std::string> vector = get_list(); + std::for_each(vector.begin(), vector.end(), [&old_dict, &type](const auto& el) + { + auto key_value = simox::alg::split(el, ":"); + old_dict->addElement(key_value.front(), + factories::VariantHelper::make(type)->from_string(key_value.back(), + old_dict->getPath() + .withElement(key_value.front()))); + }); + } + + void + PropertyDefinitionGetterVisitor::visitDictOnExit(std::shared_ptr<data::Variant>& elementData, + const std::shared_ptr<type::Variant>& elementType) + { + in_list_ = false; + } + + PropertyDefinitionGetterVisitor::MapElements + PropertyDefinitionGetterVisitor::getObjectElements(DataInput& o, TypeInput& t) + { + return component_config::getObjectElements(o, t); + } + + PropertyDefinitionGetterVisitor::MapElements + PropertyDefinitionGetterVisitor::getDictElements(DataInput& o, TypeInput& t) + { + return component_config::getDictElements(o, t); + } + + PropertyDefinitionGetterVisitor::ListElements + PropertyDefinitionGetterVisitor::getListElements(DataInput& o, TypeInput& t) + { + return component_config::getListElements(o, t); + } + + PropertyDefinitionGetterVisitor::PairElements + PropertyDefinitionGetterVisitor::getPairElements(DataInput& o, TypeInput& t) + { + return component_config::getPairElements(o, t); + } + + PropertyDefinitionGetterVisitor::TupleElements + PropertyDefinitionGetterVisitor::getTupleElements(DataInput& o, TypeInput& t) + { + return component_config::getTupleElements(o, t); + } + + type::Descriptor + PropertyDefinitionGetterVisitor::getDescriptor(DataInput& o, TypeInput& t) + { + return data::ConstTypedVariantVisitor::GetDescriptor(o, t); + } + + PropertyDefinitionSetterVisitor::PropertyDefinitionSetterVisitor(const PropertyDefinitionsPtr& defs) : + property_definitions_(std::experimental::make_observer(defs.get())) + { + } + + void + PropertyDefinitionSetterVisitor::visitAronVariant(const data::IntPtr& i, const type::IntPtr&) + { + INPUT_GUARD(i); + auto name = pathToName(i); + property_definitions_->defineOptionalProperty<int>(name, i->getValue()); + } + + void + PropertyDefinitionSetterVisitor::visitAronVariant(const data::FloatPtr& f, const type::FloatPtr&) + { + INPUT_GUARD(f); + auto name = pathToName(f); + property_definitions_->defineOptionalProperty<float>(name, f->getValue()); + } + + void + PropertyDefinitionSetterVisitor::visitAronVariant(const data::DoublePtr& d, const type::DoublePtr&) + { + INPUT_GUARD(d); + auto name = pathToName(d); + property_definitions_->defineOptionalProperty<double>(name, d->getValue()); + } + + void + PropertyDefinitionSetterVisitor::visitAronVariant(const data::BoolPtr& b, const type::BoolPtr&) + { + INPUT_GUARD(b); + auto name = pathToName(b); + property_definitions_->defineOptionalProperty<bool>(name, b->getValue()); + } + + void + PropertyDefinitionSetterVisitor::visitAronVariant(const data::StringPtr& string, const type::StringPtr&) + { + INPUT_GUARD(string); + auto name = pathToName(string); + property_definitions_->defineOptionalProperty<std::string>(name, string->getValue()); + } + + void + PropertyDefinitionSetterVisitor::visitAronVariant(const data::IntPtr& i, const type::IntEnumPtr& t) + { + INPUT_GUARD(i); + auto name = pathToName(i); + property_definitions_->defineOptionalProperty<int>(name, i->getValue()).map(t->getAcceptedValueMap()); + } + + void + PropertyDefinitionSetterVisitor::visitAronVariantOnEnter(const data::ListPtr& l, const type::ListPtr& t) + { + ARMARX_CHECK_NOT_NULL(l); + in_list_ = true; + const auto& name = pathToName(l); + const auto& type = t->getAcceptedType()->getDescriptor(); + if (std::find(implementedListDescriptors.begin(), implementedListDescriptors.end(), type) == + implementedListDescriptors.end()) + { + return; + } + const auto& input = l->getElements(); + std::string str; + std::vector<std::string> vector; + std::transform(input.begin(), input.end(), std::back_inserter(vector), [&type](const auto& el) + { + return factories::VariantHelper::make(type)->to_string(el); + }); + str = simox::alg::to_string(vector, ", "); + property_definitions_->defineOptionalProperty<std::string>(name, str); + } + + void + PropertyDefinitionSetterVisitor::visitAronVariantOnExit(const data::ListPtr&, const type::ListPtr&) + { + in_list_ = false; + } + + void + PropertyDefinitionSetterVisitor::visitAronVariantOnEnter(const data::DictPtr& d, const type::DictPtr& t) + { + in_list_ = true; + const auto& name = pathToName(d); + const auto& type = t->getAcceptedType()->getDescriptor(); + if (std::find(implementedListDescriptors.begin(), implementedListDescriptors.end(), type) == + implementedListDescriptors.end()) + { + return; + } + const auto& input = d->getElements(); + std::stringstream ss; + for (const auto& [key, el]: input) + { + ss << key << ":"; + ss << factories::VariantHelper::make(type)->to_string(el); + ss << ","; + } + std::string value = ss.str(); + if (not value.empty()) + { + value.pop_back(); + } + property_definitions_->defineOptionalProperty<std::string>(name, value); + } + + void + PropertyDefinitionSetterVisitor::visitAronVariantOnExit(const data::DictPtr&, const type::DictPtr&) + { + in_list_ = false; + } +} + +#undef INPUT_GUARD \ No newline at end of file diff --git a/source/RobotAPI/libraries/aron_component_config/PropertyDefinitionVisitors.h b/source/RobotAPI/libraries/aron_component_config/PropertyDefinitionVisitors.h new file mode 100644 index 0000000000000000000000000000000000000000..b99fb8b7b4a3fa40bdf19b3407e8ce1dcb1ac963 --- /dev/null +++ b/source/RobotAPI/libraries/aron_component_config/PropertyDefinitionVisitors.h @@ -0,0 +1,107 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package robdekon + * @author Christoph Pohl ( christoph dot pohl at kit dot edu ) + * @date 06.09.22 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +#include <experimental/memory> +#include <RobotAPI/libraries/aron/core/data/visitor/variant/VariantVisitor.h> +#include <ArmarXCore/core/application/properties/forward_declarations.h> + +namespace armarx::aron::component_config +{ + + class PropertyDefinitionSetterVisitor : public aron::data::RecursiveConstTypedVariantVisitor + { + public: + explicit PropertyDefinitionSetterVisitor(const armarx::PropertyDefinitionsPtr& defs); + + void visitAronVariant(const data::IntPtr&, const type::IntEnumPtr&) override; + + void visitAronVariant(const data::IntPtr&, const type::IntPtr&) override; + + void visitAronVariant(const data::FloatPtr&, const type::FloatPtr&) override; + + void visitAronVariant(const data::DoublePtr&, const type::DoublePtr&) override; + + void visitAronVariant(const data::BoolPtr&, const type::BoolPtr&) override; + + void visitAronVariant(const data::StringPtr&, const type::StringPtr&) override; + + void visitAronVariantOnEnter(const data::ListPtr&, const type::ListPtr&) override; + + void visitAronVariantOnExit(const data::ListPtr&, const type::ListPtr&) override; + + void visitAronVariantOnEnter(const data::DictPtr&, const type::DictPtr&) override; + + void visitAronVariantOnExit(const data::DictPtr&, const type::DictPtr&) override; + + private: + std::experimental::observer_ptr<PropertyDefinitionContainer> property_definitions_; + std::atomic<bool> in_list_{false}; + }; + + class PropertyDefinitionGetterVisitor : public aron::data::RecursiveTypedVisitor<data::VariantPtr, + const type::VariantPtr> + { + public: + explicit PropertyDefinitionGetterVisitor(const armarx::PropertyUser& defs); + + type::Descriptor getDescriptor(DataInput& o, TypeInput& t) override; + + MapElements getObjectElements(DataInput& o, TypeInput& t) override; + + MapElements getDictElements(DataInput& o, TypeInput& t) override; + + ListElements getListElements(DataInput& o, TypeInput& t) override; + + PairElements getPairElements(DataInput& o, TypeInput& t) override; + + TupleElements getTupleElements(DataInput& o, TypeInput& t) override; + + void visitInt(DataInput& elementData, TypeInput& elementType) override; + + void visitFloat(DataInput& elementData, TypeInput& elementType) override; + + void visitDouble(DataInput& elementData, TypeInput& elementType) override; + + void visitBool(DataInput& elementData, TypeInput& elementType) override; + + void visitString(DataInput& elementData, TypeInput& elementType) override; + + void visitUnknown(DataInput& elementData, TypeInput& elementType) override; + + void visitListOnEnter(DataInput& elementData, TypeInput& elementType) override; + + void visitListOnExit(DataInput& elementData, TypeInput& elementType) override; + + void visitDictOnEnter(DataInput& elementData, TypeInput& elementType) override; + + void visitDictOnExit(DataInput& elementData, TypeInput& elementType) override; + + void visitIntEnum(DataInput& elementData, TypeInput& elementType) override; + + private: + std::experimental::observer_ptr<const armarx::PropertyUser> property_user_; + std::atomic<bool> in_list_; + }; + +} \ No newline at end of file diff --git a/source/RobotAPI/libraries/aron_component_config/RemoteGui.h b/source/RobotAPI/libraries/aron_component_config/RemoteGui.h new file mode 100644 index 0000000000000000000000000000000000000000..e790688585294d69d7ff68e39ec54ad763b72046 --- /dev/null +++ b/source/RobotAPI/libraries/aron_component_config/RemoteGui.h @@ -0,0 +1,58 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package robdekon + * @author Christoph Pohl ( christoph dot pohl at kit dot edu ) + * @date 07.09.22 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +#include <ArmarXGui/libraries/RemoteGui/RemoteGui.h> +#include <RobotAPI/libraries/aron/core/data/variant/forward_declarations.h> +#include <RobotAPI/libraries/aron/core/codegeneration/cpp/AronGeneratedClass.h> +#include <RobotAPI/libraries/aron/core/data/variant/container/Dict.h> +#include "RemoteGuiVisitors.h" + +namespace armarx::RemoteGui +{ + template <typename T> concept isAronGenerated = std::is_base_of<armarx::aron::cpp::AronGeneratedClass, T>::value; + + template <typename AronStructT> + requires isAronGenerated<AronStructT> + detail::GroupBoxBuilder makeConfigGui( + const std::string& name, + const AronStructT& val) + { + aron::component_config::MakeConfigGuiVisitor vis(name); + armarx::aron::data::visitRecursive(vis, val.toAron(), val.ToAronType()); + return vis.getGroupBoxBuilder(); + } + +// template <typename AronStructT> +// requires isAronGenerated<AronStructT> +// void getValueFromMap(AronStructT& cfg, +// RemoteGui::ValueMap const& values, std::string const& name) +// { +// armarx::aron::component_config::GetValueFromMapVisitor vis(&values); +// auto data = std::static_pointer_cast<armarx::aron::data::Variant>(cfg.toAron()); +// auto type = cfg.ToAronType(); +// armarx::aron::data::visitRecursive(vis, data, type); +// cfg.fromAron(std::static_pointer_cast<armarx::aron::data::Dict>(data)); +// } + +} \ No newline at end of file diff --git a/source/RobotAPI/libraries/aron_component_config/RemoteGuiVisitors.cpp b/source/RobotAPI/libraries/aron_component_config/RemoteGuiVisitors.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9856fb3ccdbcee5426eec1d423fea9cacc2c2313 --- /dev/null +++ b/source/RobotAPI/libraries/aron_component_config/RemoteGuiVisitors.cpp @@ -0,0 +1,672 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package robdekon + * @author Christoph Pohl ( christoph dot pohl at kit dot edu ) + * @date 07.09.22 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "RemoteGuiVisitors.h" + +#include <SimoxUtility/math/convert/quat_to_rpy.h> +#include <SimoxUtility/math/convert/rpy_to_quat.h> + +#include <ArmarXCore/util/CPPUtility/Iterator.h> + +#include <ArmarXGui/libraries/RemoteGui/RemoteGui.h> + +#include <RobotAPI/libraries/aron/converter/eigen/EigenConverter.h> +#include <RobotAPI/libraries/aron/core/data/variant/All.h> +#include <RobotAPI/libraries/aron_component_config/VariantHelperFactory.h> + +#include "Util.h" + +#define INPUT_GUARD(i) \ + ARMARX_TRACE; \ + ARMARX_CHECK_NOT_NULL(i); \ + if (in_list_) \ + return; + +namespace armarx::aron::component_config +{ + + void + MakeConfigGuiVisitor::visitObjectOnEnter(DataInput& dict, TypeInput& /*unused*/) + { + INPUT_GUARD(dict); + + if (dict->getPath().hasElement()) + { + std::string name = pathToName(dict); + group_hierarchy_.emplace_back(std::make_shared<RemoteGui::detail::GroupBoxBuilder>( + RemoteGui::makeGroupBox(name))); + } + else + { + group_hierarchy_.push_back(builder_); + } + } + + void + MakeConfigGuiVisitor::visitObjectOnExit(DataInput& dict, TypeInput& /*j*/) + { + INPUT_GUARD(dict); + auto builder = *group_hierarchy_.back(); + group_hierarchy_.pop_back(); + if (!group_hierarchy_.empty()) + { + group_hierarchy_.back()->addChild(builder); + } + } + + void + MakeConfigGuiVisitor::visitInt(DataInput& i, TypeInput& /*unused*/) + { + INPUT_GUARD(i); + auto value = data::Int::DynamicCastAndCheck(i); + const auto& name = pathToName(i); + auto group = RemoteGui::makeHBoxLayout(name + "_layout"); + group.addChild(RemoteGui::makeLabel(name + "_label").value(i->getPath().getLastElement())); + group.addHSpacer(); + group.addChild(RemoteGui::makeIntSpinBox(name) + .value(value->getValue()) + .min(-1000) + .max(1000) + .toolTip(name)); + group_hierarchy_.back()->addChild(group); + } + + void + MakeConfigGuiVisitor::visitFloat(DataInput& f, TypeInput& /*unused*/) + { + INPUT_GUARD(f); + auto value = data::Float::DynamicCastAndCheck(f); + const auto& name = pathToName(f); + auto group = RemoteGui::makeHBoxLayout(name + "_layout"); + group.addChild(RemoteGui::makeLabel(name + "_label").value(f->getPath().getLastElement())); + group.addHSpacer(); + group.addChild(RemoteGui::makeFloatSpinBox(name) + .value(value->getValue()) + .min(-1000) + .max(1000) + .toolTip(name)); + group_hierarchy_.back()->addChild(group); + } + + void + MakeConfigGuiVisitor::visitDouble(DataInput& d, TypeInput& /*unused*/) + { + INPUT_GUARD(d); + auto value = data::Double::DynamicCastAndCheck(d); + const auto& name = pathToName(d); + auto group = RemoteGui::makeHBoxLayout(name + "_layout"); + group.addChild(RemoteGui::makeLabel(name + "_label").value(d->getPath().getLastElement())); + group.addHSpacer(); + group.addChild(RemoteGui::makeFloatSpinBox(name) + .value(value->getValue()) + .min(-1000) + .max(1000) + .toolTip(name)); + group_hierarchy_.back()->addChild(group); + } + + void + MakeConfigGuiVisitor::visitBool(DataInput& b, TypeInput& /*unused*/) + { + INPUT_GUARD(b); + auto value = data::Bool::DynamicCastAndCheck(b); + const auto& name = pathToName(b); + auto group = RemoteGui::makeHBoxLayout(name + "_layout"); + group.addChild(RemoteGui::makeLabel(name + "_label").value(b->getPath().getLastElement())); + group.addHSpacer(); + group.addChild( + RemoteGui::makeCheckBox(name).label("").value(value->getValue()).toolTip(name)); + group_hierarchy_.back()->addChild(group); + } + + void + MakeConfigGuiVisitor::visitString(DataInput& string, TypeInput& /*unused*/) + { + INPUT_GUARD(string); + auto value = data::String::DynamicCastAndCheck(string); + const auto& name = pathToName(string); + auto group = RemoteGui::makeHBoxLayout(name + "_layout"); + group.addChild( + RemoteGui::makeLabel(name + "_label").value(string->getPath().getLastElement())); + group.addHSpacer(); + group.addChild(RemoteGui::makeLineEdit(name).value(value->getValue()).toolTip(name)); + group_hierarchy_.back()->addChild(group); + } + + MakeConfigGuiVisitor::MakeConfigGuiVisitor(const std::string& name) : + builder_(std::make_unique<RemoteGui::detail::GroupBoxBuilder>(name)) + { + } + + RemoteGui::detail::GroupBoxBuilder + MakeConfigGuiVisitor::getGroupBoxBuilder() const + { + return *builder_; + } + + void + MakeConfigGuiVisitor::visitListOnEnter(DataInput& o, TypeInput& t) + { + in_list_ = true; + auto group = RemoteGui::makeSimpleGridLayout(pathToName(o) + "_grid").cols(20); + auto data = data::List::DynamicCastAndCheck(o); + auto type = type::List::DynamicCast(t)->getAcceptedType()->getDescriptor(); + if (std::find(implementedListDescriptors.begin(), implementedListDescriptors.end(), type) == + implementedListDescriptors.end()) + { + return; + } + for (const auto& el : data->getElements()) + { + group.addChild(RemoteGui::makeLineEdit(pathToName(el)) + .value(factories::VariantHelper::make(type)->to_string(el)), + 10); + group.addHSpacer(8); + group.addChild(RemoteGui::makeButton(pathToName(el) + "_button") + .label("-") + .toolTip("Remove List Element"), + 2); + } + group_hierarchy_.back()->addChild( + RemoteGui::makeGroupBox(pathToName(o) + "_grp") + .label(o->getPath().getLastElement()) + .collapsed(true) + .addChild(group) + .addChild(RemoteGui::makeButton(pathToName(o) + "_add") + .label("+") + .toolTip("Add new list entry."))); + } + + void + MakeConfigGuiVisitor::visitListOnExit(DataInput& /*unused*/, TypeInput& /*unused*/) + { + in_list_ = false; + } + + void + MakeConfigGuiVisitor::visitIntEnum(DataInput& o, TypeInput& t) + { + INPUT_GUARD(o); + auto data = data::Int::DynamicCastAndCheck(o); + auto type = type::IntEnum::DynamicCast(t); + const auto& name = pathToName(o); + auto group = RemoteGui::makeHBoxLayout(name + "_layout"); + group.addChild(RemoteGui::makeLabel(name + "_label").value(o->getPath().getLastElement())); + group.addHSpacer(); + group.addChild(RemoteGui::makeComboBox(name) + .options(type->getAcceptedValueNames()) + .value(type->getValueName(data->getValue())) + .toolTip(name)); + group_hierarchy_.back()->addChild(group); + } + void + MakeConfigGuiVisitor::visitMatrix(const std::shared_ptr<data::Variant>& q, + const std::shared_ptr<type::Variant>& t) + { + auto data = data::NDArray::DynamicCastAndCheck(q); + auto type = type::Matrix::DynamicCast(t); + const auto& cols = type->getCols(); + const auto& rows = type->getRows(); + const auto& name = pathToName(q); + auto group = RemoteGui::makeHBoxLayout(name + "_layout"); + group.addChild(RemoteGui::makeLabel(name + "_label").value(q->getPath().getLastElement())); + group.addHSpacer(); + + if (cols == 4 && rows == 4) + { + // Poses + const auto& matrix = aron::converter::AronEigenConverter::ConvertToMatrix4f(data); + group.addChild(RemoteGui::makePosRPYSpinBoxes(name).value(matrix).toolTip(name)); + } + else if ((cols == 3 and rows == 1) or (rows == 3 and cols == 1)) + { + // Positions + const auto& vector = aron::converter::AronEigenConverter::ConvertToVector3f(data); + group.addChild(RemoteGui::makeVector3fSpinBoxes(name).value(vector).toolTip(name)); + } + group_hierarchy_.back()->addChild(group); + } + + void + MakeConfigGuiVisitor::visitQuaternion(const std::shared_ptr<data::Variant>& q, + const std::shared_ptr<type::Variant>& t) + { + INPUT_GUARD(q); + auto data = data::NDArray::DynamicCastAndCheck(q); + auto type = type::Quaternion::DynamicCast(t); + const auto& quat = simox::math::quat_to_rpy( + aron::converter::AronEigenConverter::ConvertToQuaternionf(data)); + const auto& name = pathToName(q); + auto group = RemoteGui::makeHBoxLayout(name + "_layout"); + group.addChild(RemoteGui::makeLabel(name + "_label").value(q->getPath().getLastElement())); + group.addHSpacer(); + group.addChild(RemoteGui::makeVector3fSpinBoxes(name).value(quat).min(-M_PI).max(M_PI).steps(601).decimals(2).toolTip(name)); + group_hierarchy_.back()->addChild(group); + } + + void + MakeConfigGuiVisitor::visitDictOnEnter(const std::shared_ptr<data::Variant>& o, + const std::shared_ptr<type::Variant>& t) + { + in_list_ = true; + auto group = RemoteGui::makeSimpleGridLayout(pathToName(o) + "_grid").cols(20); + auto data = data::Dict::DynamicCastAndCheck(o); + auto type = type::Dict::DynamicCast(t)->getAcceptedType()->getDescriptor(); + if (std::find(implementedListDescriptors.begin(), implementedListDescriptors.end(), type) == + implementedListDescriptors.end()) + { + return; + } + for (const auto& el : data->getElements()) + { + group.addChild(RemoteGui::makeLineEdit(pathToName(el.second) + "_lbl").value(el.first), + 5); + group.addHSpacer(2); + group.addChild(RemoteGui::makeLineEdit(pathToName(el.second)) + .value(factories::VariantHelper::make(type)->to_string(el.second)), + 5); + group.addHSpacer(6); + group.addChild(RemoteGui::makeButton(pathToName(el.second) + "_button") + .label("-") + .toolTip("Remove List Element"), + 2); + } + group_hierarchy_.back()->addChild( + RemoteGui::makeGroupBox(pathToName(o) + "_grp") + .label(o->getPath().getLastElement()) + .collapsed(true) + .addChild(group) + .addChild(RemoteGui::makeButton(pathToName(o) + "_add") + .label("+") + .toolTip("Add new dict entry."))); + } + + void + MakeConfigGuiVisitor::visitDictOnExit(const std::shared_ptr<data::Variant>&, + const std::shared_ptr<type::Variant>&) + { + in_list_ = false; + } + + + GetValueFromMapVisitor::GetValueFromMapVisitor(armarx::RemoteGui::TabProxy* proxy) : + proxy_(std::experimental::make_observer(proxy)) + { + } + + void + GetValueFromMapVisitor::visitInt(DataInput& i, TypeInput&) + { + INPUT_GUARD(i); + auto value = data::Int::DynamicCastAndCheck(i); + const std::string name = pathToName(i); + auto gui_value = proxy_->getValue<int>(name); + if (value->getValue() != gui_value.get()) + { + if (proxy_->hasValueChanged(name)) + { + value->setValue(gui_value.get()); + i = value; + } + else + { + proxy_->setValue(value->getValue(), name); + } + } + } + + void + GetValueFromMapVisitor::visitFloat(DataInput& f, TypeInput&) + { + INPUT_GUARD(f); + auto value = data::Float::DynamicCastAndCheck(f); + const std::string name = pathToName(f); + auto gui_value = proxy_->getValue<float>(name); + if (value->getValue() != gui_value.get()) + { + if (proxy_->hasValueChanged(name)) + { + value->setValue(gui_value.get()); + f = value; + } + else + { + proxy_->setValue(value->getValue(), name); + } + } + } + + void + GetValueFromMapVisitor::visitDouble(DataInput& d, TypeInput&) + { + INPUT_GUARD(d); + auto value = data::Double::DynamicCastAndCheck(d); + const std::string name = pathToName(d); + // TODO: does double work here? + auto gui_value = proxy_->getValue<float>(name); + if (value->getValue() != gui_value.get()) + { + if (proxy_->hasValueChanged(name)) + { + value->setValue(gui_value.get()); + d = value; + } + else + { + proxy_->setValue(static_cast<float>(value->getValue()), name); + } + } + } + + void + GetValueFromMapVisitor::visitBool(DataInput& b, TypeInput&) + { + INPUT_GUARD(b); + auto value = data::Bool::DynamicCastAndCheck(b); + const std::string name = pathToName(b); + auto gui_value = proxy_->getValue<bool>(name); + if (value->getValue() != gui_value.get()) + { + if (proxy_->hasValueChanged(name)) + { + value->setValue(gui_value.get()); + b = value; + } + else + { + proxy_->setValue(value->getValue(), name); + } + } + } + + void + GetValueFromMapVisitor::visitString(DataInput& string, TypeInput&) + { + INPUT_GUARD(string); + auto value = data::String::DynamicCastAndCheck(string); + const std::string name = pathToName(string); + auto gui_value = proxy_->getValue<std::string>(name); + if (value->getValue() != gui_value.get()) + { + if (proxy_->hasValueChanged(name)) + { + value->setValue(gui_value.get()); + string = value; + } + else + { + proxy_->setValue(value->getValue(), name); + } + } + } + + type::Descriptor + GetValueFromMapVisitor::getDescriptor(DataInput& o, TypeInput& t) + { + return data::ConstTypedVariantVisitor::GetDescriptor(o, t); + } + + GetValueFromMapVisitor::MapElements + GetValueFromMapVisitor::getObjectElements(DataInput& o, TypeInput& t) + { + return component_config::getObjectElements(o, t); + } + + GetValueFromMapVisitor::MapElements + GetValueFromMapVisitor::getDictElements(DataInput& o, TypeInput& t) + { + return component_config::getDictElements(o, t); + } + + GetValueFromMapVisitor::ListElements + GetValueFromMapVisitor::getListElements(DataInput& o, TypeInput& t) + { + return component_config::getListElements(o, t); + } + + GetValueFromMapVisitor::PairElements + GetValueFromMapVisitor::getPairElements(DataInput& o, TypeInput& t) + { + return component_config::getPairElements(o, t); + } + + GetValueFromMapVisitor::TupleElements + GetValueFromMapVisitor::getTupleElements(DataInput& o, TypeInput& t) + { + return component_config::getTupleElements(o, t); + } + + void + GetValueFromMapVisitor::visitIntEnum(DataInput& o, TypeInput& t) + { + INPUT_GUARD(o); + auto data = data::Int::DynamicCastAndCheck(o); + auto type = type::IntEnum::DynamicCastAndCheck(t); + std::string str; + const std::string name = pathToName(o); + proxy_->getValue(str, pathToName(o)); + if (data->getValue() != type->getValue(str)) + { + if (proxy_->hasValueChanged(name)) + { + data->getValue() = type->getValue(str); + o = data; + } + else + { + proxy_->setValue(type->getValueName(data->getValue()), name); + } + } + } + + void + GetValueFromMapVisitor::visitListOnEnter(DataInput& o, TypeInput& t) + { + in_list_ = true; + auto data = data::List::DynamicCastAndCheck(o); + auto type = type::List::DynamicCast(t)->getAcceptedType()->getDescriptor(); + if (std::find(implementedListDescriptors.begin(), implementedListDescriptors.end(), type) == + implementedListDescriptors.end()) + { + return; + } + const auto& elements = data->getElements(); + for (const auto& [idx, el] : armarx::MakeIndexedContainer(elements)) + { + if (proxy_->getButtonClicked(pathToName(el) + "_button")) + { + data->removeElement(idx); + tab_rebuild_required_ = true; + } + auto gui_value = proxy_->getValue<std::string>(pathToName(el)).get(); + factories::VariantHelper::make(type)->set_value_from_string(el, gui_value); + } + if (proxy_->getButtonClicked(pathToName(o) + "_add")) + { + data->addElement(factories::VariantHelper::make(type)->from_string( + "", o->getPath().withIndex(data->childrenSize()))); + tab_rebuild_required_ = true; + } + } + + void + GetValueFromMapVisitor::visitListOnExit(DataInput&, TypeInput&) + { + in_list_ = false; + } + + bool + GetValueFromMapVisitor::tabRebuildRequired() const + { + return tab_rebuild_required_; + } + void + GetValueFromMapVisitor::visitMatrix(std::shared_ptr<data::Variant>& o, + const std::shared_ptr<type::Variant>& t) + { + INPUT_GUARD(o); + auto value = data::NDArray::DynamicCastAndCheck(o); + auto type = type::Matrix::DynamicCastAndCheck(t); + const std::string name = pathToName(o); + const auto& cols = type->getCols(); + const auto& rows = type->getRows(); + // TODO: does double work here? + if (cols == 4 && rows == 4) + { + auto gui_value = proxy_->getValue<Eigen::Matrix4f>(name); + auto config_value = converter::AronEigenConverter::ConvertToMatrix4f(value); + + if (config_value != gui_value.get()) + { + if (proxy_->hasValueChanged(name)) + { + auto variant = converter::AronEigenConverter::ConvertFromMatrix(gui_value.get()); + value->setData(gui_value.get().size() * sizeof(float), variant->getData()); + } + else + { + proxy_->setValue(config_value, name); + } + } + } else if ((cols == 3 and rows == 1) or (cols == 1 and rows == 3)) + { + auto gui_value = proxy_->getValue<Eigen::Vector3f>(name); + auto config_value = converter::AronEigenConverter::ConvertToVector3f(value); + + if (config_value != gui_value.get()) + { + if (proxy_->hasValueChanged(name)) + { + auto variant = converter::AronEigenConverter::ConvertFromMatrix(gui_value.get()); + value->setData(gui_value.get().size() * sizeof(float), variant->getData()); + } + else + { + proxy_->setValue(config_value, name); + } + } + } + + } + void + GetValueFromMapVisitor::visitQuaternion(std::shared_ptr<data::Variant>& o, + const std::shared_ptr<type::Variant>& t) + { + INPUT_GUARD(o); + auto value = data::NDArray::DynamicCastAndCheck(o); + const std::string name = pathToName(o); + // TODO: does double work here? + auto gui_value = proxy_->getValue<Eigen::Vector3f>(name); + const auto& quat = simox::math::quat_to_rpy(converter::AronEigenConverter::ConvertToQuaternionf(value)); + if (quat != gui_value.get()) + { + if (proxy_->hasValueChanged(name)) + { + auto variant = converter::AronEigenConverter::ConvertFromQuaternion(simox::math::rpy_to_quat(gui_value.get())); + value->setData(4 * sizeof(float), variant->getData()); + } + else + { + proxy_->setValue(quat, name); + } + } + } + + void + GetValueFromMapVisitor::visitDictOnEnter(std::shared_ptr<data::Variant>& o, + const std::shared_ptr<type::Variant>& t) + { + in_list_ = true; + auto data = data::Dict::DynamicCastAndCheck(o); + auto type = type::Dict::DynamicCast(t)->getAcceptedType()->getDescriptor(); + if (std::find(implementedListDescriptors.begin(), implementedListDescriptors.end(), type) == + implementedListDescriptors.end()) + { + return; + } + const auto& elements = data->getElements(); + std::map<std::string, std::string> changed_labels; + for (const auto& [idx, el] : elements) + { + const std::string name = pathToName(el); + if (proxy_->getButtonClicked(name + "_button")) + { + data->removeElement(idx); + tab_rebuild_required_ = true; + } + auto gui_value = proxy_->getValue<std::string>(name).get(); + auto gui_key = proxy_->getValue<std::string>(name + "_lbl").get(); + auto config_value = factories::VariantHelper::make(type)->to_string(el); + if (gui_value != config_value) + { + if (proxy_->hasValueChanged(name)) + { + factories::VariantHelper::make(type)->set_value_from_string(el, gui_value); + } + else + { + proxy_->setValue(config_value, name); + } + } + if (gui_key != idx) + { + if (proxy_->hasValueChanged(name + "_lbl")) + { + changed_labels.emplace(idx, gui_key); + } + else + { + proxy_->setValue(idx, name + "_lbl"); + } + } + } + // replace changed keys in map + for (const auto& [old_label, new_label] : changed_labels) + { + auto element = data->getElement(old_label); + data->removeElement(old_label); + auto variantHelper = factories::VariantHelper::make(type); + data->addElement(new_label, + variantHelper->from_string( + variantHelper->to_string(element), + o->getPath().withDetachedLastElement().withElement(new_label))); + tab_rebuild_required_ = true; + } + + if (proxy_->getButtonClicked(pathToName(o) + "_add")) + { + data->addElement("defaultKey", + factories::VariantHelper::make(type)->from_string( + "", o->getPath().withElement("defaultKey"))); + tab_rebuild_required_ = true; + } + } + + void + GetValueFromMapVisitor::visitDictOnExit(std::shared_ptr<data::Variant>&, + const std::shared_ptr<type::Variant>&) + { + in_list_ = false; + } +} // namespace armarx::aron::component_config + +#undef INPUT_GUARD \ No newline at end of file diff --git a/source/RobotAPI/libraries/aron_component_config/RemoteGuiVisitors.h b/source/RobotAPI/libraries/aron_component_config/RemoteGuiVisitors.h new file mode 100644 index 0000000000000000000000000000000000000000..e9324bf15e8429393beac81d2448aba9cbda26f2 --- /dev/null +++ b/source/RobotAPI/libraries/aron_component_config/RemoteGuiVisitors.h @@ -0,0 +1,133 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package robdekon + * @author Christoph Pohl ( christoph dot pohl at kit dot edu ) + * @date 07.09.22 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +#include <experimental/memory> +#include <RobotAPI/libraries/aron/core/data/visitor/variant/VariantVisitor.h> +#include <ArmarXCore/core/application/properties/forward_declarations.h> + +namespace armarx::RemoteGui +{ + namespace detail + { + class GroupBoxBuilder; + } + class TabProxy; + + class ValueVariant; + + using ValueMap = std::map<std::string, ValueVariant>; +} +namespace armarx::aron::component_config +{ + + class MakeConfigGuiVisitor : public data::RecursiveConstTypedVariantVisitor + { + public: + explicit MakeConfigGuiVisitor(const std::string& name); + + void visitObjectOnEnter(DataInput&, TypeInput&) override; + + void visitObjectOnExit(DataInput&, TypeInput&) override; + + void visitListOnEnter(DataInput&, TypeInput&) override; + + void visitListOnExit(DataInput&, TypeInput&) override; + + void visitDictOnEnter(DataInput&, TypeInput&) override; + + void visitDictOnExit(DataInput&, TypeInput&) override; + + void visitInt(DataInput&, TypeInput&) override; + + void visitIntEnum(DataInput&, TypeInput&) override; + + void visitFloat(DataInput&, TypeInput&) override; + + void visitDouble(DataInput&, TypeInput&) override; + + void visitBool(DataInput&, TypeInput&) override; + + void visitString(DataInput&, TypeInput&) override; + + void visitQuaternion(DataInput& input, TypeInput& typeInput) override; + + void visitMatrix(DataInput& input, TypeInput& typeInput) override; + + [[nodiscard]] RemoteGui::detail::GroupBoxBuilder getGroupBoxBuilder() const; + + private: + std::shared_ptr<RemoteGui::detail::GroupBoxBuilder> builder_; + std::vector<std::shared_ptr<RemoteGui::detail::GroupBoxBuilder>> group_hierarchy_; + std::atomic_bool in_list_{false}; + }; + + class GetValueFromMapVisitor : public aron::data::RecursiveTypedVisitor<data::VariantPtr, const type::VariantPtr> + { + public: + explicit GetValueFromMapVisitor(armarx::RemoteGui::TabProxy* proxy); + + type::Descriptor getDescriptor(DataInput&, TypeInput&) override; + + MapElements getObjectElements(DataInput&, TypeInput&) override; + + MapElements getDictElements(DataInput&, TypeInput&) override; + + ListElements getListElements(DataInput&, TypeInput&) override; + + PairElements getPairElements(DataInput&, TypeInput&) override; + + TupleElements getTupleElements(DataInput&, TypeInput&) override; + + void visitListOnEnter(DataInput&, TypeInput&) override; + + void visitListOnExit(DataInput&, TypeInput&) override; + + void visitDictOnEnter(DataInput&, TypeInput&) override; + + void visitDictOnExit(DataInput&, TypeInput&) override; + + void visitInt(DataInput&, TypeInput&) override; + + void visitIntEnum(DataInput&, TypeInput&) override; + + void visitFloat(DataInput&, TypeInput&) override; + + void visitDouble(DataInput&, TypeInput&) override; + + void visitBool(DataInput&, TypeInput&) override; + + void visitString(DataInput&, TypeInput&) override; + void visitMatrix(DataInput& elementData, TypeInput& elementType) override; + void visitQuaternion(DataInput& elementData, TypeInput& elementType) override; + + bool tabRebuildRequired() const; + + + private: + std::experimental::observer_ptr<armarx::RemoteGui::TabProxy> proxy_; + bool in_list_{false}; + bool tab_rebuild_required_{false}; + }; + +} \ No newline at end of file diff --git a/source/RobotAPI/libraries/aron_component_config/Util.h b/source/RobotAPI/libraries/aron_component_config/Util.h new file mode 100644 index 0000000000000000000000000000000000000000..c6c5561b7112714812896a4eec2269c1f767b597 --- /dev/null +++ b/source/RobotAPI/libraries/aron_component_config/Util.h @@ -0,0 +1,151 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package robdekon + * @author Christoph Pohl ( christoph dot pohl at kit dot edu ) + * @date 07.09.22 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +#include <memory> +#include <numeric> +#include <RobotAPI/libraries/aron/core/data/variant/Variant.h> + + +namespace armarx::aron::component_config +{ + + inline std::string pathToName(const std::shared_ptr<data::Variant>& v) + { + auto vector = v->getPath().getPath(); + auto path = v->getPath(); + path.setDelimeter("."); + path.setRootIdentifier(""); + auto string = path.toString(); + return string.substr(1, string.size()); + } + + template <typename DataInputT, typename TypeInputT> + std::map<std::string, + std::pair<typename std::remove_const<DataInputT>::type, typename std::remove_const<TypeInputT>::type>> + getObjectElements(DataInputT& o, TypeInputT& t) + { + std::map<std::string, std::pair<data::VariantPtr, type::VariantPtr>> ret; + auto x = data::Dict::DynamicCastAndCheck(o); + auto y = type::Object::DynamicCastAndCheck(t); + + ARMARX_CHECK_NOT_NULL(y); + + if (x) + { + for (const auto& [key, e]: x->getElements()) + { + auto ct = y->getMemberType(key); + ret.insert({key, {e, ct}}); + } + } + return ret; + } + + template <typename DataInputT, typename TypeInputT> + std::map<std::string, + std::pair<typename std::remove_const<DataInputT>::type, typename std::remove_const<TypeInputT>::type>> + getDictElements(DataInputT& o, TypeInputT& t) + { + std::map<std::string, std::pair<typename std::remove_const<DataInputT>::type, + typename std::remove_const<TypeInputT>::type>> ret; + auto x = data::Dict::DynamicCastAndCheck(o); + auto y = type::Dict::DynamicCastAndCheck(t); + + auto ac = y ? y->getAcceptedType() : nullptr; + + if (x) + { + for (const auto& [key, e]: x->getElements()) + { + ret.insert({key, {e, ac}}); + } + } + return ret; + } + + template <typename DataInputT, typename TypeInputT> + std::vector<std::pair<typename std::remove_const<DataInputT>::type, typename std::remove_const<TypeInputT>::type>> + getListElements(DataInputT& o, TypeInputT& t) + { + std::vector<std::pair<typename std::remove_const<DataInputT>::type, + typename std::remove_const<TypeInputT>::type>> ret; + auto x = data::List::DynamicCastAndCheck(o); + auto y = type::List::DynamicCastAndCheck(t); + + auto ac = y ? y->getAcceptedType() : nullptr; + + if (x) + { + for (const auto& e: x->getElements()) + { + ret.emplace_back(e, ac); + } + } + return ret; + } + + template <typename DataInputT, typename TypeInputT> + std::pair<std::pair<typename std::remove_const<DataInputT>::type, typename std::remove_const<TypeInputT>::type>, + std::pair<typename std::remove_const<DataInputT>::type, typename std::remove_const<TypeInputT>::type>> + getPairElements(DataInputT& o, TypeInputT& t) + { + auto x = data::List::DynamicCastAndCheck(o); + auto y = type::Pair::DynamicCastAndCheck(t); + + ARMARX_CHECK_NOT_NULL(y); + + if (x) + { + auto e0 = x->getElement(0); + auto ac0 = y->getFirstAcceptedType(); + auto e1 = x->getElement(1); + auto ac1 = y->getSecondAcceptedType(); + return {{e0, ac0}, + {e1, ac1}}; + } + return {}; + } + + template <typename DataInputT, typename TypeInputT> + std::vector<std::pair<typename std::remove_const<DataInputT>::type, typename std::remove_const<TypeInputT>::type>> + getTupleElements(DataInputT& o, TypeInputT& t) + { + std::vector<std::pair<data::VariantPtr, type::VariantPtr>> ret; + auto x = data::List::DynamicCastAndCheck(o); + auto y = type::Tuple::DynamicCastAndCheck(t); + + ARMARX_CHECK_NOT_NULL(y); + + if (x) + { + unsigned int i = 0; + for (const auto& e: x->getElements()) + { + auto ac = y->getAcceptedType(i++); + ret.emplace_back(e, ac); + } + } + return ret; + } +} \ No newline at end of file diff --git a/source/RobotAPI/libraries/aron_component_config/VariantHelperFactory.cpp b/source/RobotAPI/libraries/aron_component_config/VariantHelperFactory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1a9f09ecf7c7b2d90577ec8974c4968f4d88c213 --- /dev/null +++ b/source/RobotAPI/libraries/aron_component_config/VariantHelperFactory.cpp @@ -0,0 +1,210 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI + * @author Christoph Pohl ( christoph dot pohl at kit dot edu ) + * @date 04.11.22 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include <RobotAPI/libraries/aron/core/data/variant/All.h> +#include <ArmarXCore/core/application/properties/PropertyDefinitionContainer.h> +#include <ArmarXCore/core/application/properties/Property.h> +#include "VariantHelperFactory.h" + +namespace armarx::aron::component_config::products +{ + template <> + std::string + VariantHelper<type::Descriptor::INT>::to_string(const data::VariantPtr& ptr) const + { + ARMARX_TRACE; + return simox::alg::to_string(data::Int::DynamicCast(ptr)->getValue()); + } + + template <> + std::string + VariantHelper<type::Descriptor::BOOL>::to_string(const data::VariantPtr& ptr) const + { + ARMARX_TRACE; + return simox::alg::to_string(data::Bool::DynamicCast(ptr)->getValue()); + } + + template <> + std::string + VariantHelper<type::Descriptor::STRING>::to_string(const data::VariantPtr& ptr) const + { + ARMARX_TRACE; + return data::String::DynamicCast(ptr)->getValue(); + } + + template <> + std::string + VariantHelper<type::Descriptor::FLOAT>::to_string(const data::VariantPtr& ptr) const + { + ARMARX_TRACE; + return simox::alg::to_string(data::Float::DynamicCast(ptr)->getValue()); + } + + template <> + std::string + VariantHelper<type::Descriptor::INT_ENUM>::to_string(const data::VariantPtr& ptr) const + { + ARMARX_TRACE; + // TODO: this is should use the name of the enum value + return simox::alg::to_string(data::Int::DynamicCast(ptr)->getValue()); + } + + template <> + std::string + VariantHelper<type::Descriptor::DOUBLE>::to_string(const data::VariantPtr& ptr) const + { + ARMARX_TRACE; + return simox::alg::to_string(data::Double::DynamicCast(ptr)->getValue()); + } + + template <> + aron::data::VariantPtr + products::VariantHelper<type::Descriptor::INT>::from_string(const std::string& string, + const armarx::aron::Path& path) const + { + ARMARX_TRACE; + int i = string.empty() ? 0 : std::stoi(string); + return make_int(i, path); + } + + template <> + aron::data::VariantPtr + products::VariantHelper<type::Descriptor::FLOAT>::from_string(const std::string& string, + const armarx::aron::Path& path) const + { + ARMARX_TRACE; + float f = string.empty() ? 0 : std::stof(string); + return make_float(f, path); + } + + template <> + aron::data::VariantPtr + products::VariantHelper<type::Descriptor::DOUBLE>::from_string(const std::string& string, + const armarx::aron::Path& path) const + { + ARMARX_TRACE; + double d = string.empty() ? 0 : std::stod(string); + return make_double(d, path); + } + + template <> + aron::data::VariantPtr + products::VariantHelper<type::Descriptor::BOOL>::from_string(const std::string& string, + const armarx::aron::Path& path) const + { + ARMARX_TRACE; + if (string == "true") + { + return make_bool(true, path); + } else if (string == "false" or string.empty()) + { + return make_bool(false, path); + } + throw armarx::InvalidArgumentException("Boolean string has to be either true or false"); + } + + template <> + aron::data::VariantPtr + products::VariantHelper<type::Descriptor::INT_ENUM>::from_string(const std::string& string, + const armarx::aron::Path& path) const + { + // TODO: this might not work + ARMARX_TRACE; + return make_int(string.empty() ? 0 : std::stoi(string), path); + } + + template <> + aron::data::VariantPtr + products::VariantHelper<type::Descriptor::STRING>::from_string(const std::string& string, + const armarx::aron::Path& path) const + { + ARMARX_TRACE; + std::string formatted_string = ""; + if (not string.empty()) + { + formatted_string = armarx::FileSystemPathBuilder_ApplyFormattingAndResolveEnvAndCMakeVars(string); + } + return make_string(formatted_string, path); + } + + template <> + void + products::VariantHelper<type::Descriptor::INT>::set_value_from_string(const armarx::aron::data::VariantPtr& variant, + const std::string& string) const + { + ARMARX_TRACE; + data::Int::DynamicCast(variant)->getValue() = std::stoi(string); + } + + template <> + void + products::VariantHelper<type::Descriptor::FLOAT>::set_value_from_string(const armarx::aron::data::VariantPtr& variant, + const std::string& string) const + { + ARMARX_TRACE; + data::Float::DynamicCast(variant)->getValue() = std::stof(string); + } + + template <> + void + products::VariantHelper<type::Descriptor::DOUBLE>::set_value_from_string(const armarx::aron::data::VariantPtr& variant, + const std::string& string) const + { + ARMARX_TRACE; + data::Double::DynamicCast(variant)->getValue() = std::stod(string); + } + + template <> + void + products::VariantHelper<type::Descriptor::BOOL>::set_value_from_string(const armarx::aron::data::VariantPtr& variant, + const std::string& string) const + { + ARMARX_TRACE; + data::Bool::DynamicCast(variant)->getValue() = string == "true"; + } + + template <> + void + products::VariantHelper<type::Descriptor::STRING>::set_value_from_string(const armarx::aron::data::VariantPtr& variant, + const std::string& string) const + { + ARMARX_TRACE; + data::String::DynamicCast(variant)->getValue() = string; + } + + template <> + void + products::VariantHelper<type::Descriptor::INT_ENUM>::set_value_from_string(const armarx::aron::data::VariantPtr& variant, + const std::string& string) const + { + ARMARX_TRACE; + data::Int::DynamicCast(variant)->getValue() = std::stoi(string); + } + + + template struct products::VariantHelper<type::Descriptor::INT>; + template struct products::VariantHelper<type::Descriptor::STRING>; + template struct products::VariantHelper<type::Descriptor::BOOL>; + template struct products::VariantHelper<type::Descriptor::FLOAT>; + template struct products::VariantHelper<type::Descriptor::DOUBLE>; + template struct products::VariantHelper<type::Descriptor::INT_ENUM>; +} \ No newline at end of file diff --git a/source/RobotAPI/libraries/aron_component_config/VariantHelperFactory.h b/source/RobotAPI/libraries/aron_component_config/VariantHelperFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..d2dfb921a7f5cea9e55c6fd96258f258a965c9e3 --- /dev/null +++ b/source/RobotAPI/libraries/aron_component_config/VariantHelperFactory.h @@ -0,0 +1,174 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package RobotAPI + * @author Christoph Pohl ( christoph dot pohl at kit dot edu ) + * @date 04.11.22 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +#include <ArmarXCore/util/CPPUtility/SelfRegisteringFactory.h> +#include <ArmarXCore/core/application/properties/forward_declarations.h> +#include <RobotAPI/libraries/aron/core/Descriptor.h> +#include <RobotAPI/libraries/aron/core/data/variant/Variant.h> + +namespace armarx::aron::component_config +{ + namespace factories + { + struct VariantHelper : armarx::Factory<VariantHelper, type::Descriptor> + { + explicit VariantHelper(Key) + { + }; + + virtual ~VariantHelper() = default; + + virtual std::string to_string(const armarx::aron::data::VariantPtr&) const = 0; + + virtual void + set_value_from_string(const armarx::aron::data::VariantPtr&, const std::string& string) const = 0; + + virtual aron::data::VariantPtr from_string(const std::string&, const armarx::aron::Path& path) const = 0; + }; + } + namespace products + { + template <type::Descriptor DescT> + struct VariantHelper : factories::VariantHelper::Registrar<VariantHelper<DescT>> + { + using RegistrarT = factories::VariantHelper::Registrar<VariantHelper<DescT>>; + static constexpr type::Descriptor id = DescT; + + explicit VariantHelper() : RegistrarT(typename RegistrarT::Registration()) + { + }; + + [[nodiscard]] std::string to_string(const data::VariantPtr& ptr) const override; + + void set_value_from_string(const armarx::aron::data::VariantPtr& variant, + const std::string& string) const override; + + [[nodiscard]] aron::data::VariantPtr + from_string(const std::string&, const armarx::aron::Path& path) const override; + }; + + + } + + template <> + std::string + products::VariantHelper<type::Descriptor::INT>::to_string(const data::VariantPtr& ptr) const; + + template <> + aron::data::VariantPtr + products::VariantHelper<type::Descriptor::INT>::from_string(const std::string&, + const armarx::aron::Path& path) const; + + template <> + void + products::VariantHelper<type::Descriptor::INT>::set_value_from_string(const armarx::aron::data::VariantPtr&, + const std::string&) const; + + template <> + std::string + products::VariantHelper<type::Descriptor::FLOAT>::to_string(const data::VariantPtr& ptr) const; + + template <> + aron::data::VariantPtr + products::VariantHelper<type::Descriptor::FLOAT>::from_string(const std::string&, + const armarx::aron::Path& path) const; + + template <> + void + products::VariantHelper<type::Descriptor::FLOAT>::set_value_from_string(const armarx::aron::data::VariantPtr&, + const std::string&) const; + + template <> + std::string + products::VariantHelper<type::Descriptor::BOOL>::to_string(const data::VariantPtr& ptr) const; + + template <> + aron::data::VariantPtr + products::VariantHelper<type::Descriptor::BOOL>::from_string(const std::string&, + const armarx::aron::Path& path) const; + + template <> + void + products::VariantHelper<type::Descriptor::BOOL>::set_value_from_string(const armarx::aron::data::VariantPtr&, + const std::string&) const; + + template <> + std::string + products::VariantHelper<type::Descriptor::STRING>::to_string(const data::VariantPtr& ptr) const; + + template <> + aron::data::VariantPtr + products::VariantHelper<type::Descriptor::STRING>::from_string(const std::string&, + const armarx::aron::Path& path) const; + + template <> + void + products::VariantHelper<type::Descriptor::STRING>::set_value_from_string(const armarx::aron::data::VariantPtr&, + const std::string&) const; + + template <> + std::string + products::VariantHelper<type::Descriptor::DOUBLE>::to_string(const data::VariantPtr& ptr) const; + + template <> + aron::data::VariantPtr + products::VariantHelper<type::Descriptor::DOUBLE>::from_string(const std::string&, + const armarx::aron::Path& path) const; + + template <> + void + products::VariantHelper<type::Descriptor::DOUBLE>::set_value_from_string(const armarx::aron::data::VariantPtr&, + const std::string&) const; + + template <> + std::string + products::VariantHelper<type::Descriptor::INT_ENUM>::to_string(const data::VariantPtr& ptr) const; + + template <> + aron::data::VariantPtr + products::VariantHelper<type::Descriptor::INT_ENUM>::from_string(const std::string&, + const armarx::aron::Path& path) const; + + template <> + void + products::VariantHelper<type::Descriptor::INT_ENUM>::set_value_from_string(const armarx::aron::data::VariantPtr&, + const std::string&) const; + + + static inline const std::list<type::Descriptor> implementedListDescriptors = { + type::Descriptor::INT_ENUM, + type::Descriptor::INT, + type::Descriptor::STRING, + type::Descriptor::FLOAT, + type::Descriptor::DOUBLE, + type::Descriptor::BOOL, + }; + extern template struct products::VariantHelper<type::Descriptor::INT>; + extern template struct products::VariantHelper<type::Descriptor::FLOAT>; + extern template struct products::VariantHelper<type::Descriptor::DOUBLE>; + extern template struct products::VariantHelper<type::Descriptor::STRING>; + extern template struct products::VariantHelper<type::Descriptor::BOOL>; + extern template struct products::VariantHelper<type::Descriptor::INT_ENUM>; +} +