Skip to content

Commit b2936e0

Browse files
authored
Merge fc6c6e3 into afa2270
2 parents afa2270 + fc6c6e3 commit b2936e0

24 files changed

+1319
-6
lines changed

examples/visualization_demo/Main.cc

+40-2
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,21 @@ void buildScene(ScenePtr _scene)
118118
blue->SetTransparency(0.5);
119119
blue->SetDepthWriteEnabled(false);
120120

121+
// create gray material
122+
MaterialPtr gray = _scene->CreateMaterial();
123+
gray->SetAmbient(0.7, 0.7, 0.7);
124+
gray->SetDiffuse(0.7, 0.7, 0.7);
125+
gray->SetSpecular(0.7, 0.7, 0.7);
126+
gray->SetShininess(50);
127+
gray->SetReflectivity(0);
128+
gray->SetTransparency(0.75);
129+
gray->SetDepthWriteEnabled(false);
130+
121131
// create box visual
122132
VisualPtr box = _scene->CreateVisual("parent_box");
123133
box->AddGeometry(_scene->CreateBox());
124134
box->SetOrigin(0.0, 0.0, 0.0);
125-
box->SetLocalPosition(4.5, 0.0, 0.0);
135+
box->SetLocalPosition(4.5, -1.0, 0.0);
126136
box->SetLocalRotation(0, 0, 0);
127137
box->SetMaterial(blue);
128138
root->AddChild(box);
@@ -149,7 +159,7 @@ void buildScene(ScenePtr _scene)
149159
ignition::math::Pose3d p(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
150160
ignition::math::Inertiald inertial{massMatrix, p};
151161
inertiaVisual->SetInertial(inertial);
152-
inertiaVisual->SetLocalPosition(1, 0, 0);
162+
inertiaVisual->SetLocalPosition(1.5, -1.0, 0);
153163
root->AddChild(inertiaVisual);
154164

155165
// create CoM visual
@@ -162,6 +172,34 @@ void buildScene(ScenePtr _scene)
162172
comVisual->SetInertial(comVisualInertial);
163173
box->AddChild(comVisual);
164174

175+
// create joint child visual
176+
VisualPtr jointChildBox = _scene->CreateVisual("joint_child");
177+
jointChildBox->AddGeometry(_scene->CreateBox());
178+
jointChildBox->SetOrigin(0.0, 0.0, 0.0);
179+
jointChildBox->SetLocalPosition(3.5, 0.5, 0.0);
180+
jointChildBox->SetLocalRotation(0, 0, 0);
181+
jointChildBox->SetMaterial(blue);
182+
root->AddChild(jointChildBox);
183+
184+
// create joint parent visual
185+
VisualPtr jointParentBox = _scene->CreateVisual("joint_parent");
186+
jointParentBox->AddGeometry(_scene->CreateBox());
187+
jointParentBox->SetOrigin(0.0, 0.0, 0.0);
188+
jointParentBox->SetLocalPosition(2.0, 0.5, 0.0);
189+
jointParentBox->SetLocalRotation(1.5, -1.0, 0);
190+
jointParentBox->SetMaterial(gray);
191+
root->AddChild(jointParentBox);
192+
193+
// create joint visual
194+
JointVisualPtr jointVisual = _scene->CreateJointVisual();
195+
jointChildBox->AddChild(jointVisual);
196+
jointVisual->SetType(JointVisualType::JVT_REVOLUTE2);
197+
ignition::math::Vector3d axis2(1.0, 1.0, 1.0);
198+
jointVisual->SetAxis(axis2);
199+
200+
ignition::math::Vector3d axis1(1.0, 0.0, 0.0);
201+
jointVisual->SetParentAxis(axis1, jointParentBox->Name(), true);
202+
165203
// create camera
166204
CameraPtr camera = _scene->CreateCamera("camera");
167205
camera->SetLocalPosition(0.0, 0.0, 0.0);

include/ignition/rendering/ArrowVisual.hh

+12
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,21 @@ namespace ignition
4242
/// \return The arrow-shaft visual
4343
public: virtual VisualPtr Shaft() const = 0;
4444

45+
/// \brief Get arrow-rotation visual
46+
/// \return The arrow-rotation visual
47+
public: virtual VisualPtr Rotation() const = 0;
48+
4549
/// \brief set true to show the arrow head, false otherwise
4650
/// \param[in] _b true to show the arrow head, false otherwise
4751
public: virtual void ShowArrowHead(bool _b) = 0;
52+
53+
/// \brief set true to show the arrow shaft, false otherwise
54+
/// \param[in] _b true to show the arrow shaft, false otherwise
55+
public: virtual void ShowArrowShaft(bool _b) = 0;
56+
57+
/// \brief Set true to show the rotation of the arrow, false otherwise
58+
/// \param[in] _b True to show the arrow rotation.
59+
public: virtual void ShowArrowRotation(bool _b) = 0;
4860
};
4961
}
5062
}

