Skip to content

Commit 0dedeca

Browse files
show requested speed and force, and position and current of all motors
1 parent a57c6b6 commit 0dedeca

File tree

2 files changed

+297
-5
lines changed

2 files changed

+297
-5
lines changed

robotiq_3f_rviz/src/panel.ui

Lines changed: 274 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>400</width>
10-
<height>300</height>
10+
<height>368</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -138,14 +138,53 @@
138138
</widget>
139139
</item>
140140
<item>
141-
<layout class="QFormLayout" name="group_sliders">
141+
<layout class="QGridLayout" name="group_sliders">
142142
<item row="0" column="0">
143143
<widget class="QLabel" name="label_force">
144144
<property name="text">
145145
<string>Force</string>
146146
</property>
147147
</widget>
148148
</item>
149+
<item row="0" column="3">
150+
<widget class="QLabel" name="force_unit">
151+
<property name="text">
152+
<string>N</string>
153+
</property>
154+
</widget>
155+
</item>
156+
<item row="1" column="0">
157+
<widget class="QLabel" name="label_speed">
158+
<property name="text">
159+
<string>Speed</string>
160+
</property>
161+
</widget>
162+
</item>
163+
<item row="0" column="2">
164+
<widget class="QLabel" name="force_value">
165+
<property name="minimumSize">
166+
<size>
167+
<width>40</width>
168+
<height>0</height>
169+
</size>
170+
</property>
171+
<property name="maximumSize">
172+
<size>
173+
<width>40</width>
174+
<height>16777215</height>
175+
</size>
176+
</property>
177+
<property name="frameShape">
178+
<enum>QFrame::Box</enum>
179+
</property>
180+
<property name="text">
181+
<string>--</string>
182+
</property>
183+
<property name="alignment">
184+
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
185+
</property>
186+
</widget>
187+
</item>
149188
<item row="0" column="1">
150189
<widget class="QSlider" name="slider_force">
151190
<property name="maximum">
@@ -166,15 +205,245 @@
166205
</property>
167206
</widget>
168207
</item>
169-
<item row="1" column="0">
170-
<widget class="QLabel" name="label_speed">
208+
<item row="1" column="2">
209+
<widget class="QLabel" name="speed_value">
210+
<property name="minimumSize">
211+
<size>
212+
<width>40</width>
213+
<height>0</height>
214+
</size>
215+
</property>
216+
<property name="maximumSize">
217+
<size>
218+
<width>40</width>
219+
<height>16777215</height>
220+
</size>
221+
</property>
222+
<property name="frameShape">
223+
<enum>QFrame::Box</enum>
224+
</property>
171225
<property name="text">
172-
<string>Speed</string>
226+
<string>--</string>
227+
</property>
228+
<property name="alignment">
229+
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
230+
</property>
231+
</widget>
232+
</item>
233+
<item row="1" column="3">
234+
<widget class="QLabel" name="speed_unit">
235+
<property name="text">
236+
<string>mm/s</string>
173237
</property>
174238
</widget>
175239
</item>
176240
</layout>
177241
</item>
242+
<item>
243+
<widget class="QFrame" name="group_status">
244+
<property name="frameShape">
245+
<enum>QFrame::Panel</enum>
246+
</property>
247+
<property name="frameShadow">
248+
<enum>QFrame::Plain</enum>
249+
</property>
250+
<layout class="QGridLayout" name="layout_status">
251+
<item row="2" column="1">
252+
<widget class="QLabel" name="pos_a">
253+
<property name="frameShape">
254+
<enum>QFrame::StyledPanel</enum>
255+
</property>
256+
<property name="text">
257+
<string>--</string>
258+
</property>
259+
<property name="alignment">
260+
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
261+
</property>
262+
</widget>
263+
</item>
264+
<item row="1" column="2">
265+
<widget class="Line" name="line_b">
266+
<property name="orientation">
267+
<enum>Qt::Horizontal</enum>
268+
</property>
269+
</widget>
270+
</item>
271+
<item row="3" column="1">
272+
<widget class="QLabel" name="cur_a">
273+
<property name="frameShape">
274+
<enum>QFrame::StyledPanel</enum>
275+
</property>
276+
<property name="text">
277+
<string>--</string>
278+
</property>
279+
<property name="alignment">
280+
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
281+
</property>
282+
</widget>
283+
</item>
284+
<item row="2" column="3">
285+
<widget class="QLabel" name="pos_c">
286+
<property name="frameShape">
287+
<enum>QFrame::StyledPanel</enum>
288+
</property>
289+
<property name="text">
290+
<string>--</string>
291+
</property>
292+
<property name="alignment">
293+
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
294+
</property>
295+
</widget>
296+
</item>
297+
<item row="2" column="0">
298+
<widget class="QLabel" name="label_status_pos">
299+
<property name="text">
300+
<string>Position</string>
301+
</property>
302+
</widget>
303+
</item>
304+
<item row="1" column="3">
305+
<widget class="Line" name="line_c">
306+
<property name="orientation">
307+
<enum>Qt::Horizontal</enum>
308+
</property>
309+
</widget>
310+
</item>
311+
<item row="1" column="1">
312+
<widget class="Line" name="line_a">
313+
<property name="orientation">
314+
<enum>Qt::Horizontal</enum>
315+
</property>
316+
</widget>
317+
</item>
318+
<item row="3" column="0">
319+
<widget class="QLabel" name="label_status_cur">
320+
<property name="text">
321+
<string>Current (mA)</string>
322+
</property>
323+
</widget>
324+
</item>
325+
<item row="0" column="0">
326+
<widget class="QLabel" name="label">
327+
<property name="text">
328+
<string>Finger</string>
329+
</property>
330+
</widget>
331+
</item>
332+
<item row="2" column="2">
333+
<widget class="QLabel" name="pos_b">
334+
<property name="frameShape">
335+
<enum>QFrame::StyledPanel</enum>
336+
</property>
337+
<property name="text">
338+
<string>--</string>
339+
</property>
340+
<property name="alignment">
341+
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
342+
</property>
343+
</widget>
344+
</item>
345+
<item row="0" column="2">
346+
<widget class="QLabel" name="label_fb">
347+
<property name="text">
348+
<string>B</string>
349+
</property>
350+
<property name="alignment">
351+
<set>Qt::AlignCenter</set>
352+
</property>
353+
</widget>
354+
</item>
355+
<item row="3" column="2">
356+
<widget class="QLabel" name="cur_b">
357+
<property name="frameShape">
358+
<enum>QFrame::StyledPanel</enum>
359+
</property>
360+
<property name="text">
361+
<string>--</string>
362+
</property>
363+
<property name="alignment">
364+
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
365+
</property>
366+
</widget>
367+
</item>
368+
<item row="0" column="3">
369+
<widget class="QLabel" name="label_fc">
370+
<property name="text">
371+
<string>C</string>
372+
</property>
373+
<property name="alignment">
374+
<set>Qt::AlignCenter</set>
375+
</property>
376+
</widget>
377+
</item>
378+
<item row="0" column="1">
379+
<widget class="QLabel" name="label_fa">
380+
<property name="text">
381+
<string>A</string>
382+
</property>
383+
<property name="alignment">
384+
<set>Qt::AlignCenter</set>
385+
</property>
386+
</widget>
387+
</item>
388+
<item row="3" column="3">
389+
<widget class="QLabel" name="cur_c">
390+
<property name="frameShape">
391+
<enum>QFrame::StyledPanel</enum>
392+
</property>
393+
<property name="text">
394+
<string>--</string>
395+
</property>
396+
<property name="alignment">
397+
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
398+
</property>
399+
</widget>
400+
</item>
401+
<item row="0" column="4">
402+
<widget class="QLabel" name="label_s">
403+
<property name="text">
404+
<string>S</string>
405+
</property>
406+
<property name="alignment">
407+
<set>Qt::AlignCenter</set>
408+
</property>
409+
</widget>
410+
</item>
411+
<item row="2" column="4">
412+
<widget class="QLabel" name="pos_s">
413+
<property name="frameShape">
414+
<enum>QFrame::StyledPanel</enum>
415+
</property>
416+
<property name="text">
417+
<string>--</string>
418+
</property>
419+
<property name="alignment">
420+
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
421+
</property>
422+
</widget>
423+
</item>
424+
<item row="3" column="4">
425+
<widget class="QLabel" name="cur_s">
426+
<property name="frameShape">
427+
<enum>QFrame::StyledPanel</enum>
428+
</property>
429+
<property name="text">
430+
<string>--</string>
431+
</property>
432+
<property name="alignment">
433+
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
434+
</property>
435+
</widget>
436+
</item>
437+
<item row="1" column="4">
438+
<widget class="Line" name="line_s">
439+
<property name="orientation">
440+
<enum>Qt::Horizontal</enum>
441+
</property>
442+
</widget>
443+
</item>
444+
</layout>
445+
</widget>
446+
</item>
178447
</layout>
179448
</widget>
180449
<resources/>

