Skip to content

Commit bcdc1c1

Browse files
committed
building new primitive for object corner pivoting
1 parent 5d1a575 commit bcdc1c1

File tree

4 files changed

+87
-12
lines changed

4 files changed

+87
-12
lines changed

msg/ControlCommand.msg

+6
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@ float32 delta_theta
77
float32 delta_s_pivot
88
float32 delta_s_hand
99

10+
float32 delta_theta_relative
11+
float32 delta_theta_object
12+
1013
# absolute commands
1114
float32 theta
1215
float32 s_pivot
1316
float32 s_hand
1417

18+
float32 theta_relative
19+
float32 theta_object
20+
1521
#jog commands
1622
float32 delta_x
1723
float32 delta_y

src/ControlandExecution/interactive_command_module.py

+67-12
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
'delta_s_hand' : 0.0,
4242
}
4343

44+
4445
delta_rotate_corner_left = {
4546
'name': 'delta_rotate_left',
4647
'command_flag' : 1,
@@ -305,6 +306,43 @@
305306
'delta_tangential': 0.0,
306307
}
307308

309+
delta_rotate_hand_left_object_corner = {
310+
'name': 'delta_rotate_hand_left_object_corner',
311+
'command_flag' : 4,
312+
'mode' : -1,
313+
'delta_theta' : np.pi/50, #np.pi/12,
314+
'delta_s_pivot' : 0.0,
315+
'delta_s_hand' : 0.0,
316+
}
317+
318+
delta_rotate_hand_right_object_corner = {
319+
'name': 'delta_rotate_hand_right_object_corner',
320+
'command_flag' : 4,
321+
'mode' : -1,
322+
'delta_theta' : -np.pi/50, #-np.pi/12,
323+
'delta_s_pivot' : 0.0,
324+
'delta_s_hand' : 0.0,
325+
}
326+
327+
delta_rotate_object_left_object_corner = {
328+
'name': 'delta_rotate_object_left_object_corner',
329+
'command_flag' : 4,
330+
'mode' : 0,
331+
'delta_theta' : np.pi/50, #np.pi/12,
332+
'delta_s_pivot' : 0.0,
333+
'delta_s_hand' : 0.0,
334+
}
335+
336+
delta_rotate_object_right_object_corner = {
337+
'name': 'delta_rotate_object_right_object_corner',
338+
'command_flag' : 4,
339+
'mode' : 0,
340+
'delta_theta' : -np.pi/50, #-np.pi/12,
341+
'delta_s_pivot' : 0.0,
342+
'delta_s_hand' : 0.0,
343+
}
344+
345+
308346

309347
def on_release(key):
310348
# try:
@@ -322,18 +360,18 @@ def on_press(key):
322360

323361
global shift_on
324362
global ctrl_on
325-
global alt_on
363+
global tab_on
326364

327365
command_msg_dict = None
328366

329-
not_a_modifier_key = key!=keyboard.Key.shift and key!=keyboard.Key.ctrl and key!=keyboard.Key.alt
367+
not_a_modifier_key = key!=keyboard.Key.shift and key!=keyboard.Key.ctrl and key!=keyboard.Key.tab
330368
# shift_on = keyboard.Key.shift in keys_held_down
331369
# ctrl_on = keyboard.Key.ctrl in keys_held_down
332-
# alt_on = keyboard.Key.alt in keys_held_down
370+
# tab_on = keyboard.Key.tab in keys_held_down
333371

334372
if key==keyboard.Key.shift:
335373
ctrl_on = False
336-
alt_on = False
374+
tab_on = False
337375

338376
shift_on = not shift_on
339377

@@ -344,7 +382,7 @@ def on_press(key):
344382

345383
if key==keyboard.Key.ctrl:
346384
shift_on = False
347-
alt_on = False
385+
tab_on = False
348386

349387
ctrl_on = not ctrl_on
350388

@@ -353,18 +391,18 @@ def on_press(key):
353391
else:
354392
print('ctrl off')
355393

356-
if key==keyboard.Key.alt:
394+
if key==keyboard.Key.tab:
357395
shift_on = False
358396
ctrl_on = False
359397

360-
alt_on = not alt_on
398+
tab_on = not tab_on
361399