include/ignition/rendering/AxisVisual.hh

+5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ namespace ignition
3737
/// \brief set true to show the axis heads, false otherwise
3838
/// \param[in] _b true to show the axis heads, false otherwise
3939
public: virtual void ShowAxisHead(bool _b) = 0;
40+
41+
/// \brief set true to show the specified axis head, false otherwise
42+
/// \param[in] _axis Axis index. 0: x, 1: y, 2: z
43+
/// \param[in] _b true to show the specified axis head, false otherwise
44+
public: virtual void ShowAxisHead(unsigned int _axis, bool _b) = 0;
4045
};
4146
}
4247
}
+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
/*
2+
* Copyright (C) 2021 Open Source Robotics Foundation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
#ifndef IGNITION_RENDERING_JOINTVISUAL_HH_
18+
#define IGNITION_RENDERING_JOINTVISUAL_HH_
19+
20+
#include <string>
21+
22+
#include <ignition/math/Vector3.hh>
23+
24+
#include "ignition/rendering/config.hh"
25+
#include "ignition/rendering/Object.hh"
26+
#include "ignition/rendering/RenderTypes.hh"
27+
#include "ignition/rendering/Visual.hh"
28+
29+
namespace ignition
30+
{
31+
namespace rendering
32+
{
33+
inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
34+
//
35+
/// \brief Enum for JointVisual types
36+
enum IGNITION_RENDERING_VISIBLE JointVisualType
37+
{
38+
/// \brief No type
39+
JVT_NONE = 0,
40+
41+
/// \brief Revolute joint type
42+
JVT_REVOLUTE = 1,
43+
44+
/// \brief Revolute2 joint type
45+
JVT_REVOLUTE2 = 2,
46+
47+
/// \brief Prismatic joint type
48+
JVT_PRISMATIC = 3,
49+
50+
/// \brief Universal joint type
51+
JVT_UNIVERSAL = 4,
52+
53+
/// \brief Ball joint type
54+
JVT_BALL = 5,
55+
56+
/// \brief Screw joint type
57+
JVT_SCREW = 6,
58+
59+
/// \brief Gearbox joint type
60+
JVT_GEARBOX = 7,
61+
62+
/// \brief Fixed joint type
63+
JVT_FIXED = 8
64+
};
65+
66+
/// \class JointVisual JointVisual.hh
67+
/// ignition/rendering/JointVisual.hh
68+
/// \brief Represents a joint visual
69+
class IGNITION_RENDERING_VISIBLE JointVisual :
70+
public virtual Visual
71+
{
72+
/// \brief Destructor
73+
public: virtual ~JointVisual() {}
74+
75+
/// \brief Create an axis and attach it to the joint visual.
76+
/// \param[in] _axis Axis vector.
77+
/// \param[in] _useParentFrame True if axis vector is expressed in
78+
/// parent frame.
79+
public: virtual void SetAxis(const ignition::math::Vector3d &_axis,
80+
bool _useParentFrame = false) = 0;
81+
82+
/// \brief Get axis vector.
83+
/// \return The axis vector.
84+
public: virtual ignition::math::Vector3d Axis() const = 0;
85+
86+
/// \brief Create a parent axis for hinge2 and universal joint types
87+
/// and attach it to the joint visual.
88+
/// \param[in] _axis Axis vector.
89+
/// \param[in] _parentName Joint parent name.
90+
/// \param[in] _useParentFrame True if axis vector is expressed in
91+
/// parent frame.
92+
public: virtual void SetParentAxis(
93+
const ignition::math::Vector3d &_axis,
94+
const std::string &_parentName,
95+
bool _useParentFrame = false) = 0;
96+
97+
/// \brief Get parent axis vector.
98+
/// \return The parent axis vector.
99+
public: virtual ignition::math::Vector3d ParentAxis() const = 0;
100+
101+
/// \brief Update an axis' arrow visual.
102+
/// \param[in] _axis Axis vector.
103+
/// \param[in] _useParentFrame True if axis vector is expressed in
104+
/// parent frame.
105+
/// \return True if axis was updated else false.
106+
public: virtual bool UpdateAxis(const ignition::math::Vector3d &_axis,
107+
bool _useParentFrame = false) = 0;
108+
109+
/// \brief Update the parent axis' arrow visual if it exists.
110+
/// \param[in] _axis Axis vector.
111+
/// \param[in] _useParentFrame True if axis vector is expressed in
112+
/// parent frame.
113+
/// \return True if parent axis was updated else false.
114+
public: virtual bool UpdateParentAxis(
115+
const ignition::math::Vector3d &_axis,
116+
bool _useParentFrame = false) = 0;
117+
118+
/// \brief Set type for joint visual.
119+
/// \param[in] _type The type of visualisation for joint.
120+
public: virtual void SetType(const JointVisualType _type) = 0;
121+
122+
/// \brief Get joint visual type.
123+
/// \return The joint visual type.
124+
public: virtual JointVisualType Type() const = 0;
125+
126+
/// \brief Get the JointVisual which is attached to the parent.
127+
/// \return Parent axis visual.
128+
public: virtual JointVisualPtr ParentAxisVisual() const = 0;
129+
130+
/// \brief Get the arrow visual which represents the axis attached to the
131+
/// child.
132+
/// \return Arrow visual.
133+
public: virtual ArrowVisualPtr ArrowVisual() const = 0;
134+
};
135+
}
136+
}
137+
}
138+
#endif

include/ignition/rendering/Node.hh

+4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ namespace ignition
7070
/// \return The local pose
7171
public: virtual math::Pose3d LocalPose() const = 0;
7272

73+
/// \brief Get the initial local pose
74+
/// \return The initial local pose
75+
public: virtual math::Pose3d InitialLocalPose() const = 0;
76+
7377
/// \brief Set the local pose
7478
/// \param[in] _pose New local pose
7579
public: virtual void SetLocalPose(const math::Pose3d &_pose) = 0;

include/ignition/rendering/Scene.hh

+29
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,35 @@ namespace ignition
881881
public: virtual InertiaVisualPtr CreateInertiaVisual(
882882
unsigned int _id, const std::string &_name) = 0;
883883

884+
/// \brief Create new joint visual. A unique ID and name will
885+
/// automatically be assigned to the Joint visual.
886+
/// \return The created Joint visual
887+
public: virtual JointVisualPtr CreateJointVisual() = 0;
888+
889+
/// \brief Create new joint visual with the given ID. A unique name
890+
/// will automatically be assigned to the visual. If the given ID is
891+
/// already in use, NULL will be returned.
892+
/// \param[in] _id ID of the new Joint visual
893+
/// \return The created Joint visual
894+
public: virtual JointVisualPtr CreateJointVisual(
895+
unsigned int _id) = 0;
896+
897+
/// \brief Create new joint visual with the given name. A unique ID
898+
/// will automatically be assigned to the visual. If the given name is
899+
/// already in use, NULL will be returned.
900+
/// \param[in] _name Name of the new Joint visual
901+
/// \return The created Joint visual
902+
public: virtual JointVisualPtr CreateJointVisual(
903+
const std::string &_name) = 0;
904+
905+
/// \brief Create new joint visual with the given name. If either the
906+
/// given ID or name is already in use, NULL will be returned.
907+
/// \param[in] _id ID of the new Joint visual
908+
/// \param[in] _name Name of the new Joint visual
909+
/// \return The created Joint visual
910+
public: virtual JointVisualPtr CreateJointVisual(
911+
unsigned int _id, const std::string &_name) = 0;
912+
884913
/// \brief Create new light visual. A unique ID and name will
885914
/// automatically be assigned to the light visual.
886915
/// \return The created light visual

0 commit comments

Comments
 (0)