@@ -41,20 +41,20 @@ def __init__(self, person_number):
41
41
42
42
def set_speed (self , data ):
43
43
########## In case the receibed speed is in the person frame ##########
44
- if time .time () - self .last_time_sent_velocity > self .time_between_velocity_commands :
45
- self .last_time_sent_velocity = time .time ()
46
- person_orientation = self .person_node .getOrientation ()
47
- orientation = math .atan2 (person_orientation [0 ], person_orientation [1 ]) - math .pi / 2
48
- rotation_matrix = np .array (
49
- [[math .cos (orientation ), - math .sin (orientation )], [math .sin (orientation ), math .cos (orientation )]])
50
- lin_speed = np .array ([data .axes [1 ].value * 2 , 0 ])
51
- # if data.axes[1] > 0.1 or data.axes[1] < -0.1:
52
- # self.moving = True
53
- # else:
54
- # self.moving = False
55
- converted_speed = np .matmul (rotation_matrix , lin_speed )
56
- self .person_node .setVelocity (
57
- [converted_speed [0 ] / 2.5 , converted_speed [1 ] / 2.5 , 0 , 0 , 0 , - data .axes [0 ].value * math .pi / 2 ])
44
+ # if time.time() - self.last_time_sent_velocity > self.time_between_velocity_commands:
45
+ # self.last_time_sent_velocity = time.time()
46
+ person_orientation = self .person_node .getOrientation ()
47
+ orientation = math .atan2 (person_orientation [0 ], person_orientation [1 ]) - math .pi / 2
48
+ rotation_matrix = np .array (
49
+ [[math .cos (orientation ), - math .sin (orientation )], [math .sin (orientation ), math .cos (orientation )]])
50
+ lin_speed = np .array ([data .axes [1 ].value * 2 , 0 ])
51
+ # if data.axes[1] > 0.1 or data.axes[1] < -0.1:
52
+ # self.moving = True
53
+ # else:
54
+ # self.moving = False
55
+ converted_speed = np .matmul (rotation_matrix , lin_speed )
56
+ self .person_node .setVelocity (
57
+ [converted_speed [0 ] / 2.5 , converted_speed [1 ] / 2.5 , 0 , 0 , 0 , - data .axes [0 ].value * math .pi / 2 ])
58
58
59
59
def set_initial_pose (self , data ):
60
60
if data .buttons [3 ]:
@@ -65,6 +65,6 @@ def get_camera_image(self):
65
65
color = self .person_camera .getImage ()
66
66
color_image = cv2 .cvtColor (cv2 .cvtColor (
67
67
np .frombuffer (color , np .uint8 ).reshape (self .person_camera .getHeight (), self .person_camera .getWidth (), 4 ),
68
- cv2 .COLOR_RGBA2RGB ), cv2 .COLOR_BGR2RGB )
68
+ cv2 .COLOR_BGR2RGB ), cv2 .COLOR_BGR2RGB )
69
69
cv2 .imshow ("color" , color_image )
70
70
cv2 .waitKey (1 )
0 commit comments