Skip to content

Add uri to KinBodyInfo::SerializeJSON output#1550

Closed
eisoku9618 wants to merge 3 commits intoproductionfrom
keep-referenceURI
Closed

Add uri to KinBodyInfo::SerializeJSON output#1550
eisoku9618 wants to merge 3 commits intoproductionfrom
keep-referenceURI

Conversation

@eisoku9618
Copy link
Copy Markdown
Collaborator

@eisoku9618 eisoku9618 commented Feb 27, 2026

When sending KinBody to another process, we serialize it on the sender side as KinBodyInfo and deserialize on the receiver side. However, KinBodyInfo::SerializeJSON supports _referenceUri but not _uri intentionally, so we have been working around this by copying _uri into _referenceUri before serialization in application code. The problem is that this overwrites the original _referenceUri, so the original value is lost. To avoid that, I would like KinBodyInfo::SerializeJSON to support _uri as well.

Here is an example of the current application code for the sender and receiver sides.

// sender side
void SerializeBodyInfo(const KinBody& body, rapidjson::Value& rKinBodyInfo)
{
    KinBody::KinBodyInfo kinfo;
    body.ExtractInfo(kinfo, EIO_Everything);

    // this swap is the current workaround, and I would like to remove this line.
    kinfo._uri.swap(kinfo._referenceUri);

    kinfo.SerializeJSON(rKinBodyInfo);
}

// receiver side
void ApplyEnvBodiesCacheState(const rapidjson::Value& rKinBodyInfo)
{
    KinBodyPtr pbody;

    // this is the current workaround, and I would like to change "referenceUri" to "uri"
    std::string referenceUri = mujinjson::GetStringJsonValueByKey(rKinBodyInfo, "referenceUri");
    bool bIsDummy = referenceUri.find("__dummyuri__") != std::string::npos;
    if( !bIsDummy ) {
        pbody = env.ReadKinBodyURI(KinBodyPtr(), referenceUri);
    }

    if( !pbody ) {
        KinBody::KinBodyInfo kinfo;
        kinfo.DeserializeJSON(rKinBodyInfo);
        // currently this pbody does not have the original "referenceUri",
        // and I would like to change to have it.
        pbody->InitFromKinBodyInfo(kinfo);
    }
}

@eisoku9618 eisoku9618 changed the title Implement URI serialization functionality Add uri to KinBodyInfo::SerializeJSON output Feb 27, 2026
@eisoku9618 eisoku9618 marked this pull request as ready for review February 27, 2026 10:02
Copy link
Copy Markdown
Collaborator

@yoshikikanemoto yoshikikanemoto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

@rdiankov @ziyan

Do you see any problems? Further description about motivation can be found https://tiny.mujin.co.jp/lz998
Our tests are all green with this change + other changes in internal repos.

@yoshikikanemoto
Copy link
Copy Markdown
Collaborator

saving uri into serialized data requires a lot of design changes and user flow changes when dealing with scene rename etc so closing

@eisoku9618 eisoku9618 deleted the keep-referenceURI branch March 5, 2026 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants