Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
LLipter committed Jan 16, 2024
1 parent 8ee4599 commit fdec473
Show file tree
Hide file tree
Showing 5 changed files with 201 additions and 201 deletions.
80 changes: 40 additions & 40 deletions src/libopenrave/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() ) {
Expand Down
36 changes: 18 additions & 18 deletions src/libopenrave/kinbody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
54 changes: 27 additions & 27 deletions src/libopenrave/kinbodygeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
174 changes: 87 additions & 87 deletions src/libopenrave/kinbodyjoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit fdec473

Please sign in to comment.