From fdec47301dac2cd247857c945aefe06d8c35c88a Mon Sep 17 00:00:00 2001 From: "ran.liao" Date: Tue, 16 Jan 2024 10:25:52 +0900 Subject: [PATCH] test --- src/libopenrave/environment.cpp | 80 ++++++------- src/libopenrave/kinbody.cpp | 36 +++--- src/libopenrave/kinbodygeometry.cpp | 54 ++++----- src/libopenrave/kinbodyjoint.cpp | 174 ++++++++++++++-------------- src/libopenrave/kinbodylink.cpp | 58 +++++----- 5 files changed, 201 insertions(+), 201 deletions(-) diff --git a/src/libopenrave/environment.cpp b/src/libopenrave/environment.cpp index 7816bf9449..40fc18242f 100644 --- a/src/libopenrave/environment.cpp +++ b/src/libopenrave/environment.cpp @@ -61,47 +61,47 @@ void EnvironmentBase::EnvironmentBaseInfo::SerializeJSON(rapidjson::Value& rEnvI // for all SerializeJSON, we clear the output rEnvInfo.SetObject(); - if (_isDiffResult) { - if (IsModifiedField(EnvironmentBaseInfo::EIF_UnitInfo)) { - orjson::SetJsonValueByKey(rEnvInfo, "unitInfo", _unitInfo, allocator); - } - if (IsModifiedField(EnvironmentBaseInfo::EIF_Description)) { - orjson::SetJsonValueByKey(rEnvInfo, "description", _description, allocator); - } - if (IsModifiedField(EnvironmentBaseInfo::EIF_Keywords)) { - orjson::SetJsonValueByKey(rEnvInfo, "keywords", _keywords, allocator); - } - if (IsModifiedField(EnvironmentBaseInfo::EIF_Int64Parameters)) { - if( _uInt64Parameters.size() > 0 ) { - rapidjson::Value rUInt64Parameters; - rUInt64Parameters.SetArray(); - FOREACHC(it, _uInt64Parameters) { - rapidjson::Value rInt64Parameter; - rInt64Parameter.SetObject(); - orjson::SetJsonValueByKey(rInt64Parameter, "id", it->first, allocator); - orjson::SetJsonValueByKey(rInt64Parameter, "value", it->second, allocator); - rUInt64Parameters.PushBack(rInt64Parameter, allocator); - } - rEnvInfo.AddMember("uint64Parameters", rUInt64Parameters, allocator); - } - } + // if (_isDiffResult) { + // if (IsModifiedField(EnvironmentBaseInfo::EIF_UnitInfo)) { + // orjson::SetJsonValueByKey(rEnvInfo, "unitInfo", _unitInfo, allocator); + // } + // if (IsModifiedField(EnvironmentBaseInfo::EIF_Description)) { + // orjson::SetJsonValueByKey(rEnvInfo, "description", _description, allocator); + // } + // if (IsModifiedField(EnvironmentBaseInfo::EIF_Keywords)) { + // orjson::SetJsonValueByKey(rEnvInfo, "keywords", _keywords, allocator); + // } + // if (IsModifiedField(EnvironmentBaseInfo::EIF_Int64Parameters)) { + // if( _uInt64Parameters.size() > 0 ) { + // rapidjson::Value rUInt64Parameters; + // rUInt64Parameters.SetArray(); + // FOREACHC(it, _uInt64Parameters) { + // rapidjson::Value rInt64Parameter; + // rInt64Parameter.SetObject(); + // orjson::SetJsonValueByKey(rInt64Parameter, "id", it->first, allocator); + // orjson::SetJsonValueByKey(rInt64Parameter, "value", it->second, allocator); + // rUInt64Parameters.PushBack(rInt64Parameter, allocator); + // } + // rEnvInfo.AddMember("uint64Parameters", rUInt64Parameters, allocator); + // } + // } - if (_vBodyInfos.size() > 0) { - rapidjson::Value rBodiesValue; - rBodiesValue.SetArray(); - rBodiesValue.Reserve(_vBodyInfos.size(), allocator); - for (const KinBody::KinBodyInfoPtr& pinfo : _vBodyInfos) { - if (!pinfo) { - continue; - } - rapidjson::Value bodyValue; - pinfo->SerializeJSON(bodyValue, allocator, fUnitScale, options); - rBodiesValue.PushBack(bodyValue, allocator); - } - rEnvInfo.AddMember("bodies", rBodiesValue, allocator); - } - return; - } + // if (_vBodyInfos.size() > 0) { + // rapidjson::Value rBodiesValue; + // rBodiesValue.SetArray(); + // rBodiesValue.Reserve(_vBodyInfos.size(), allocator); + // for (const KinBody::KinBodyInfoPtr& pinfo : _vBodyInfos) { + // if (!pinfo) { + // continue; + // } + // rapidjson::Value bodyValue; + // pinfo->SerializeJSON(bodyValue, allocator, fUnitScale, options); + // rBodiesValue.PushBack(bodyValue, allocator); + // } + // rEnvInfo.AddMember("bodies", rBodiesValue, allocator); + // } + // return; + // } orjson::SetJsonValueByKey(rEnvInfo, "keywords", _keywords, allocator); if( !_description.empty() ) { diff --git a/src/libopenrave/kinbody.cpp b/src/libopenrave/kinbody.cpp index 7dde886191..9b3fa2a573 100644 --- a/src/libopenrave/kinbody.cpp +++ b/src/libopenrave/kinbody.cpp @@ -139,24 +139,24 @@ void KinBody::KinBodyInfo::SerializeJSON(rapidjson::Value& rKinBodyInfo, rapidjs { rKinBodyInfo.SetObject(); - if (_isDiffResult) { - if (IsModifiedField(KinBody::KinBodyInfo::KBIF_Name)) { - orjson::SetJsonValueByKey(rKinBodyInfo, "name", _name, allocator); - } - - if (_vLinkInfos.size() > 0) { - rapidjson::Value rLinkInfoValues; - rLinkInfoValues.SetArray(); - rLinkInfoValues.Reserve(_vLinkInfos.size(), allocator); - FOREACHC(it, _vLinkInfos) { - rapidjson::Value linkInfoValue; - (*it)->SerializeJSON(linkInfoValue, allocator, fUnitScale, options); - rLinkInfoValues.PushBack(linkInfoValue, allocator); - } - rKinBodyInfo.AddMember("links", rLinkInfoValues, allocator); - } - return; - } + // if (_isDiffResult) { + // if (IsModifiedField(KinBody::KinBodyInfo::KBIF_Name)) { + // orjson::SetJsonValueByKey(rKinBodyInfo, "name", _name, allocator); + // } + + // if (_vLinkInfos.size() > 0) { + // rapidjson::Value rLinkInfoValues; + // rLinkInfoValues.SetArray(); + // rLinkInfoValues.Reserve(_vLinkInfos.size(), allocator); + // FOREACHC(it, _vLinkInfos) { + // rapidjson::Value linkInfoValue; + // (*it)->SerializeJSON(linkInfoValue, allocator, fUnitScale, options); + // rLinkInfoValues.PushBack(linkInfoValue, allocator); + // } + // rKinBodyInfo.AddMember("links", rLinkInfoValues, allocator); + // } + // return; + // } if( !_id.empty() ) { orjson::SetJsonValueByKey(rKinBodyInfo, "id", _id, allocator); diff --git a/src/libopenrave/kinbodygeometry.cpp b/src/libopenrave/kinbodygeometry.cpp index 226926e8e8..da057551cb 100644 --- a/src/libopenrave/kinbodygeometry.cpp +++ b/src/libopenrave/kinbodygeometry.cpp @@ -1054,33 +1054,33 @@ void KinBody::GeometryInfo::SerializeJSON(rapidjson::Value& rGeometryInfo, rapid rGeometryInfo.SetObject(); orjson::SetJsonValueByKey(rGeometryInfo, "id", _id, allocator); - if (_isPartial) { - if (IsModifiedField(KinBody::GeometryInfo::GIF_Visible)) { - orjson::SetJsonValueByKey(rGeometryInfo, "visible", _bVisible, allocator); - } - if (IsModifiedField(KinBody::GeometryInfo::GIF_Transparency)) { - orjson::SetJsonValueByKey(rGeometryInfo, "transparency", _fTransparency, allocator); - } - if (IsModifiedField(KinBody::GeometryInfo::GIF_DiffuseColor)) { - orjson::SetJsonValueByKey(rGeometryInfo, "diffuseColor", _vDiffuseColor, allocator); - } - if (IsModifiedField(KinBody::GeometryInfo::GIF_AmbientColor)) { - orjson::SetJsonValueByKey(rGeometryInfo, "ambientColor", _vAmbientColor, allocator); - } - if (IsModifiedField(KinBody::GeometryInfo::GIF_NegativeCropContainerMargins)) { - orjson::SetJsonValueByKey(rGeometryInfo, "negativeCropContainerMargins", _vNegativeCropContainerMargins*fUnitScale, allocator); - } - if (IsModifiedField(KinBody::GeometryInfo::GIF_PositiveCropContainerMargins)) { - orjson::SetJsonValueByKey(rGeometryInfo, "positiveCropContainerMargins", _vPositiveCropContainerMargins*fUnitScale, allocator); - } - if (IsModifiedField(KinBody::GeometryInfo::GIF_NegativeCropContainerEmptyMargins)) { - orjson::SetJsonValueByKey(rGeometryInfo, "negativeCropContainerEmptyMargins", _vNegativeCropContainerEmptyMargins*fUnitScale, allocator); - } - if (IsModifiedField(KinBody::GeometryInfo::GIF_PositiveCropContainerEmptyMargins)) { - orjson::SetJsonValueByKey(rGeometryInfo, "positiveCropContainerEmptyMargins", _vPositiveCropContainerEmptyMargins*fUnitScale, allocator); - } - return; - } + // if (_isPartial) { + // if (IsModifiedField(KinBody::GeometryInfo::GIF_Visible)) { + // orjson::SetJsonValueByKey(rGeometryInfo, "visible", _bVisible, allocator); + // } + // if (IsModifiedField(KinBody::GeometryInfo::GIF_Transparency)) { + // orjson::SetJsonValueByKey(rGeometryInfo, "transparency", _fTransparency, allocator); + // } + // if (IsModifiedField(KinBody::GeometryInfo::GIF_DiffuseColor)) { + // orjson::SetJsonValueByKey(rGeometryInfo, "diffuseColor", _vDiffuseColor, allocator); + // } + // if (IsModifiedField(KinBody::GeometryInfo::GIF_AmbientColor)) { + // orjson::SetJsonValueByKey(rGeometryInfo, "ambientColor", _vAmbientColor, allocator); + // } + // if (IsModifiedField(KinBody::GeometryInfo::GIF_NegativeCropContainerMargins)) { + // orjson::SetJsonValueByKey(rGeometryInfo, "negativeCropContainerMargins", _vNegativeCropContainerMargins*fUnitScale, allocator); + // } + // if (IsModifiedField(KinBody::GeometryInfo::GIF_PositiveCropContainerMargins)) { + // orjson::SetJsonValueByKey(rGeometryInfo, "positiveCropContainerMargins", _vPositiveCropContainerMargins*fUnitScale, allocator); + // } + // if (IsModifiedField(KinBody::GeometryInfo::GIF_NegativeCropContainerEmptyMargins)) { + // orjson::SetJsonValueByKey(rGeometryInfo, "negativeCropContainerEmptyMargins", _vNegativeCropContainerEmptyMargins*fUnitScale, allocator); + // } + // if (IsModifiedField(KinBody::GeometryInfo::GIF_PositiveCropContainerEmptyMargins)) { + // orjson::SetJsonValueByKey(rGeometryInfo, "positiveCropContainerEmptyMargins", _vPositiveCropContainerEmptyMargins*fUnitScale, allocator); + // } + // return; + // } orjson::SetJsonValueByKey(rGeometryInfo, "name", _name, allocator); diff --git a/src/libopenrave/kinbodyjoint.cpp b/src/libopenrave/kinbodyjoint.cpp index 24df1cacb0..982274da9f 100644 --- a/src/libopenrave/kinbodyjoint.cpp +++ b/src/libopenrave/kinbodyjoint.cpp @@ -293,93 +293,93 @@ void KinBody::JointInfo::SerializeJSON(rapidjson::Value& value, rapidjson::Docum newvupperlimit[i] *= fjointmult; } - if (_isPartial) { - value.SetObject(); - orjson::SetJsonValueByKey(value, "id", _id, allocator); - if (IsModifiedField(KinBody::JointInfo::JIF_Limit)) { - orjson::SetJsonValueByKey(value, "lowerLimit", newvlowerlimit, allocator, dof); - orjson::SetJsonValueByKey(value, "upperLimit", newvupperlimit, allocator, dof); - } - if (IsModifiedField(KinBody::JointInfo::JIF_Maxvel)) { - orjson::SetJsonValueByKey(value, "maxVel", newvmaxvel, allocator, dof); - } - if (IsModifiedField(KinBody::JointInfo::JIF_Maxaccel)) { - orjson::SetJsonValueByKey(value, "maxAccel", newvmaxaccel, allocator, dof); - } - if (IsModifiedField(KinBody::JointInfo::JIF_Maxjerk)) { - orjson::SetJsonValueByKey(value, "maxJerk", _vmaxjerk, allocator, dof); - } - if (IsModifiedField(KinBody::JointInfo::JIF_Hardmaxvel)) { - orjson::SetJsonValueByKey(value, "hardMaxVel", _vhardmaxvel, allocator, dof); - } - if (IsModifiedField(KinBody::JointInfo::JIF_Hardmaxaccel)) { - orjson::SetJsonValueByKey(value, "hardMaxAccel", _vhardmaxaccel, allocator, dof); - } - if (IsModifiedField(KinBody::JointInfo::JIF_Hardmaxjerk)) { - orjson::SetJsonValueByKey(value, "hardMaxJerk", _vhardmaxjerk, allocator, dof); - } - if (IsModifiedField(KinBody::JointInfo::JIF_Maxtorque)) { - orjson::SetJsonValueByKey(value, "maxTorque", _vmaxtorque, allocator, dof); - } - if (IsModifiedField(KinBody::JointInfo::JIF_Maxinertia)) { - orjson::SetJsonValueByKey(value, "maxInertia", _vmaxinertia, allocator, dof); - } - if (IsModifiedField(KinBody::JointInfo::JIF_Offsets)) { - orjson::SetJsonValueByKey(value, "offsets", _voffsets, allocator, dof); - } - if (IsModifiedField(KinBody::JointInfo::JIF_Resolution)) { - orjson::SetJsonValueByKey(value, "resolutions", _vresolution, allocator, dof); - } - if (IsModifiedField(KinBody::JointInfo::JIF_Weights)) { - orjson::SetJsonValueByKey(value, "weights", _vweights, allocator, dof); - } - if (IsModifiedField(KinBody::JointInfo::JIF_MapFloatParameters)) { - if(_mapFloatParameters.size() > 0) - { - rapidjson::Value parameters; - parameters.SetArray(); - FOREACHC(it, _mapFloatParameters) { - rapidjson::Value parameter; - parameter.SetObject(); - orjson::SetJsonValueByKey(parameter, "id", it->first, allocator); - orjson::SetJsonValueByKey(parameter, "values", it->second, allocator); - parameters.PushBack(parameter, allocator); - } - value.AddMember("floatParameters", parameters, allocator); - } - } - if (IsModifiedField(KinBody::JointInfo::JIF_MapIntParameters)) { - if(_mapIntParameters.size() > 0) - { - rapidjson::Value parameters; - parameters.SetArray(); - FOREACHC(it, _mapIntParameters) { - rapidjson::Value parameter; - parameter.SetObject(); - orjson::SetJsonValueByKey(parameter, "id", it->first, allocator); - orjson::SetJsonValueByKey(parameter, "values", it->second, allocator); - parameters.PushBack(parameter, allocator); - } - value.AddMember("intParameters", parameters, allocator); - } - } - if (IsModifiedField(KinBody::JointInfo::JIF_MapStringParameters)) { - if(_mapStringParameters.size() > 0) - { - rapidjson::Value parameters; - parameters.SetArray(); - FOREACHC(it, _mapStringParameters) { - rapidjson::Value parameter; - parameter.SetObject(); - orjson::SetJsonValueByKey(parameter, "id", it->first, allocator); - orjson::SetJsonValueByKey(parameter, "value", it->second, allocator); - parameters.PushBack(parameter, allocator); - } - value.AddMember("stringParameters", parameters, allocator); - } - } - return; - } +// if (_isPartial) { +// value.SetObject(); +// orjson::SetJsonValueByKey(value, "id", _id, allocator); +// if (IsModifiedField(KinBody::JointInfo::JIF_Limit)) { +// orjson::SetJsonValueByKey(value, "lowerLimit", newvlowerlimit, allocator, dof); +// orjson::SetJsonValueByKey(value, "upperLimit", newvupperlimit, allocator, dof); +// } +// if (IsModifiedField(KinBody::JointInfo::JIF_Maxvel)) { +// orjson::SetJsonValueByKey(value, "maxVel", newvmaxvel, allocator, dof); +// } +// if (IsModifiedField(KinBody::JointInfo::JIF_Maxaccel)) { +// orjson::SetJsonValueByKey(value, "maxAccel", newvmaxaccel, allocator, dof); +// } +// if (IsModifiedField(KinBody::JointInfo::JIF_Maxjerk)) { +// orjson::SetJsonValueByKey(value, "maxJerk", _vmaxjerk, allocator, dof); +// } +// if (IsModifiedField(KinBody::JointInfo::JIF_Hardmaxvel)) { +// orjson::SetJsonValueByKey(value, "hardMaxVel", _vhardmaxvel, allocator, dof); +// } +// if (IsModifiedField(KinBody::JointInfo::JIF_Hardmaxaccel)) { +// orjson::SetJsonValueByKey(value, "hardMaxAccel", _vhardmaxaccel, allocator, dof); +// } +// if (IsModifiedField(KinBody::JointInfo::JIF_Hardmaxjerk)) { +// orjson::SetJsonValueByKey(value, "hardMaxJerk", _vhardmaxjerk, allocator, dof); +// } +// if (IsModifiedField(KinBody::JointInfo::JIF_Maxtorque)) { +// orjson::SetJsonValueByKey(value, "maxTorque", _vmaxtorque, allocator, dof); +// } +// if (IsModifiedField(KinBody::JointInfo::JIF_Maxinertia)) { +// orjson::SetJsonValueByKey(value, "maxInertia", _vmaxinertia, allocator, dof); +// } +// if (IsModifiedField(KinBody::JointInfo::JIF_Offsets)) { +// orjson::SetJsonValueByKey(value, "offsets", _voffsets, allocator, dof); +// } +// if (IsModifiedField(KinBody::JointInfo::JIF_Resolution)) { +// orjson::SetJsonValueByKey(value, "resolutions", _vresolution, allocator, dof); +// } +// if (IsModifiedField(KinBody::JointInfo::JIF_Weights)) { +// orjson::SetJsonValueByKey(value, "weights", _vweights, allocator, dof); +// } +// if (IsModifiedField(KinBody::JointInfo::JIF_MapFloatParameters)) { +// if(_mapFloatParameters.size() > 0) +// { +// rapidjson::Value parameters; +// parameters.SetArray(); +// FOREACHC(it, _mapFloatParameters) { +// rapidjson::Value parameter; +// parameter.SetObject(); +// orjson::SetJsonValueByKey(parameter, "id", it->first, allocator); +// orjson::SetJsonValueByKey(parameter, "values", it->second, allocator); +// parameters.PushBack(parameter, allocator); +// } +// value.AddMember("floatParameters", parameters, allocator); +// } +// } +// if (IsModifiedField(KinBody::JointInfo::JIF_MapIntParameters)) { +// if(_mapIntParameters.size() > 0) +// { +// rapidjson::Value parameters; +// parameters.SetArray(); +// FOREACHC(it, _mapIntParameters) { +// rapidjson::Value parameter; +// parameter.SetObject(); +// orjson::SetJsonValueByKey(parameter, "id", it->first, allocator); +// orjson::SetJsonValueByKey(parameter, "values", it->second, allocator); +// parameters.PushBack(parameter, allocator); +// } +// value.AddMember("intParameters", parameters, allocator); +// } +// } +// if (IsModifiedField(KinBody::JointInfo::JIF_MapStringParameters)) { +// if(_mapStringParameters.size() > 0) +// { +// rapidjson::Value parameters; +// parameters.SetArray(); +// FOREACHC(it, _mapStringParameters) { +// rapidjson::Value parameter; +// parameter.SetObject(); +// orjson::SetJsonValueByKey(parameter, "id", it->first, allocator); +// orjson::SetJsonValueByKey(parameter, "value", it->second, allocator); +// parameters.PushBack(parameter, allocator); +// } +// value.AddMember("stringParameters", parameters, allocator); +// } +// } +// return; +// } orjson::SetJsonValueByKey(value, "maxVel", newvmaxvel, allocator, dof); diff --git a/src/libopenrave/kinbodylink.cpp b/src/libopenrave/kinbodylink.cpp index d10cad3b83..e5b4b574c3 100644 --- a/src/libopenrave/kinbodylink.cpp +++ b/src/libopenrave/kinbodylink.cpp @@ -142,35 +142,35 @@ void KinBody::LinkInfo::SerializeJSON(rapidjson::Value &value, rapidjson::Docume tmpTransform.trans *= fUnitScale; tmpMassTransform.trans *= fUnitScale; - if (_isPartial) { - if (IsModifiedField(KinBody::LinkInfo::LIF_Transform)) { - orjson::SetJsonValueByKey(value, "transform", tmpTransform, allocator); - } - if (IsModifiedField(KinBody::LinkInfo::LIF_MassFrame)) { - orjson::SetJsonValueByKey(value, "massTransform", tmpMassTransform, allocator); - } - if (IsModifiedField(KinBody::LinkInfo::LIF_Static)) { - orjson::SetJsonValueByKey(value, "isStatic", _bStatic, allocator); - } - if (IsModifiedField(KinBody::LinkInfo::LIF_Mass)) { - orjson::SetJsonValueByKey(value, "mass", _mass, allocator); - } - if (IsModifiedField(KinBody::LinkInfo::LIF_InertiaMoments)) { - orjson::SetJsonValueByKey(value, "inertiaMoments", _vinertiamoments*fUnitScale*fUnitScale, allocator); - } - if (_vgeometryinfos.size() > 0) { - rapidjson::Value geometriesValue; - geometriesValue.SetArray(); - geometriesValue.Reserve(_vgeometryinfos.size(), allocator); - FOREACHC(it, _vgeometryinfos) { - rapidjson::Value geometryValue; - (*it)->SerializeJSON(geometryValue, allocator, fUnitScale, options); - geometriesValue.PushBack(geometryValue, allocator); - } - value.AddMember("geometries", geometriesValue, allocator); - } - return; - } + // if (_isPartial) { + // if (IsModifiedField(KinBody::LinkInfo::LIF_Transform)) { + // orjson::SetJsonValueByKey(value, "transform", tmpTransform, allocator); + // } + // if (IsModifiedField(KinBody::LinkInfo::LIF_MassFrame)) { + // orjson::SetJsonValueByKey(value, "massTransform", tmpMassTransform, allocator); + // } + // if (IsModifiedField(KinBody::LinkInfo::LIF_Static)) { + // orjson::SetJsonValueByKey(value, "isStatic", _bStatic, allocator); + // } + // if (IsModifiedField(KinBody::LinkInfo::LIF_Mass)) { + // orjson::SetJsonValueByKey(value, "mass", _mass, allocator); + // } + // if (IsModifiedField(KinBody::LinkInfo::LIF_InertiaMoments)) { + // orjson::SetJsonValueByKey(value, "inertiaMoments", _vinertiamoments*fUnitScale*fUnitScale, allocator); + // } + // if (_vgeometryinfos.size() > 0) { + // rapidjson::Value geometriesValue; + // geometriesValue.SetArray(); + // geometriesValue.Reserve(_vgeometryinfos.size(), allocator); + // FOREACHC(it, _vgeometryinfos) { + // rapidjson::Value geometryValue; + // (*it)->SerializeJSON(geometryValue, allocator, fUnitScale, options); + // geometriesValue.PushBack(geometryValue, allocator); + // } + // value.AddMember("geometries", geometriesValue, allocator); + // } + // return; + // } orjson::SetJsonValueByKey(value, "name", _name, allocator); orjson::SetJsonValueByKey(value, "transform", tmpTransform, allocator);