Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new KinBody::ExtraGeometryInfo struture for KinBody::Link::_mapExtraGeometries #1441

Open
wants to merge 22 commits into
base: production
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3b5fbb4
Add missing Boost include
PeterBowman Aug 15, 2024
ec22ecf
Merge pull request #1420 from PeterBowman/boost-hash
rdiankov Aug 16, 2024
0258762
add serialization and deserialization of extraGeometries
Sep 27, 2024
e898491
tested and updated de/serialization of extraGeometries
Sep 30, 2024
64caea0
deserialization support merging based on id
Oct 10, 2024
61ef8a6
add extrageometry structure and modify related functions
Oct 18, 2024
26573d7
Merge pull request #1448 from zax147/extra_geometries
justism Oct 18, 2024
5ccc302
add extrageometry structure and modify related functions
Oct 18, 2024
745c4c8
Merge remote-tracking branch 'origin/production' into extra_geometries
Oct 21, 2024
766e991
Merge branch 'extra_geometries' of https://github.com/rdiankov/openra…
Oct 21, 2024
564543f
add assertion for setlinkgroupgeometries
Oct 22, 2024
5119ad0
Merge pull request #1451 from zax147/extra_geometries
rschlaikjer Oct 22, 2024
e800a93
fixed unintialized pointer issue
Oct 22, 2024
edeaaa1
Merge pull request #1452 from zax147/extra_geometries
rschlaikjer Oct 22, 2024
0380fa6
change function signature for compatibility
Oct 23, 2024
05cb3bf
Merge pull request #1453 from zax147/extra_geometries
justism Oct 23, 2024
48a1991
change function signature for compatibility
Oct 23, 2024
4094bce
Merge branch 'extra_geometries' of https://github.com/rdiankov/openra…
Oct 23, 2024
eab12ce
Merge branch 'rdiankov-extra_geometries' into extra_geometries
Oct 23, 2024
d5dce67
Merge pull request #1454 from zax147/extra_geometries
justism Oct 23, 2024
7a3a9de
clean up comments
Oct 24, 2024
07c46b1
changed variable name, change link serialization, and update the para…
Oct 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 36 additions & 8 deletions include/openrave/kinbody.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@ class OPENRAVE_API KinBody : public InterfaceBase
CLA_CheckLimitsThrow = 3, ///< check the limits and throws if something went wrong
};


/// \brief Describes the properties of a geometric primitive.
///
/// Contains everything associated with a geometry's appearance and shape
Expand Down Expand Up @@ -982,6 +981,33 @@ class OPENRAVE_API KinBody : public InterfaceBase
typedef boost::shared_ptr<Geometry> GeometryPtr;
typedef boost::shared_ptr<Geometry const> GeometryConstPtr;

/// \brief Describes the properties of an extraGeometric primitive.
class OPENRAVE_API ExtraGeometryInfo : public InfoBase
{
public:
ExtraGeometryInfo(){
}

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

std::vector<GeometryInfoPtr> _vgeometryinfos;

///\brief unique id of the extrageometry
std::string _id;
/// \brief unique extrageometry name
std::string _name;

private:
friend class Link;
friend class KinBody;
friend class RobtBase;
};

typedef boost::shared_ptr<ExtraGeometryInfo> ExtraGeometryInfoPtr;
typedef boost::shared_ptr<ExtraGeometryInfo const> ExtraGeometryInfoConstPtr;

