-
Notifications
You must be signed in to change notification settings - Fork 58
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
Joint visual #366
Changes from 21 commits
134faeb
21746c7
e2b2440
50f6d45
5dd198c
bfd743f
409ddd1
deecbb1
71a0e7e
392d3d6
b4f86e0
49e7247
9b3afe5
9f66ae4
c7e2f38
543de15
464347c
00c2c73
4da8e7a
f0c535c
6925f90
b141395
42d6394
0e16df2
54feb2c
4cde823
bfbb44b
4884de6
d0a4bed
745e563
45cb492
3d31542
9edace1
714d523
fc6c6e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
|
@@ -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 | ||
|
@@ -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); | ||
jointParentBox->SetMaterial(blue); | ||
jointParentBox->Material()->SetTransparency(0.5); | ||
jointParentBox->Material()->SetDepthWriteEnabled(false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
do you still need to these 2 calls? The Alternatively, set to a different color material so it's easier to distinguish between parent and child box There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed material to gray in |
||
root->AddChild(jointParentBox); | ||
|
||
// create joint visual | ||
JointVisualPtr jointVisual = _scene->CreateJointVisual(); | ||
jointChildBox->AddChild(jointVisual); | ||
jointVisual->SetType(JointVisualType::JVT_REVOLUTE); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
ignition::math::Vector3d axis2(1.0, 0.0, 0.0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
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" | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
here and below There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||||||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9edace1