libfranka 0.18.0
FCI C++ API
Loading...
Searching...
No Matches
joint_velocity_limits.h
Go to the documentation of this file.
1// Copyright (c) 2025 Franka Robotics GmbH
2// Use of this source code is governed by the Apache-2.0 license, see LICENSE
3#pragma once
4
5#include <array>
6#include <string>
7
13namespace franka {
14
20 double max_velocity;
21 double velocity_offset;
22 double deceleration_limit;
23 double upper_position_limit;
24 double lower_position_limit;
25
27 : max_velocity(0),
28 velocity_offset(0),
29 deceleration_limit(0),
30 upper_position_limit(0),
31 lower_position_limit(0) {}
32
42 double velocity_offset,
43 double deceleration_limit,
44 double upper_position_limit,
45 double lower_position_limit)
46 : max_velocity(max_velocity),
47 velocity_offset(velocity_offset),
48 deceleration_limit(deceleration_limit),
49 upper_position_limit(upper_position_limit),
50 lower_position_limit(lower_position_limit) {}
51};
52
59 public:
60 // Robot configuration constants
61 static constexpr int kNumJoints = 7;
62
63 JointVelocityLimitsConfig() = default;
64
69 explicit JointVelocityLimitsConfig(const std::string& urdf_string) { parseFromURDF(urdf_string); }
70
76 const PositionBasedJointVelocityLimitConstants& operator[](size_t joint_index) const {
77 return joint_params_[joint_index];
78 }
79
84 const std::array<PositionBasedJointVelocityLimitConstants, kNumJoints>& getJointParams() const {
85 return joint_params_;
86 }
87
93 std::array<double, kNumJoints> getUpperJointVelocityLimits(
94 const std::array<double, kNumJoints>& joint_positions) const;
95
101 std::array<double, kNumJoints> getLowerJointVelocityLimits(
102 const std::array<double, kNumJoints>& joint_positions) const;
103
104 private:
105 // XML element and attribute name constants
106 static constexpr const char* kRobotElementName = "robot";
107 static constexpr const char* kJointElementName = "joint";
108 static constexpr const char* kPositionBasedVelocityLimitsElementName =
109 "position_based_velocity_limits";
110 static constexpr const char* kLimitElementName = "limit";
111 static constexpr const char* kNameAttributeName = "name";
112 static constexpr const char* kVelocityAttributeName = "velocity";
113 static constexpr const char* kUpperAttributeName = "upper";
114 static constexpr const char* kLowerAttributeName = "lower";
115 static constexpr const char* kVelocityOffsetAttributeName = "velocity_offset";
116 static constexpr const char* kDecelerationLimitAttributeName = "deceleration_limit";
117
118 // Joint name pattern constants
119 static constexpr const char* kJoint1Name = "joint1";
120 static constexpr const char* kJoint2Name = "joint2";
121 static constexpr const char* kJoint3Name = "joint3";
122 static constexpr const char* kJoint4Name = "joint4";
123 static constexpr const char* kJoint5Name = "joint5";
124 static constexpr const char* kJoint6Name = "joint6";
125 static constexpr const char* kJoint7Name = "joint7";
126
131 void parseFromURDF(const std::string& urdf_string);
132
138 static int getJointIndex(const std::string& joint_name);
139
140 std::array<PositionBasedJointVelocityLimitConstants, kNumJoints> joint_params_;
141};
142
143} // namespace franka
Configuration class that holds position-based joint velocity limit parameters for all 7 joints.
Definition joint_velocity_limits.h:58
std::array< double, kNumJoints > getLowerJointVelocityLimits(const std::array< double, kNumJoints > &joint_positions) const
Compute lower joint velocity limits based on current joint positions.
JointVelocityLimitsConfig(const std::string &urdf_string)
Constructor that parses URDF string and initializes joint parameters.
Definition joint_velocity_limits.h:69
const PositionBasedJointVelocityLimitConstants & operator[](size_t joint_index) const
Get joint parameters for a specific joint.
Definition joint_velocity_limits.h:76
const std::array< PositionBasedJointVelocityLimitConstants, kNumJoints > & getJointParams() const
Get all joint parameters.
Definition joint_velocity_limits.h:84
std::array< double, kNumJoints > getUpperJointVelocityLimits(const std::array< double, kNumJoints > &joint_positions) const
Compute upper joint velocity limits based on current joint positions.
Structure to hold position-based joint velocity limit constants for a single joint from URDF.
Definition joint_velocity_limits.h:19
PositionBasedJointVelocityLimitConstants(double max_velocity, double velocity_offset, double deceleration_limit, double upper_position_limit, double lower_position_limit)
Constructor with specified parameters.
Definition joint_velocity_limits.h:41