/// \brief Describes the properties of a link used to initialize it
class OPENRAVE_API LinkInfo : public InfoBase
{
Expand Down Expand Up @@ -1017,7 +1043,7 @@ class OPENRAVE_API KinBody : public InterfaceBase
std::vector<GeometryInfoPtr> _vgeometryinfos;
/// extra-purpose geometries like
/// self - self-collision specific geometry. By default, this type of geometry will be always set
std::map< std::string, std::vector<GeometryInfoPtr> > _mapExtraGeometries;
std::map< std::string, ExtraGeometryInfoPtr > _mapExtraGeometries;

///\brief unique id of the link
std::string _id;
Expand Down Expand Up @@ -1086,6 +1112,8 @@ class OPENRAVE_API KinBody : public InterfaceBase
/// \brief deserializes a readable from rReadable and stores it into _mReadableInterfaces[id]
void _DeserializeReadableInterface(const std::string& id, const rapidjson::Value& rReadable, dReal fUnitScale);

void _DeserializeExtraGeometryInfo(const std::string& id, const rapidjson::Value& rExtraGeom, dReal fUnitScale, int options);

friend class Link;
friend class KinBody;
friend class RobtBase;
Expand Down Expand Up @@ -1329,21 +1357,21 @@ class OPENRAVE_API KinBody : public InterfaceBase

/// \brief initializes the link with geometries from the extra geomeries in LinkInfo
///
/// \param name The name of the geometry group. If name is empty, will initialize the default geometries.
/// \throw If name does not exist in GetInfo()._mapExtraGeometries, then throw an exception.
void SetGeometriesFromGroup(const std::string& name);
/// \param groupid The id of the geometry group. If id is empty, will initialize the default geometries.
/// \throw If id does not exist in GetInfo()._mapExtraGeometries, then throw an exception.
void SetGeometriesFromGroup(const std::string& groupid);

/// \brief returns a const reference to the vector of geometries for a particular group
///
/// \param name The name of the geometry group.
/// \param groupid The id of the geometry group.
/// \throw openrave_exception If the group does not exist, throws an exception.
const std::vector<KinBody::GeometryInfoPtr>& GetGeometriesFromGroup(const std::string& name) const;
const std::vector<KinBody::GeometryInfoPtr>& GetGeometriesFromGroup(const std::string& groupid) const;

/// \brief stores geometries for later retrieval
///
/// the list is stored inside _GetInfo()._mapExtraGeometries. Note that the pointers are copied and not the data, so
/// any be careful not to modify the geometries afterwards
void SetGroupGeometries(const std::string& name, const std::vector<KinBody::GeometryInfoPtr>& geometries);
void SetGroupGeometries(const std::string& groupid, const std::vector<KinBody::GeometryInfoPtr>& geometries);

private:
/// \brief stores geometries for later retrieval
Expand Down
1 change: 1 addition & 0 deletions include/openrave/openrave.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#if __cplusplus >= 201703L
#include <string_view>
#else
#include <boost/container_hash/hash.hpp>
#include <boost/utility/string_view.hpp>
namespace std{
// make boost::string_view handlable by std::unordered_set/map
Expand Down
3 changes: 3 additions & 0 deletions python/bindings/include/openravepy/openravepy_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class PyCameraIntrinsics;
class PyLinkInfo;
class PyJointInfo;
class PyGeometryInfo;
class PyExtraGeometryInfo;
class PyManipulatorInfo;
class PyAttachedSensorInfo;
class PyConnectedBodyInfo;
Expand Down Expand Up @@ -150,6 +151,7 @@ typedef OPENRAVE_SHARED_PTR<PyCameraIntrinsics> PyCameraIntrinsicsPtr;
typedef OPENRAVE_SHARED_PTR<PyLinkInfo> PyLinkInfoPtr;
typedef OPENRAVE_SHARED_PTR<PyJointInfo> PyJointInfoPtr;
typedef OPENRAVE_SHARED_PTR<PyGeometryInfo> PyGeometryInfoPtr;
typedef OPENRAVE_SHARED_PTR<PyExtraGeometryInfo> PyExtraGeometryInfoPtr;
typedef OPENRAVE_SHARED_PTR<PyManipulatorInfo> PyManipulatorInfoPtr;
typedef OPENRAVE_SHARED_PTR<PyAttachedSensorInfo> PyAttachedSensorInfoPtr;
typedef OPENRAVE_SHARED_PTR<PyConnectedBodyInfo> PyConnectedBodyInfoPtr;
Expand Down Expand Up @@ -889,6 +891,7 @@ OPENRAVEPY_API PyJointPtr toPyJoint(KinBody::JointPtr pjoint, PyEnvironmentBaseP
OPENRAVEPY_API PyLinkInfoPtr toPyLinkInfo(const KinBody::LinkInfo& linkinfo);
OPENRAVEPY_API PyJointInfoPtr toPyJointInfo(const KinBody::JointInfo& jointinfo);
OPENRAVEPY_API PyGeometryInfoPtr toPyGeometryInfo(const KinBody::GeometryInfo& geominfo);
OPENRAVEPY_API PyExtraGeometryInfoPtr toPyExtraGeometryInfo(const KinBody::ExtraGeometryInfo& extrageominfo);
OPENRAVEPY_API PyManipulatorInfoPtr toPyManipulatorInfo(const RobotBase::ManipulatorInfo& manipulatorinfo);
OPENRAVEPY_API PyAttachedSensorInfoPtr toPyAttachedSensorInfo(const RobotBase::AttachedSensorInfo& attachedSensorinfo);
OPENRAVEPY_API PyConnectedBodyInfoPtr toPyConnectedBodyInfo(const RobotBase::ConnectedBodyInfo& connectedBodyInfo);
Expand Down
32 changes: 28 additions & 4 deletions python/bindings/include/openravepy/openravepy_jointinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,30 @@ class PyGeometryInfo

typedef OPENRAVE_SHARED_PTR<PyGeometryInfo> PyGeometryInfoPtr;

class PyExtraGeometryInfo
{
public:
PyExtraGeometryInfo();
PyExtraGeometryInfo(const KinBody::ExtraGeometryInfo& info);
KinBody::ExtraGeometryInfoPtr GetExtraGeometryInfo();

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

py::list _vgeometryinfos;

std::string __repr__();
std::string __str__();

object _id = py::none_();
object _name = py::none_();

private:
void _Update(const KinBody::ExtraGeometryInfo& info);
};

typedef OPENRAVE_SHARED_PTR<PyExtraGeometryInfo> PyExtraGeometryInfoPtr;

class PyLinkInfo
{
public:
Expand Down Expand Up @@ -403,13 +427,13 @@ class PyLink : public PyReadablesContainer
void AddGeometryToGroup(object ogeometryinfo, const std::string& groupname);

void RemoveGeometryByName(const std::string& geometryname, bool removeFromAllGroups);
void SetGeometriesFromGroup(const std::string& name);
void SetGeometriesFromGroup(const std::string& groupid);

object GetGeometriesFromGroup(const std::string& name);
object GetGeometriesFromGroup(const std::string& groupid);

void SetGroupGeometries(const std::string& name, object ogeometryinfos);
void SetGroupGeometries(const std::string& groupid, object oextrageometryinfo);

int GetGroupNumGeometries(const std::string& geomname);
int GetGroupNumGeometries(const std::string& groupid);

object GetRigidlyAttachedLinks() const;

Expand Down
Loading