Skip to content

Commit 1f41ebf

Browse files
committed
ADD: position and current scaling to application layer
1 parent 332af88 commit 1f41ebf

File tree

2 files changed

+26
-28
lines changed

2 files changed

+26
-28
lines changed

robotiq_hande_driver/include/application.hpp

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,6 @@ class ApplicationLayer{
8484
*/
8585
void Close();
8686

87-
/**
88-
* @brief Updates gripper status
89-
*
90-
* @param none
91-
* @return none
92-
* @note see status on success, exception thrown if communicatoin issues
93-
*/
94-
void UpdateStatus();
95-
9687
/**
9788
* @brief Returns the gripper status
9889
*
@@ -118,34 +109,34 @@ class ApplicationLayer{
118109
* @return Gripper requested position
119110
* @note see status on success, exception thrown if communicatoin issues
120111
*/
121-
uint8_t RequestedPosition();
112+
double RequestedPosition();
122113

123114
/**
124115
* @brief Returns the gripper position
125116
*
126117
* @param none
127-
* @return Gripper position in
118+
* @return Gripper position in [m]
128119
* @note see status on success, exception thrown if communicatoin issues
129120
*/
130-
uint8_t Position();
121+
double Position();
131122

132123
/**
133124
* @brief Moves the gripper to requested position
134125
*
135-
* @param position to which the gripper has to move
126+
* @param position to which the gripper has to move, in [m]
136127
* @return none
137128
* @note see status on success, exception thrown if communicatoin issues
138129
*/
139-
void SetPosition(uint8_t position);
130+
void SetPosition(double position);
140131

141132
/**
142133
* @brief Returns the gripper current
143134
*
144135
* @param none
145-
* @return Gripper current in mA (range: 0-2550mA)
136+
* @return Gripper current in [A] (range: 0-2.55A)
146137
* @note see status on success, exception thrown if communicatoin issues
147138
*/
148-
uint16_t Current();
139+
double Current();
149140

150141

151142
void Read();
@@ -171,17 +162,17 @@ class ApplicationLayer{
171162
/**
172163
* Requested position of the gripper, in [m]
173164
*/
174-
uint8_t requested_position_;
165+
double requested_position_;
175166

176167
/**
177168
* POsition of the gripper, in [m]
178169
*/
179-
uint8_t position_;
170+
double position_;
180171

181172
/**
182-
* Current flowin through the gripper, in [mA]
173+
* Current flowin through the gripper, in [A]
183174
*/
184-
uint16_t current_;
175+
double current_;
185176

186177
};
187178
} // namespace hande_driver

robotiq_hande_driver/src/application.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55

66
namespace hande_driver {
77

8+
constexpr auto kGripperPositionMin = 0.0;
9+
constexpr auto kGripperPositionMax = 0.05;
10+
constexpr auto kGripperPositionStep = (kGripperPositionMax - kGripperPositionMin) / 255.0;
11+
constexpr auto kGripperCurrentScale = 0.01;
12+
813
ApplicationLayer::ApplicationLayer()
914
: requested_position_(0)
1015
, position_(0)
@@ -53,19 +58,21 @@ ApplicationLayer::FaultStatus ApplicationLayer::GetFaultStatus(){
5358
return fault_status_;
5459
}
5560

56-
uint8_t ApplicationLayer::RequestedPosition(){
61+
double ApplicationLayer::RequestedPosition(){
5762
return requested_position_;
5863
}
5964

60-
uint8_t ApplicationLayer::Position(){
65+
double ApplicationLayer::Position(){
6166
return position_;
6267
}
6368

64-
void ApplicationLayer::SetPosition(uint8_t position){
65-
protocol_logic_.GoTo(position, 255, 255);
69+
void ApplicationLayer::SetPosition(double position){
70+
uint8_t raw_position = uint8_t(position / kGripperPositionStep - kGripperPositionMin);
71+
72+
protocol_logic_.GoTo(raw_position, 255, 255);
6673
}
6774

68-
uint16_t ApplicationLayer::Current(){
75+
double ApplicationLayer::Current(){
6976
return current_;
7077
}
7178

@@ -82,9 +89,9 @@ void ApplicationLayer::Read(){
8289

8390
//fault_status
8491

85-
requested_position_ = protocol_logic_.GetRegPos();//TODO: add scaling
86-
position_ = protocol_logic_.GetPos(); //TODO: add scaling
87-
current_ = (uint16_t)protocol_logic_.GetCurrent() * 10;
92+
requested_position_ = (double)protocol_logic_.GetRegPos() * kGripperPositionStep + kGripperPositionMin;
93+
position_ = (double)protocol_logic_.GetPos() * kGripperPositionStep + kGripperPositionMin;
94+
current_ = (double)protocol_logic_.GetCurrent() * kGripperCurrentScale;
8895
}
8996

9097
void ApplicationLayer::Write(){

0 commit comments

Comments
 (0)