Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • sw/armarx/robot-api
  • uwkce_singer/robot-api
  • untcg_hofmann/robot-api
  • ulqba_korosakov/RobotAPI
4 results
Show changes
Commits on Source (5)
......@@ -482,6 +482,12 @@ void armarx::ArVizStorage::recordBatch(armarx::viz::data::RecordingBatch& batch)
batch.header.lastRevision = last.revision;
batch.header.firstTimestampInMicroSeconds = first.timestampInMicroseconds;
batch.header.lastTimestampInMicroSeconds = last.timestampInMicroseconds;
if (firstBatch)
{
batch.initialState = currentState;
firstBatch = false;
}
std::string filename = batchFileName(batch.header);
std::filesystem::path filePath = recordingPath / filename;
......@@ -571,6 +577,7 @@ std::string armarx::ArVizStorage::startRecording(std::string const& newRecording
recordingMetaData.batchHeaders.clear();
}
firstBatch = true;
recordingTask = new RunningTask<ArVizStorage>(this, &ArVizStorage::record);
recordingTask->start();
......@@ -640,7 +647,7 @@ armarx::viz::data::RecordingBatch armarx::ArVizStorage::getRecordingBatch(std::s
return result;
}
if (batchIndex < 0 && batchIndex >= (long)recording->batchHeaders.size())
if (batchIndex < 0 || batchIndex >= (long)recording->batchHeaders.size())
{
ARMARX_WARNING << "Batch index is not valid. Index = " << batchIndex
<< "Batch count: " << recording->batchHeaders.size();
......
......@@ -110,6 +110,7 @@ namespace armarx
std::vector<viz::data::TimestampedLayerUpdate> currentState;
std::vector<viz::data::TimestampedLayerUpdate> history;
long revision = 0;
bool firstBatch = false;
// We store all interactions in here
// But we curate them, so that only the last interaction with an element is reported
......
......@@ -24,12 +24,13 @@
#pragma once
// STD/STL
#include <memory>
#include <map>
#include <memory>
#include <optional>
// ArmarX
#include <SimoxUtility/xml.h>
#include <ArmarXCore/core/rapidxml/wrapper/RapidXmlReader.h>
/**
......@@ -116,36 +117,80 @@ namespace armarx::aron::typereader::xml
};
// Replacements ({tagName, {replacementsTag, additionalAronDTOXMLIncludePackagePath}, deprecationwarning})
const std::map<std::string, Replacement> REPLACEMENTS =
{
{"int", {"<int32 />", {}, "The <int />-tag is deprecated. Please use <int32 /> instead."}},
{"long", {"<int64 />", {}, "The <long />-tag is deprecated. Please use <int64 /> instead."}},
{"float", {"<float32 />", {}, "The <float />-tag is deprecated. Please use <float32 /> instead."}},
{"double", {"<float64 />", {}, "The <double />-tag is deprecated. Please use <float64 /> instead."}},
{"position", {"<matrix rows='3' cols='1' type='float32' />", {}, ""}},
{"pose", {"<matrix rows='4' cols='4' type='float32' />", {}, ""}},
{"orientation", {"<quaternion type='float32' />", {}, ""}},
const std::map<std::string, Replacement> REPLACEMENTS = {
{"int",
{"<int32 />", {}, "The <int />-tag is deprecated. Please use <int32 /> instead."}},
{"long",
{"<int64 />", {}, "The <long />-tag is deprecated. Please use <int64 /> instead."}},
{"float",
{"<float32 />",
{},
"The <float />-tag is deprecated. Please use <float32 /> instead."}},
{"double",
{"<float64 />",
{},
"The <double />-tag is deprecated. Please use <float64 /> instead."}},
// should that be deprecated?
{"position", {"<matrix rows='3' cols='1' type='float32' />", {}, ""}},
{"pose", {"<matrix rows='4' cols='4' type='float32' />", {}, ""}},
{"orientation", {"<quaternion type='float32' />", {}, ""}},
// values similar to eigen
{"quaternionf", {"<quaternion type='float32' />", {}, ""}},
{"quaterniond", {"<quaternion type='float64' />", {}, ""}},
{"vector2f", {"<matrix rows='2' cols='1' type='float32' />", {}, ""}},
{"vector2d", {"<matrix rows='2' cols='1' type='float64' />", {}, ""}},
{"vector3f", {"<matrix rows='3' cols='1' type='float32' />", {}, ""}},
{"vector3d", {"<matrix rows='3' cols='1' type='float64' />", {}, ""}},
{"vector4f", {"<matrix rows='4' cols='1' type='float32' />", {}, ""}},
{"vector4d", {"<matrix rows='4' cols='1' type='float64' />", {}, ""}},
{"matrix2f", {"<matrix rows='2' cols='2' type='float32' />", {}, ""}},
{"matrix2d", {"<matrix rows='2' cols='2' type='float64' />", {}, ""}},
{"matrix3f", {"<matrix rows='3' cols='3' type='float32' />", {}, ""}},
{"matrix3d", {"<matrix rows='3' cols='3' type='float64' />", {}, ""}},
{"matrix4f", {"<matrix rows='4' cols='4' type='float32' />", {}, ""}},
{"matrix4d", {"<matrix rows='4' cols='4' type='float64' />", {}, ""}},
// You can also add replacements for arondtos here!
// structure: {xml-identifier, {replacement, auto-include}, deprecationwarning}
{"datetime", {"<armarx::arondto::DateTime />", {"RobotAPI", "libraries/aron/common/aron/time.xml"}, ""}},
{"time", {"<armarx::arondto::DateTime />", {"RobotAPI", "libraries/aron/common/aron/time.xml"}, ""}},
{"duration", {"<armarx::arondto::Duration />", {"RobotAPI", "libraries/aron/common/aron/time.xml"}, ""}},
{"framedposition", {"<armarx::arondto::FramedPosition />", {"RobotAPI", "libraries/aron/common/aron/framed.xml"}, ""}},
{"framedorientation", {"<armarx::arondto::FramedOrientation />", {"RobotAPI", "libraries/aron/common/aron/framed.xml"}, ""}},
{"framedpose", {"<armarx::arondto::FramedPose />", {"RobotAPI", "libraries/aron/common/aron/framed.xml"}, ""}}
};
}
{"datetime",
{"<armarx::arondto::DateTime />",
{"RobotAPI", "libraries/aron/common/aron/time.xml"},
""}},
{"time",
{"<armarx::arondto::DateTime />",
{"RobotAPI", "libraries/aron/common/aron/time.xml"},
""}},
{"duration",
{"<armarx::arondto::Duration />",
{"RobotAPI", "libraries/aron/common/aron/time.xml"},
""}},
{"framedposition",
{"<armarx::arondto::FramedPosition />",
{"RobotAPI", "libraries/aron/common/aron/framed.xml"},
""}},
{"framedorientation",
{"<armarx::arondto::FramedOrientation />",
{"RobotAPI", "libraries/aron/common/aron/framed.xml"},
""}},
{"framedpose",
{"<armarx::arondto::FramedPose />",
{"RobotAPI", "libraries/aron/common/aron/framed.xml"},
""}}};
} // namespace constantes
namespace util
{
std::optional<RapidXmlReaderNode> GetFirstNodeWithTag(const RapidXmlReaderNode& node, const std::string& name);
std::optional<RapidXmlReaderNode> GetFirstNodeWithTag(const RapidXmlReaderNode& node,
const std::string& name);
void EnforceAttribute(const RapidXmlReaderNode& node, const std::string& att);
bool HasAttribute(const RapidXmlReaderNode& node, const std::string& att);
std::string GetAttribute(const RapidXmlReaderNode& node, const std::string& att);
std::string GetAttributeWithDefault(const RapidXmlReaderNode& node, const std::string& att, const std::string& def);
std::string GetAttributeWithDefault(const RapidXmlReaderNode& node,
const std::string& att,
const std::string& def);
bool AttributeIsTrue(const RapidXmlReaderNode& node, const std::string& att);
bool HasTagName(const RapidXmlReaderNode& node, const std::string& name);
......@@ -158,5 +203,5 @@ namespace armarx::aron::typereader::xml
void EnforceChildSize(const RapidXmlReaderNode& node, const size_t size);
void EnforceChildSizeGreaterEqual(const RapidXmlReaderNode& node, const size_t size);
void EnforceChildSizeGreater(const RapidXmlReaderNode& node, const size_t size);
}
}
} // namespace util
} // namespace armarx::aron::typereader::xml
......@@ -29,29 +29,21 @@
namespace armarx::aron
{
Path::Path() :
rootIdentifier("_ARON"),
delimeter("->")
Path::Path() : rootIdentifier(DEFAULT_ROOT_IDENTIFIER), delimeter(DEFAULT_DELIMETER)
{
}
Path::Path(const std::vector<std::string>& p) :
rootIdentifier("_ARON"),
delimeter("->"),
path(p)
rootIdentifier(DEFAULT_ROOT_IDENTIFIER), delimeter(DEFAULT_DELIMETER), path(p)
{
}
Path::Path(const Path& p) :
rootIdentifier(p.getRootIdentifier()),
delimeter(p.getDelimeter()),
path(p.getPath())
rootIdentifier(p.getRootIdentifier()), delimeter(p.getDelimeter()), path(p.getPath())
{
}
Path::Path(const Path& pa, const std::vector<std::string>& p) :
Path(pa)
Path::Path(const Path& pa, const std::vector<std::string>& p) : Path(pa)
{
for (const std::string& s : p)
{
......@@ -59,65 +51,78 @@ namespace armarx::aron
}
}
void Path::setRootIdentifier(const std::string& s)
void
Path::setRootIdentifier(const std::string& s)
{
rootIdentifier = s;
}
std::string Path::getRootIdentifier() const
std::string
Path::getRootIdentifier() const
{
return rootIdentifier;
}
void Path::setDelimeter(const std::string& d)
void
Path::setDelimeter(const std::string& d)
{
delimeter = d;
}
std::string Path::getDelimeter() const
std::string
Path::getDelimeter() const
{
return delimeter;
}
void Path::append(const std::string& str)
void
Path::append(const std::string& str)
{
path.push_back(str);
}
std::vector<std::string> Path::getPath() const
std::vector<std::string>
Path::getPath() const
{
return path;
}
std::string Path::getLastElement() const
std::string
Path::getLastElement() const
{
if (!hasElement())
{
throw error::AronException(__PRETTY_FUNCTION__, "Try to access last element of empty vector.");
throw error::AronException(__PRETTY_FUNCTION__,
"Try to access last element of empty vector.");
}
return path.back();
}
std::string Path::getFirstElement() const
std::string
Path::getFirstElement() const
{
if (!hasElement())
{
throw error::AronException(__PRETTY_FUNCTION__, "Try to access last element of empty vector.");
throw error::AronException(__PRETTY_FUNCTION__,
"Try to access last element of empty vector.");
}
return path[0];
}
bool Path::hasElement() const
bool
Path::hasElement() const
{
return path.size() > 0;
}
size_t Path::size() const
size_t
Path::size() const
{
return path.size();
}
std::string Path::toString() const
std::string
Path::toString() const
{
std::stringstream ss;
ss << rootIdentifier;
......@@ -128,7 +133,10 @@ namespace armarx::aron
return ss.str();
}
Path Path::FromString(const std::string& s, const std::string& rootIdentifier, const std::string& delimeter)
Path
Path::FromString(const std::string& s,
const std::string& rootIdentifier,
const std::string& delimeter)
{
std::vector<std::string> elements = simox::alg::split(s, delimeter);
if (elements.size())
......@@ -138,7 +146,8 @@ namespace armarx::aron
return Path(elements);
}
Path Path::withIndex(int i, bool escape) const
Path
Path::withIndex(int i, bool escape) const
{
std::string el = std::to_string(i);
if (escape)
......@@ -148,7 +157,8 @@ namespace armarx::aron
return Path(*this, {el});
}
Path Path::withElement(const std::string& s, bool escape) const
Path
Path::withElement(const std::string& s, bool escape) const
{
std::string el = s;
if (escape)
......@@ -158,7 +168,8 @@ namespace armarx::aron
return Path(*this, {el});
}
Path Path::withAcceptedType(bool escape) const
Path
Path::withAcceptedType(bool escape) const
{
std::string el = "::accepted_type";
if (escape)
......@@ -168,7 +179,8 @@ namespace armarx::aron
return Path(*this, {el});
}
Path Path::withAcceptedTypeIndex(int i, bool escape) const
Path
Path::withAcceptedTypeIndex(int i, bool escape) const
{
std::string el = "::accepted_type_" + std::to_string(i);
if (escape)
......@@ -178,7 +190,8 @@ namespace armarx::aron
return Path(*this, {el});
}
Path Path::withDetachedLastElement() const
Path
Path::withDetachedLastElement() const
{
std::vector<std::string> p = path;
p.pop_back();
......@@ -188,7 +201,8 @@ namespace armarx::aron
return ret;
}
Path Path::withDetachedFirstElement() const
Path
Path::withDetachedFirstElement() const
{
std::vector<std::string> p = path;
p.erase(p.begin());
......@@ -198,7 +212,8 @@ namespace armarx::aron
return ret;
}
Path Path::getWithoutPrefix(const Path& pref) const
Path
Path::getWithoutPrefix(const Path& pref) const
{
unsigned int firstWithoutMatch = 0;
for (const std::string& el : pref.getPath())
......@@ -212,11 +227,12 @@ namespace armarx::aron
firstWithoutMatch++;
}
}
std::vector<std::string> elementsWithoutPrefix(path.begin() + firstWithoutMatch, path.end());
std::vector<std::string> elementsWithoutPrefix(path.begin() + firstWithoutMatch,
path.end());
auto ret = Path(elementsWithoutPrefix);
ret.setRootIdentifier(rootIdentifier);
ret.setDelimeter(delimeter);
return ret;
}
}
} // namespace armarx::aron
......@@ -24,8 +24,8 @@
#pragma once
// STD/STL
#include<vector>
#include<string>
#include <string>
#include <vector>
namespace armarx::aron
{
......@@ -36,6 +36,9 @@ namespace armarx::aron
class Path
{
public:
static const constexpr char* DEFAULT_ROOT_IDENTIFIER = "_ARON";
static const constexpr char* DEFAULT_DELIMETER = "->";
/// default constructor
Path();
......@@ -69,7 +72,9 @@ namespace armarx::aron
std::string getDelimeter() const;
std::string toString() const;
static Path FromString(const std::string&, const std::string& rootIdentifier = "_ARON", const std::string& delimeter = "->");
static Path FromString(const std::string&,
const std::string& rootIdentifier = DEFAULT_ROOT_IDENTIFIER,
const std::string& delimeter = DEFAULT_DELIMETER);
Path withDetachedFirstElement() const;
Path withDetachedLastElement() const;
......@@ -83,4 +88,4 @@ namespace armarx::aron
std::string delimeter;
std::vector<std::string> path;
};
}
} // namespace armarx::aron