robotiq_3f_rviz/src/robotiq_3f_rviz.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,21 @@ void Robotiq3FingerPanel::on_slider_position_valueChanged(const int value) {
110110
void Robotiq3FingerPanel::on_slider_force_valueChanged(const int value) {
111111
command.rFRA = uint8_t(value);
112112
auto_send_check();
113+
114+
// force: 15 + value * 0.175 N (max: 60 N)
115+
static constexpr double min_force = 15;
116+
static constexpr double delta_force = 0.175;
117+
ui.force_value->setNum(int(min_force+value*delta_force));
113118
}
114119

115120
void Robotiq3FingerPanel::on_slider_speed_valueChanged(const int value) {
116121
command.rSPA = uint8_t(value);
117122
auto_send_check();
123+
124+
// speed: 22 + value * 0.34 mm/s (max: 110 mm/s)
125+
static constexpr double min_speed = 22;
126+
static constexpr double delta_speed = 0.34;
127+
ui.speed_value->setNum(int(min_speed+value*delta_speed));
118128
}
119129

120130
void Robotiq3FingerPanel::on_check_send_clicked(const bool checked) {
@@ -145,6 +155,19 @@ void Robotiq3FingerPanel::on_status(const RQ3Fin &status) {
145155
set_button_active(ui.button_pinch, status.gMOD==1);
146156
set_button_active(ui.button_wide, status.gMOD==2);
147157
set_button_active(ui.button_scissor, status.gMOD==3);
158+
159+
// individual finger position
160+
ui.pos_a->setNum(status.gPOA);
161+
ui.pos_b->setNum(status.gPOB);
162+
ui.pos_c->setNum(status.gPOC);
163+
ui.pos_s->setNum(status.gPOS);
164+
165+
// individual finger current
166+
// current: 0.1 * value mA
167+
ui.cur_a->setNum(0.1*status.gCUA);
168+
ui.cur_b->setNum(0.1*status.gCUB);
169+
ui.cur_c->setNum(0.1*status.gCUC);
170+
ui.cur_s->setNum(0.1*status.gCUS);
148171
}
149172

150173
void Robotiq3FingerPanel::set_button_active(QPushButton *button, const bool active) {

0 commit comments

Comments
 (0)