Gazebo Gazebo

API Reference

6.18.0
gz/sim/Joint.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 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 GZ_GAZEBO_JOINT_HH_
18 #define GZ_GAZEBO_JOINT_HH_
19 
20 #include <memory>
21 #include <optional>
22 #include <string>
23 #include <vector>
24 
25 #include <gz/msgs/wrench.pb.h>
26 #include <gz/utils/ImplPtr.hh>
27 
28 #include <gz/math/Pose3.hh>
29 #include <gz/math/Vector2.hh>
30 #include <gz/math/Vector3.hh>
31 
32 #include <sdf/Joint.hh>
33 #include <sdf/JointAxis.hh>
34 
35 #include "gz/sim/config.hh"
37 #include "gz/sim/Export.hh"
38 #include "gz/sim/Model.hh"
39 #include "gz/sim/Types.hh"
40 
41 namespace ignition
42 {
43  namespace gazebo
44  {
45  // Inline bracket to help doxygen filtering.
46  inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
47  //
67  class IGNITION_GAZEBO_VISIBLE Joint
68  {
71  public: explicit Joint(gazebo::Entity _entity = kNullEntity);
72 
75  public: gazebo::Entity Entity() const;
76 
79  public: void ResetEntity(gazebo::Entity _newEntity);
80 
85  public: bool Valid(const EntityComponentManager &_ecm) const;
86 
91  public: std::optional<std::string> Name(
92  const EntityComponentManager &_ecm) const;
93 
98  public: std::optional<std::string> ParentLinkName(
99  const EntityComponentManager &_ecm) const;
100 
105  public: std::optional<std::string> ChildLinkName(
106  const EntityComponentManager &_ecm) const;
107 
112  public: std::optional<math::Pose3d> Pose(
113  const EntityComponentManager &_ecm) const;
114 
119  public: std::optional<double> ThreadPitch(
120  const EntityComponentManager &_ecm) const;
121 
126  public: std::optional<std::vector<sdf::JointAxis>> Axis(
127  const EntityComponentManager &_ecm) const;
128 
133  public: std::optional<sdf::JointType> Type(
134  const EntityComponentManager &_ecm) const;
135 
142  const std::string &_name) const;
143 
148  const EntityComponentManager &_ecm) const;
149 
154  public: uint64_t SensorCount(const EntityComponentManager &_ecm) const;
155 
165  const std::vector<double> &_velocities);
166 
173  public: void SetForce(EntityComponentManager &_ecm,
174  const std::vector<double> &_forces);
175 
183  const std::vector<math::Vector2d> &_limits);
184 
192  const std::vector<math::Vector2d> &_limits);
193 
201  const std::vector<math::Vector2d> &_limits);
202 
209  const std::vector<double> &_positions);
210 
218  const std::vector<double> &_velocities);
219 
227  bool _enable = true) const;
228 
236  bool _enable = true) const;
237 
245  bool _enable = true) const;
246 
252  public: std::optional<std::vector<double>> Velocity(
253  const EntityComponentManager &_ecm) const;
254 
260  public: std::optional<std::vector<double>> Position(
261  const EntityComponentManager &_ecm) const;
262 
268  public: std::optional<std::vector<msgs::Wrench>> TransmittedWrench(
269  const EntityComponentManager &_ecm) const;
270 
275  public: std::optional<Model> ParentModel(
276  const EntityComponentManager &_ecm) const;
277 
286  public: std::optional<std::vector<double>> EffortLimits(
287  const EntityComponentManager &_ecm) const;
288 
297  public: std::optional<std::vector<math::Vector2d>> PositionLimits(
298  const EntityComponentManager &_ecm) const;
299 
308  public: std::optional<std::vector<double>> MaxVelocityLimits(
309  const EntityComponentManager &_ecm) const;
310 
312  IGN_UTILS_IMPL_PTR(dataPtr)
313  };
314  }
315  }
316 }
317 #endif
The EntityComponentManager constructs, deletes, and returns components and entities....
Definition: gz/sim/EntityComponentManager.hh:67
This class provides wrappers around entities and components which are more convenient and straight-fo...
Definition: gz/sim/Joint.hh:68
std::optional< std::vector< msgs::Wrench > > TransmittedWrench(const EntityComponentManager &_ecm) const
Get the transmitted wrench of the joint.
void EnableTransmittedWrenchCheck(EntityComponentManager &_ecm, bool _enable=true) const
By default, Gazebo will not report transmitted wrench for a joint, so functions like TransmittedWrenc...
void EnableVelocityCheck(EntityComponentManager &_ecm, bool _enable=true) const
By default, Gazebo will not report velocities for a joint, so functions like Velocity will return nul...
void SetForce(EntityComponentManager &_ecm, const std::vector< double > &_forces)
Set force on this joint. If both forces and velocities are set, only forces are applied.
uint64_t SensorCount(const EntityComponentManager &_ecm) const
Get the number of sensors which are immediate children of this joint.
std::optional< std::vector< math::Vector2d > > PositionLimits(const EntityComponentManager &_ecm) const
Get joint position limits.
std::optional< math::Pose3d > Pose(const EntityComponentManager &_ecm) const
Get the pose of the joint.
void SetVelocityLimits(EntityComponentManager &_ecm, const std::vector< math::Vector2d > &_limits)
Set the velocity limits on a joint axis.
std::optional< Model > ParentModel(const EntityComponentManager &_ecm) const
Get the parent model.
std::optional< std::string > ParentLinkName(const EntityComponentManager &_ecm) const
Get the parent link name.
std::optional< std::string > ChildLinkName(const EntityComponentManager &_ecm) const
Get the child link name.
std::optional< sdf::JointType > Type(const EntityComponentManager &_ecm) const
Get the joint type.
gazebo::Entity SensorByName(const EntityComponentManager &_ecm, const std::string &_name) const
Get the ID of a sensor entity which is an immediate child of this joint.
std::vector< gazebo::Entity > Sensors(const EntityComponentManager &_ecm) const
Get all sensors which are immediate children of this joint.
void SetEffortLimits(EntityComponentManager &_ecm, const std::vector< math::Vector2d > &_limits)
Set the effort limits on a joint axis.
std::optional< std::vector< double > > Velocity(const EntityComponentManager &_ecm) const
Get the velocity of the joint.
std::optional< std::string > Name(const EntityComponentManager &_ecm) const
Get the joint's unscoped name.
void ResetEntity(gazebo::Entity _newEntity)
Reset Entity to a new one.
void EnablePositionCheck(EntityComponentManager &_ecm, bool _enable=true) const
By default, Gazebo will not report positions for a joint, so functions like Position will return null...
void SetVelocity(EntityComponentManager &_ecm, const std::vector< double > &_velocities)
Set velocity on this joint. Only applied if no forces are set.
bool Valid(const EntityComponentManager &_ecm) const
Check whether this joint correctly refers to an entity that has a components::Joint.
Joint(gazebo::Entity _entity=kNullEntity)
Constructor.
std::optional< std::vector< double > > EffortLimits(const EntityComponentManager &_ecm) const
Get joint effort limits.
void ResetVelocity(EntityComponentManager &_ecm, const std::vector< double > &_velocities)
Reset the joint velocities.
std::optional< std::vector< double > > MaxVelocityLimits(const EntityComponentManager &_ecm) const
Get joint velocity limits.
gazebo::Entity Entity() const
Get the entity which this Joint is related to.
std::optional< std::vector< sdf::JointAxis > > Axis(const EntityComponentManager &_ecm) const
Get the joint axis.
void SetPositionLimits(EntityComponentManager &_ecm, const std::vector< math::Vector2d > &_limits)
Set the position limits on a joint axis.
std::optional< std::vector< double > > Position(const EntityComponentManager &_ecm) const
Get the position of the joint.
std::optional< double > ThreadPitch(const EntityComponentManager &_ecm) const
Get the thread pitch of the joint.
void ResetPosition(EntityComponentManager &_ecm, const std::vector< double > &_positions)
Reset the joint positions.
const Entity kNullEntity
Indicates a non-existant or invalid Entity.
Definition: gz/sim/Entity.hh:61
uint64_t Entity
An Entity identifies a single object in simulation such as a model, link, or light....
Definition: gz/sim/Entity.hh:58
This library is part of the Gazebo project.
Definition: gz/sim/Actor.hh:34