joint.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <angles/angles.h>
4 #include <control_toolbox/pid.h>
5 #include <franka/robot_state.h>
7 #include <ros/ros.h>
8 #include <Eigen/Dense>
9 #include <boost/optional.hpp>
10 #include <gazebo/physics/Joint.hh>
11 
12 namespace franka_gazebo {
13 
18 
25 struct Joint {
26  public:
27  Joint() = default;
28  Joint(Joint&&) = default;
29  Joint(const Joint&) = delete;
30 
35  void update(const ros::Duration& dt);
36 
38  std::string name;
39 
41  gazebo::physics::JointPtr handle;
42 
45  int type;
46 
50 
52  Eigen::Vector3d axis;
53 
56  double command = 0;
57 
62  double desired_position = 0;
63 
67  double desired_velocity = 0;
68 
71  boost::optional<ControlMethod> control_method = boost::none;
72 
74  double gravity = 0;
75 
77  double position = 0;
78 
80  double velocity = 0;
81 
83  double effort = 0;
84 
87  double jerk = 0;
88 
91  double acceleration = 0;
92 
94  double contact_threshold = std::numeric_limits<double>::infinity();
95 
98  double collision_threshold = std::numeric_limits<double>::infinity();
99 
101  double stop_position = 0;
102 
112  double getDesiredPosition(const franka::RobotMode& mode) const;
113 
122  double getDesiredVelocity(const franka::RobotMode& mode) const;
123 
132  double getDesiredAcceleration(const franka::RobotMode& mode) const;
133 
142  double getDesiredTorque(const franka::RobotMode& mode) const;
143 
148  double getLinkMass() const;
149 
154  bool isInContact() const;
155 
160  bool isInCollision() const;
161 
165 
169 
170  private:
171  double lastVelocity = std::numeric_limits<double>::quiet_NaN();
172  double lastAcceleration = std::numeric_limits<double>::quiet_NaN();
173 };
174 
175 } // namespace franka_gazebo
franka_gazebo::Joint::stop_position
double stop_position
Position used as desired position if control_method is none.
Definition: joint.h:101
franka_gazebo::Joint::contact_threshold
double contact_threshold
Above which threshold forces or torques will be interpreted as "contacts" by isInContact.
Definition: joint.h:94
franka_gazebo
Definition: controller_verifier.h:8
franka_gazebo::Joint::getDesiredPosition
double getDesiredPosition(const franka::RobotMode &mode) const
Decide what the desired position of this joint is based on:
Definition: joint.cpp:55
franka_gazebo::Joint::gravity
double gravity
The currently acting gravity force or torque acting on this joint in or .
Definition: joint.h:74
joint_limits_interface::JointLimits
franka_gazebo::Joint::velocity_controller
control_toolbox::Pid velocity_controller
The PID gains used for the controller, when in "velocity" control mode.
Definition: joint.h:168
ros.h
franka_gazebo::Joint::limits
joint_limits_interface::JointLimits limits
Joint limits.
Definition: joint.h:49
franka_gazebo::Joint::isInContact
bool isInContact() const
Is the joint currently in contact with something?
Definition: joint.cpp:111
franka_gazebo::EFFORT
@ EFFORT
Definition: joint.h:17
franka_gazebo::Joint::desired_velocity
double desired_velocity
The current desired velocity that is used for the PID controller when the joints control method is "V...
Definition: joint.h:67
joint_limits.h
franka_gazebo::Joint::acceleration
double acceleration
The currently acting acceleration on this joint in either or .
Definition: joint.h:91
franka_gazebo::Joint::jerk
double jerk
The currently acting jerk acting on this this joint in either or .
Definition: joint.h:87
franka_gazebo::Joint::isInCollision
bool isInCollision() const
Is the joint currently in contact with something?
Definition: joint.cpp:107
franka_gazebo::Joint::command
double command
The currently applied command from a controller acting on this joint either in or without gravity.
Definition: joint.h:56
franka_gazebo::Joint::position
double position
The current position of this joint either in or .
Definition: joint.h:77
franka_gazebo::Joint::control_method
boost::optional< ControlMethod > control_method
Decides whether the joint is doing torque control or if the position or velocity should be controlled...
Definition: joint.h:71
franka_gazebo::Joint::getDesiredVelocity
double getDesiredVelocity(const franka::RobotMode &mode) const
Decide what the desired velocity of this joint is based on:
Definition: joint.cpp:66
franka_gazebo::Joint::desired_position
double desired_position
The current desired position that is used for the PID controller when the joints control method is "P...
Definition: joint.h:62
franka_gazebo::Joint::axis
Eigen::Vector3d axis
The axis of rotation/translation of this joint in local coordinates.
Definition: joint.h:52
franka_gazebo::POSITION
@ POSITION
Definition: joint.h:17
franka_gazebo::Joint::name
std::string name
Name of this joint. Should be unique in whole simulation.
Definition: joint.h:38
franka_gazebo::Joint::lastVelocity
double lastVelocity
Definition: joint.h:171
franka_gazebo::Joint::getDesiredTorque
double getDesiredTorque(const franka::RobotMode &mode) const
Decide what the desired torque of this joint is:
Definition: joint.cpp:86
franka_gazebo::Joint::Joint
Joint()=default
franka_gazebo::Joint::handle
gazebo::physics::JointPtr handle
A pointer to the underlying gazebo handle. Must be non-null for update to work.
Definition: joint.h:41
franka_gazebo::Joint::velocity
double velocity
The current velocity of this joint either in or .
Definition: joint.h:80
franka_gazebo::Joint::getLinkMass
double getLinkMass() const
Get the total link mass of this joint's child.
Definition: joint.cpp:96
franka_gazebo::Joint::type
int type
The type of joint, i.e.
Definition: joint.h:45
franka_gazebo::VELOCITY
@ VELOCITY
Definition: joint.h:17
control_toolbox::Pid
franka_gazebo::ControlMethod
ControlMethod
Specifies the current control method of the joint.
Definition: joint.h:17
pid.h
franka_gazebo::Joint
A data container holding all relevant information about a robotic joint.
Definition: joint.h:25
franka_gazebo::Joint::lastAcceleration
double lastAcceleration
Definition: joint.h:172
franka_gazebo::Joint::collision_threshold
double collision_threshold
Above which threshold forces or torques will be interpreted as "collisions" by isInCollision.
Definition: joint.h:98
franka_gazebo::Joint::getDesiredAcceleration
double getDesiredAcceleration(const franka::RobotMode &mode) const
Decide what the desired acceleration of this joint is based on:
Definition: joint.cpp:76
franka_gazebo::Joint::position_controller
control_toolbox::Pid position_controller
The PID gains used for the controller, when in "position" control mode.
Definition: joint.h:164
franka_gazebo::Joint::update
void update(const ros::Duration &dt)
Calculate all members such as accelerations, jerks velocities by differentiation.
Definition: joint.cpp:7
franka_gazebo::Joint::effort
double effort
The current total force or torque acting on this joint in either or .
Definition: joint.h:83
ros::Duration
angles.h


franka_gazebo
Author(s): Franka Emika GmbH
autogenerated on Mon Sep 19 2022 02:33:28