Skip to content

Joint visual #366

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

Merged
merged 35 commits into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
134faeb
Added main class
atharva-18 Jun 29, 2021
21746c7
Added base API
atharva-18 Jul 1, 2021
e2b2440
Added scene impl
atharva-18 Jul 1, 2021
50f6d45
Added UpdateAxisImpl
atharva-18 Jul 1, 2021
5dd198c
Add rotation visual
atharva-18 Jul 2, 2021
bfd743f
Add ShowAxisHead method
atharva-18 Jul 2, 2021
409ddd1
codecheck
atharva-18 Jul 2, 2021
deecbb1
Add ScaleToChild method
atharva-18 Jul 2, 2021
71a0e7e
Fix parent axis visual
atharva-18 Jul 4, 2021
392d3d6
Add hinge2 example
atharva-18 Jul 4, 2021
b4f86e0
Fix parent scaling
atharva-18 Jul 5, 2021
49e7247
Update API to set axes
atharva-18 Jul 6, 2021
9b3afe5
Add Destroy impl
atharva-18 Jul 6, 2021
9f66ae4
Update ArrowVisual test
atharva-18 Jul 6, 2021
c7e2f38
Update AxisVisual test
atharva-18 Jul 6, 2021
543de15
Fix variable name
atharva-18 Jul 6, 2021
464347c
Fix visibility and destroy
atharva-18 Jul 7, 2021
00c2c73
Fix destroy child visuals
atharva-18 Jul 8, 2021
4da8e7a
Fix BaseArrowVisual::Destroy
atharva-18 Jul 13, 2021
f0c535c
Add test
atharva-18 Jul 16, 2021
6925f90
Merge branch 'main' of https://github.com/ignitionrobotics/ign-render…
atharva-18 Jul 19, 2021
b141395
Use IGN_PI
atharva-18 Jul 19, 2021
42d6394
Style comments
atharva-18 Jul 20, 2021
0e16df2
Add curly braces
atharva-18 Jul 20, 2021
54feb2c
Merge branch 'main' of https://github.com/ignitionrobotics/ign-render…
atharva-18 Jul 20, 2021
4cde823
Merge branch 'main' of https://github.com/ignitionrobotics/ign-render…
atharva-18 Aug 9, 2021
bfbb44b
Add useParentFrame
atharva-18 Aug 17, 2021
4884de6
Style fixes
atharva-18 Aug 17, 2021
d0a4bed
Remove const
atharva-18 Aug 18, 2021
745e563
Style fixes
atharva-18 Aug 18, 2021
45cb492
Add documentation inherited
atharva-18 Aug 18, 2021
3d31542
Change joint parent material
atharva-18 Aug 18, 2021
9edace1
Improve joint visual demo
atharva-18 Aug 18, 2021
714d523
Fix Revolute2 and Universal joint visual types
atharva-18 Aug 18, 2021
fc6c6e3
Add destroy check to test
atharva-18 Aug 19, 2021
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
34 changes: 32 additions & 2 deletions examples/visualization_demo/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void buildScene(ScenePtr _scene)
VisualPtr box = _scene->CreateVisual("parent_box");
box->AddGeometry(_scene->CreateBox());
box->SetOrigin(0.0, 0.0, 0.0);
box->SetLocalPosition(4.5, 0.0, 0.0);
box->SetLocalPosition(4.5, -1.0, 0.0);
box->SetLocalRotation(0, 0, 0);
box->SetMaterial(blue);
root->AddChild(box);
Expand All @@ -149,7 +149,7 @@ void buildScene(ScenePtr _scene)
ignition::math::Pose3d p(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
ignition::math::Inertiald inertial{massMatrix, p};
inertiaVisual->SetInertial(inertial);
inertiaVisual->SetLocalPosition(1, 0, 0);
inertiaVisual->SetLocalPosition(1.5, -1.0, 0);
root->AddChild(inertiaVisual);

// create CoM visual
Expand All @@ -162,6 +162,36 @@ void buildScene(ScenePtr _scene)
comVisual->SetInertial(comVisualInertial);
box->AddChild(comVisual);

// create joint child visual
VisualPtr jointChildBox = _scene->CreateVisual("joint_child");
jointChildBox->AddGeometry(_scene->CreateBox());
jointChildBox->SetOrigin(0.0, 0.0, 0.0);
jointChildBox->SetLocalPosition(3.5, 0.5, 0.0);
jointChildBox->SetLocalRotation(0, 0, 0);
jointChildBox->SetMaterial(blue);
root->AddChild(jointChildBox);

// create joint parent visual
VisualPtr jointParentBox = _scene->CreateVisual("joint_parent");
jointParentBox->AddGeometry(_scene->CreateBox());
jointParentBox->SetOrigin(0.0, 0.0, 0.0);
jointParentBox->SetLocalPosition(2.0, 0.5, 0.0);
jointParentBox->SetLocalRotation(0, 0, 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

use a different rotation from child to show what the parent axis looks like with rotation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

jointParentBox->SetMaterial(blue);
jointParentBox->Material()->SetTransparency(0.5);
jointParentBox->Material()->SetDepthWriteEnabled(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

  jointParentBox->Material()->SetTransparency(0.5);
  jointParentBox->Material()->SetDepthWriteEnabled(false);

do you still need to these 2 calls? The blue material should have these set.

Alternatively, set to a different color material so it's easier to distinguish between parent and child box

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed material to gray in 3d31542

root->AddChild(jointParentBox);

// create joint visual
JointVisualPtr jointVisual = _scene->CreateJointVisual();
jointChildBox->AddChild(jointVisual);
jointVisual->SetType(JointVisualType::JVT_REVOLUTE);
Copy link
Contributor

Choose a reason for hiding this comment

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

I was a little confused at first to see 2 joint visuals while the type is JVT_REVOLUTE. I would expect this to be JVT_REVOLUTE2 or JVT_UNIVERSAL. Maybe only create the parent axes or make it visible if joint type is revolute2 / universal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

714d523 should fix it

ignition::math::Vector3d axis2(1.0, 0.0, 0.0);
Copy link
Contributor

Choose a reason for hiding this comment

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

set to a non-unit axis to show what the joint visual would look like? ,e.g. axis2(1.0, 1.0, 1.0)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

jointVisual->SetAxis(axis2, "");

ignition::math::Vector3d axis1(1.0, 0.0, 0.0);
jointVisual->SetParentAxis(axis1, "__model__", jointParentBox->Name());

// create camera
CameraPtr camera = _scene->CreateCamera("camera");
camera->SetLocalPosition(0.0, 0.0, 0.0);
Expand Down
12 changes: 12 additions & 0 deletions include/ignition/rendering/ArrowVisual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,21 @@ namespace ignition
/// \return The arrow-shaft visual
public: virtual VisualPtr Shaft() const = 0;

/// \brief Get arrow-rotation visual
/// \return The arrow-rotation visual
public: virtual VisualPtr Rotation() const = 0;

/// \brief set true to show the arrow head, false otherwise
/// \param[in] _b true to show the arrow head, false otherwise
public: virtual void ShowArrowHead(bool _b) = 0;

/// \brief set true to show the arrow shaft, false otherwise
/// \param[in] _b true to show the arrow shaft, false otherwise
public: virtual void ShowArrowShaft(bool _b) = 0;

/// \brief Set true to show the rotation of the arrow, false otherwise
/// \param[in] _b True to show the arrow rotation.
public: virtual void ShowArrowRotation(bool _b) = 0;
};
}
}
Expand Down
5 changes: 5 additions & 0 deletions include/ignition/rendering/AxisVisual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ namespace ignition
/// \brief set true to show the axis heads, false otherwise
/// \param[in] _b true to show the axis heads, false otherwise
public: virtual void ShowAxisHead(bool _b) = 0;

