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

Remove Geometry::scale #119

Merged
merged 2 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion binding/python/rbdyn/parsers/c_parsers.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cdef extern from "<RBDyn/parsers/common.h>" namespace "rbd::parsers":

cdef cppclass GeometryMesh "rbd::parsers::Geometry::Mesh":
string filename
double scale
Vector3d scaleV

cdef cppclass GeometryBox "rbd::parsers::Geometry::Box":
Vector3d size
Expand Down
8 changes: 4 additions & 4 deletions binding/python/rbdyn/parsers/parsers.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ cdef class GeometryMesh(object):
property filename:
def __get__(self):
return self.impl.filename
property scale:
property scaleV:
def __get__(self):
return self.impl.scale
return eigen.Vector3dFromC(self.impl.scaleV)

def __richcmp__(GeometryMesh self, GeometryMesh other, int op):
if op == 2:
return (
self.impl.filename == other.impl.filename
and self.impl.scale == other.impl.scale
and self.impl.scaleV == other.impl.scaleV
)
elif op == 3:
return (
self.impl.filename != other.impl.filename
and self.impl.scale != other.impl.scale
and self.impl.scaleV != other.impl.scaleV
)
else:
raise NotImplementedError("This comparison is not supported")
Expand Down
3 changes: 1 addition & 2 deletions src/parsers/RBDyn/parsers/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ struct RBDYN_PARSERS_DLLAPI Geometry
public:
struct Mesh
{
Mesh() : scaleV(Eigen::Vector3d::Ones()), scale(1) {}
Mesh() : scaleV(Eigen::Vector3d::Ones()) {}
std::string filename;
Eigen::Vector3d scaleV;
double scale;
};
struct Box
{
Expand Down
4 changes: 1 addition & 3 deletions src/parsers/urdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,11 @@ Geometry::Data geometryFromMesh(const tinyxml2::XMLElement & meshDom)
if(maybeScaleV.size() == 3)
{
mesh.scaleV = Eigen::Map<Eigen::Vector3d>(maybeScaleV.data(), 3);
mesh.scale = mesh.scaleV[2];
}
else
{
assert(maybeScaleV.size() == 1);
mesh.scale = maybeScaleV[0];
mesh.scaleV.setConstant(mesh.scale);
mesh.scaleV.setConstant(maybeScaleV[0]);
}
return mesh;
}
Expand Down
4 changes: 1 addition & 3 deletions src/parsers/yaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,11 @@ bool RBDynFromYAML::parseGeometry(const YAML::Node & geometry, Geometry & data)
if(maybeScaleV.size() == 3)
{
mesh_data.scaleV = Eigen::Map<Eigen::Vector3d>(maybeScaleV.data(), 3);
mesh_data.scale = mesh_data.scaleV(2);
}
else
{
assert(maybeScaleV.size() == 1);
mesh_data.scale = maybeScaleV[0];
mesh_data.scaleV.setConstant(mesh_data.scale);
mesh_data.scaleV.setConstant(maybeScaleV[0]);
}
has_geometry = true;
data.data = mesh_data;
Expand Down
4 changes: 1 addition & 3 deletions tests/ParsersTestUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,12 @@ inline rbd::parsers::ParserResult createRobot()
rbd::parsers::Geometry::Mesh mesh;
v1.origin = create_ptransform(0.1, 0.2, 0.3, 0, 0, 0);
mesh.filename = "file://test_mesh1.dae";
mesh.scale = 1.0;
mesh.scaleV = Eigen::Vector3d::Ones();
v1.geometry.type = rbd::parsers::Geometry::Type::MESH;
v1.geometry.data = mesh;

v2.origin = create_ptransform(0, 0, 0, 0, 0, 0);
mesh.filename = "file://test_mesh2.dae";
mesh.scale = 0.1;
mesh.scaleV = Eigen::Vector3d(0.1, -0.1, 0.1);
v2.geometry.type = rbd::parsers::Geometry::Type::MESH;
v2.geometry.data = mesh;
Expand Down Expand Up @@ -168,7 +166,7 @@ namespace parsers

inline bool operator==(const Geometry::Mesh & m1, const Geometry::Mesh & m2)
{
return m1.scaleV == m2.scaleV && m1.scale == m2.scale && m1.filename == m2.filename;
return m1.scaleV == m2.scaleV && m1.filename == m2.filename;
}

inline bool operator==(const Geometry::Box & b1, const Geometry::Box & b2)
Expand Down
Loading