362-
if alt_on:
363-
print('alt on')
400+
if tab_on:
401+
print('tab on')
364402
else:
365-
print('alt off')
403+
print('tab off')
366404

367-
modifier_state = shift_on + 2*ctrl_on + 4*alt_on
405+
modifier_state = shift_on + 2*ctrl_on + 4*tab_on
368406

369407
# if not_a_modifier_key:
370408
# print('modifier_state: ',modifier_state)
@@ -490,6 +528,23 @@ def on_press(key):
490528
command_msg_dict = jog_move_right
491529
print('jog_move_right')
492530

531+
if modifier_state==4:
532+
if k == 'left':
533+
command_msg_dict = delta_rotate_hand_left_object_corner
534+
print('delta_rotate_hand_left_object_corner')
535+
536+
if k == 'right':
537+
command_msg_dict = delta_rotate_hand_right_object_corner
538+
print('delta_rotate_hand_right_object_corner')
539+
540+
if k == 'a':
541+
command_msg_dict = delta_rotate_object_left_object_corner
542+
print('delta_rotate_object_left_object_corner')
543+
544+
if k == 'd':
545+
command_msg_dict = delta_rotate_object_right_object_corner
546+
print('delta_rotate_object_right_object_corner')
547+
493548
if command_msg_dict is not None:
494549
rm.pub_barrier_func_control_command(command_msg_dict)
495550

@@ -533,7 +588,7 @@ def on_press(key):
533588

534589
shift_on = False
535590
ctrl_on = False
536-
alt_on = False
591+
tab_on = False
537592

538593
rm = ros_manager()
539594
rospy.init_node('barrier_func_commands')

src/Helpers/pbal_msg_helper.py

+6
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,17 @@ def command_stamped_to_command_dict(command_msg):
332332
command_dict['delta_s_pivot'] = command_msg.control_command.delta_s_pivot
333333
command_dict['delta_s_hand'] = command_msg.control_command.delta_s_hand
334334

335+
command_dict['delta_theta_relative'] = command_msg.control_command.delta_theta_relative
336+
command_dict['delta_theta_object'] = command_msg.control_command.delta_theta_object
337+
335338
# absolute commands
336339
command_dict['theta'] = command_msg.control_command.theta
337340
command_dict['s_pivot'] = command_msg.control_command.s_pivot
338341
command_dict['s_hand'] = command_msg.control_command.s_hand
339342

343+
command_dict['theta_relative'] = command_msg.control_command.theta_relative
344+
command_dict['theta_object'] = command_msg.control_command.theta_object
345+
340346
#additional commands for jogging
341347
command_dict['delta_x'] = command_msg.control_command.delta_x
342348
command_dict['delta_y'] = command_msg.control_command.delta_y

src/Modelling/modular_barrier_controller.py

+8
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ def torque_right_contact_constraint(self):
624624
lc = self.l_contact * self.pivot_params['l_contact_multiplier']
625625
if self.torque_bounds is not None:
626626
aiq = np.array([self.torque_bounds[0], 0., 1.])
627+
print(aiq)
627628
else:
628629
aiq = np.array([-lc / 2., 0., 1.])
629630
biq = -self.pivot_params['torque_margin']
@@ -634,6 +635,7 @@ def torque_left_contact_constraint(self):
634635
lc = self.l_contact * self.pivot_params['l_contact_multiplier']
635636
if self.torque_bounds is not None:
636637
aiq = np.array([-self.torque_bounds[1], 0., -1.])
638+
print(aiq)
637639
else:
638640
aiq = np.array([-lc / 2., 0., -1.])
639641
biq = -self.pivot_params['torque_margin']
@@ -668,6 +670,12 @@ def normal_force_min_external_constraint(self):
668670
biq = 0.
669671
return aiq, biq, self.pivot_params['tr_min_normal_external'], ['nemn']
670672

673+
# def radial_force_bounded_external_constraint(self):
674+
675+
# radial_vector = robot_contact_wm - external_contact_wm
676+
677+
678+
671679
def friction_right_external_constraint(self):
672680
''' right (i.e., positive) boundary of friction cone '''
673681
measured_friction_available = False

0 commit comments

Comments
 (0)