/// \brief set true to show the specified axis head, false otherwise
/// \param[in] _axis Axis index. 0: x, 1: y, 2: z
/// \param[in] _b true to show the specified axis head, false otherwise
public: virtual void ShowAxisHead(unsigned int _axis, bool _b) = 0;
};
}
}
Expand Down
146 changes: 146 additions & 0 deletions include/ignition/rendering/JointVisual.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/*
* Copyright (C) 2021 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef IGNITION_RENDERING_JOINTVISUAL_HH_
#define IGNITION_RENDERING_JOINTVISUAL_HH_

#include <string>
#include <ignition/math/Vector3.hh>
#include "ignition/rendering/config.hh"
#include "ignition/rendering/Object.hh"
#include "ignition/rendering/RenderTypes.hh"
#include "ignition/rendering/Visual.hh"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#include <string>
#include <ignition/math/Vector3.hh>
#include "ignition/rendering/config.hh"
#include "ignition/rendering/Object.hh"
#include "ignition/rendering/RenderTypes.hh"
#include "ignition/rendering/Visual.hh"
#include <string>
#include <ignition/math/Vector3.hh>
#include "ignition/rendering/config.hh"
#include "ignition/rendering/Object.hh"
#include "ignition/rendering/RenderTypes.hh"
#include "ignition/rendering/Visual.hh"

Copy link
Contributor Author

Choose a reason for hiding this comment

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


namespace ignition
{
namespace rendering
{
inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
//
/// \brief Enum for JointVisual types
enum IGNITION_RENDERING_VISIBLE JointVisualType
{
/// \brief No type
JVT_NONE = 0,

/// \brief Revolute joint type
JVT_REVOLUTE = 1,

/// \brief Revolute2 joint type
JVT_REVOLUTE2 = 2,

/// \brief Prismatic joint type
JVT_PRISMATIC = 3,

/// \brief Universal joint type
JVT_UNIVERSAL = 4,

/// \brief Ball joint type
JVT_BALL = 5,

/// \brief Screw joint type
JVT_SCREW = 6,

/// \brief Gearbox joint type
JVT_GEARBOX = 7,

/// \brief Fixed joint type
JVT_FIXED = 8
};

/// \class JointVisual JointVisual.hh
/// ignition/rendering/JointVisual.hh
/// \brief Represents a joint visual
class IGNITION_RENDERING_VISIBLE JointVisual :
public virtual Visual
{
/// \brief Destructor
public: virtual ~JointVisual() {}

/// \brief Create an axis and attach it to the joint visual.
/// \param[in] _axis Axis vector.
/// \param[in] _xyzExpressedIn Frame in which the axis vector is
/// expressed.
public: virtual void SetAxis(const ignition::math::Vector3d &_axis,
const std::string &_xyzExpressedIn) = 0;

/// \brief Get axis vector.
/// \return The axis vector.
public: virtual ignition::math::Vector3d Axis() const = 0;

/// \brief Get axis frame.
/// \return The axis frame.
public: virtual std::string AxisFrame() const = 0;

/// \brief Create a parent axis for hinge2 and universal joint types
/// and attach it to the joint visual.
/// \param[in] _axis Axis vector.
/// \param[in] _xyzExpressedIn Frame in which the axis vector is
/// expressed.
/// \param[in] _parentName Joint parent name.
public: virtual void SetParentAxis(
const ignition::math::Vector3d &_axis,
const std::string &_xyzExpressedIn,
const std::string &_parentName) = 0;

/// \brief Get parent axis vector.
/// \return The parent axis vector.
public: virtual ignition::math::Vector3d ParentAxis() const = 0;

/// \brief Get parent axis frame.
/// \return The parent axis frame.
public: virtual std::string ParentAxisFrame() const = 0;

/// \brief Update an axis' arrow visual.
/// \param[in] _axis Axis vector.
/// \param[in] _xyzExpressedIn Frame in which the axis vector is
/// expressed.
/// \return True if axis was updated else false.
public: virtual bool UpdateAxis(const ignition::math::Vector3d &_axis,
const std::string &_xyzExpressedIn) = 0;

/// \brief Update the parent axis' arrow visual if it exists.
/// \param[in] _arrowVisual Arrow visual to be updated.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// \param[in] _arrowVisual Arrow visual to be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

/// \param[in] _axis Axis vector.
/// \param[in] _xyzExpressedIn Frame in which the axis vector is
/// expressed.
/// \param[in] _parentName Name of the joint parent.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// \param[in] _parentName Name of the joint parent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

/// \return True if parent axis was updated else false.
public: virtual bool UpdateParentAxis(
const ignition::math::Vector3d &_axis,
const std::string &_xyzExpressedIn) = 0;

/// \brief Set type for joint visual.
/// \param[in] _type The type of visualisation for joint.
public: virtual void SetType(const JointVisualType _type) = 0;

/// \brief Get joint visual type.
/// \return The joint visual type.
public: virtual JointVisualType Type() const = 0;

/// \brief Get the JointVisual which is attached to the parent.
/// \return Parent axis visual.
public: virtual JointVisualPtr ParentAxisVisual() const = 0;

/// \brief Get the arrow visual which represents the axis attached to the
/// child.
/// \return Arrow visual.
public: virtual ArrowVisualPtr ArrowVisual() const = 0;
};
}
}
}
#endif
4 changes: 4 additions & 0 deletions include/ignition/rendering/Node.hh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ namespace ignition
/// \return The local pose
public: virtual math::Pose3d LocalPose() const = 0;

/// \brief Get the initial local pose
/// \return The initial local pose
public: virtual math::Pose3d InitialLocalPose() const = 0;

/// \brief Set the local pose
/// \param[in] _pose New local pose
public: virtual void SetLocalPose(const math::Pose3d &_pose) = 0;
Expand Down
29 changes: 29 additions & 0 deletions include/ignition/rendering/Scene.hh
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,35 @@ namespace ignition
public: virtual InertiaVisualPtr CreateInertiaVisual(
unsigned int _id, const std::string &_name) = 0;

/// \brief Create new Joint visual. A unique ID and name will
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// \brief Create new Joint visual. A unique ID and name will
/// \brief Create new joint visual. A unique ID and name will

here and below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

/// automatically be assigned to the Joint visual.
/// \return The created Joint visual
public: virtual JointVisualPtr CreateJointVisual() = 0;

/// \brief Create new Joint visual with the given ID. A unique name
/// will automatically be assigned to the visual. If the given ID is
/// already in use, NULL will be returned.
/// \param[in] _id ID of the new Joint visual
/// \return The created Joint visual
public: virtual JointVisualPtr CreateJointVisual(
unsigned int _id) = 0;

/// \brief Create new Joint visual with the given name. A unique ID
/// will automatically be assigned to the visual. If the given name is
/// already in use, NULL will be returned.
/// \param[in] _name Name of the new Joint visual
/// \return The created Joint visual
public: virtual JointVisualPtr CreateJointVisual(
const std::string &_name) = 0;

/// \brief Create new Joint visual with the given name. If either the
/// given ID or name is already in use, NULL will be returned.
/// \param[in] _id ID of the new Joint visual
/// \param[in] _name Name of the new Joint visual
/// \return The created Joint visual
public: virtual JointVisualPtr CreateJointVisual(
unsigned int _id, const std::string &_name) = 0;

/// \brief Create new light visual. A unique ID and name will
/// automatically be assigned to the light visual.
/// \return The created light visual
Expand Down
Loading