Skip to content

Commit

Permalink
Adds PositionConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
Shintaro Matsuoka committed Mar 28, 2022
1 parent 4db6c14 commit e96520b
Show file tree
Hide file tree
Showing 4 changed files with 521 additions and 0 deletions.
50 changes: 50 additions & 0 deletions include/openrave/kinbody.h
Original file line number Diff line number Diff line change
Expand Up @@ -2034,6 +2034,56 @@ class OPENRAVE_API KinBody : public InterfaceBase
typedef boost::shared_ptr<KinBody::Joint const> JointConstPtr;
typedef boost::weak_ptr<KinBody::Joint> JointWeakPtr;

/// \brief Holds a joint value set representing a KinBody/Robot pose
///
/// Currently, this structure supports only joints which have single DoF

This comment has been minimized.

Copy link
@felixvd

felixvd Mar 31, 2022

Collaborator

--> "which have a single DoF"

This comment has been minimized.

Copy link
@strmtk

strmtk Mar 31, 2022

Collaborator

This limitation has been eliminated in a later commit, and the line has been removed accordingly.

class OPENRAVE_API PositionConfiguration : public InfoBase
{
public:
PositionConfiguration() = default;
virtual ~PositionConfiguration() = default;

void Reset() override;
void SerializeJSON(rapidjson::Value& value, rapidjson::Document::AllocatorType& allocator, dReal fUnitScale, int options=0) const override;
void DeserializeJSON(const rapidjson::Value& value, dReal fUnitScale, int options) override;

bool operator==(const PositionConfiguration& other) const;
bool operator!=(const PositionConfiguration& other) const;

inline void Swap(PositionConfiguration& rhs) {
_id.swap(rhs._id);
name.swap(rhs.name);
jointConfigurationStates.swap(rhs.jointConfigurationStates);
}

class JointConfigurationState : public InfoBase

This comment has been minimized.

Copy link
@felixvd

felixvd Mar 31, 2022

Collaborator

Would add /// name and value of one joint

{
public:
JointConfigurationState() = default;
virtual ~JointConfigurationState() = default;

void Reset() override;
void SerializeJSON(rapidjson::Value& value, rapidjson::Document::AllocatorType& allocator, dReal fUnitScale, int options=0) const override;
void DeserializeJSON(const rapidjson::Value& value, dReal fUnitScale, int options) override;

bool operator==(const JointConfigurationState& other) const;
bool operator!=(const JointConfigurationState& other) const;

std::string _id; ///< id of joint configuration state, for incremental update

This comment has been minimized.

Copy link
@felixvd

felixvd Mar 31, 2022

Collaborator

Is this the same id as the parent PositionConfiguration? If not, is it also unique?

std::string jointName; ///< name of the joint. If the joint belong to a connectedBody, then it's resolved name is connectedBodyName+"_"+jointName

This comment has been minimized.

Copy link
@felixvd

felixvd Mar 31, 2022

Collaborator

///< name of the joint. If the joint belongs to a connectedBody, then its resolved name is connectedBodyName+"_"+jointName

(typos)

This comment has been minimized.

Copy link
@strmtk

strmtk Mar 31, 2022

Collaborator

Sure, updated. You're welcome to make a change directly especially for non-debatable improvements :)

This comment has been minimized.

Copy link
@cielavenir

cielavenir Mar 31, 2022

Collaborator

@felixvd if you don't have access to rdiankov/openrave, please ask Rosen to send invitation.

dReal jointValue = 0.0;
std::string connectedBodyName; ///< the connected body name the jointName comes from

This comment has been minimized.

Copy link
@felixvd

felixvd Mar 31, 2022

Collaborator

///< the connected body the jointName is from. Can be empty.

};
typedef boost::shared_ptr<JointConfigurationState> JointConfigurationStatePtr;
typedef boost::shared_ptr<JointConfigurationState const> JointConfigurationStateConstPtr;

std::string _id; ///< unique id of the configuration used to identify it when changing it.
std::string name; ///< name of the configuration
std::vector<JointConfigurationState> jointConfigurationStates; ///< joint name to joint values mapping
};
typedef boost::shared_ptr<PositionConfiguration> PositionConfigurationPtr;
typedef boost::shared_ptr<PositionConfiguration const> PositionConfigurationConstPtr;

/// \brief holds all user-set attached sensor information used to initialize the AttachedSensor class.
///
/// This is serializable and independent of environment.
Expand Down
46 changes: 46 additions & 0 deletions python/bindings/include/openravepy/openravepy_jointinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,52 @@ class PyJoint
int __hash__();
};

class PyPositionConfiguration_JointConfigurationState
{
public:
PyPositionConfiguration_JointConfigurationState() = default;
PyPositionConfiguration_JointConfigurationState(const KinBody::PositionConfiguration::JointConfigurationState& jointConfigurationState);

KinBody::PositionConfiguration::JointConfigurationStatePtr GetJointConfigurationState() const;
object SerializeJSON(dReal fUnitScale = 1.0, object options = py::none_());
void DeserializeJSON(object obj, dReal fUnitScale = 1.0, object options = py::none_());

std::string __str__();
bool __eq__(OPENRAVE_SHARED_PTR<PyPositionConfiguration_JointConfigurationState> p);
bool __ne__(OPENRAVE_SHARED_PTR<PyPositionConfiguration_JointConfigurationState> p);

object _id = py::none_();
object jointName = py::none_();
dReal jointValue = 0.0;
object connectedBodyName = py::none_();

private:
void _Update(const KinBody::PositionConfiguration::JointConfigurationState& jointConfigurationState);
};
typedef OPENRAVE_SHARED_PTR<PyPositionConfiguration_JointConfigurationState> PyPositionConfiguration_JointConfigurationStatePtr;

class PyPositionConfiguration
{
public:
PyPositionConfiguration() = default;
PyPositionConfiguration(const KinBody::PositionConfiguration& positionConfiguration);

KinBody::PositionConfigurationPtr GetPositionConfiguration() const;
object SerializeJSON(dReal fUnitScale = 1.0, object options = py::none_());
void DeserializeJSON(object obj, dReal fUnitScale = 1.0, object options = py::none_());

std::string __str__();
bool __eq__(OPENRAVE_SHARED_PTR<PyPositionConfiguration> p);
bool __ne__(OPENRAVE_SHARED_PTR<PyPositionConfiguration> p);

object _id = py::none_();
object name = py::none_();
py::list jointConfigurationStates;

private:
void _Update(const KinBody::PositionConfiguration& positionConfiguration);
};

class PyKinBodyStateSaver
{
PyEnvironmentBasePtr _pyenv;
Expand Down
Loading

0 comments on commit e96520b

Please sign in to comment.