1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| def makeFieldMarker(self): init_marker = InteractiveMarker() init_marker.header.frame_id = "base_link" init_marker.name = "field"
control = InteractiveMarkerControl() control.always_visible = True for i in range(4): wrap_marker = WrapMarker() wrap_marker.set_type(Marker.CUBE) wrap_marker.set_color() if i<2: wrap_marker.set_scale(FIELD_WIDTH + 6.0 * BORDER_SIZE, BORDER_SIZE, BORDER_SIZE) y = FIELD_HEIGHT * 0.5 + BORDER_SIZE if i == 0 else -(FIELD_HEIGHT * 0.5 + BORDER_SIZE) wrap_marker.set_position(y=y) else: wrap_marker.set_scale(BORDER_SIZE, FIELD_HEIGHT + 3.0 * BORDER_SIZE, BORDER_SIZE) x = FIELD_WIDTH*0.5 + 2.5 * BORDER_SIZE if i==2 else -(FIELD_WIDTH*0.5 + 2.5 * BORDER_SIZE) wrap_marker.set_position(x=x)
control.markers.append(wrap_marker.get_marker()) init_marker.controls.append(control) self.server_.insert(init_marker)
def makeBallMarker(self): int_marker = InteractiveMarker() int_marker.header.frame_id = "base_link" int_marker.name = 'ball' control = InteractiveMarkerControl() control.always_visible = True control.interaction_mode = InteractiveMarkerControl.NONE control.orientation.w = 1 control.orientation.y = 1
wrap_marker = WrapMarker() wrap_marker.set_color() wrap_marker.set_type(Marker.CYLINDER) wrap_marker.set_scale(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE)
control.markers.append(wrap_marker.get_marker()) int_marker.controls.append(control) self.server_.insert(int_marker)
def makePaddleMarkers(self): def create_int_marker(name, visible=False, control_mode=0, PPX=PLAYER_X, r=0.0, g=1.0, b=1.0, a=1.0, sx=0., sy=0., sz=0., px=0, py=0, pz=0): int_marker = InteractiveMarker() int_marker.header.frame_id = "base_link" int_marker.name = name control = InteractiveMarkerControl() control.always_visible = visible control.interaction_mode = control_mode control.orientation.w = 1 control.orientation.z = 1
wrap_marker = WrapMarker() wrap_marker.set_type(Marker.CUBE) wrap_marker.set_color(r=r, g=g, b=b, a=a) wrap_marker.set_scale(sx, sy, sz) wrap_marker.set_position(x=px, y=py, z=pz) control.markers.append(wrap_marker.get_marker()) int_marker.controls.append(control) int_marker.pose.position.x = PPX return int_marker
paddle0_marker = create_int_marker("paddle0", visible=False, control_mode=InteractiveMarkerControl.MOVE_AXIS, r=1., g=1, b=1, a=0, sx=BORDER_SIZE+0.1, sy=PADDLE_SIZE+0.1, sz=BORDER_SIZE+0.1, PPX=-PLAYER_X, px=0, py=0, pz=0) self.server_.insert(paddle0_marker, self.processPaddleFeedback)
paddle1_marker = create_int_marker("paddle1", visible=False, control_mode=InteractiveMarkerControl.MOVE_AXIS, r=1., g=1, b=1, a=0, PPX=PLAYER_X, px=0, py=0, pz=0, sx = BORDER_SIZE+0.1, sy=PADDLE_SIZE+0.1, sz=BORDER_SIZE+0.1) self.server_.insert(paddle1_marker, self.processPaddleFeedback)
paddle0_marker_disp = create_int_marker("paddle0_display", visible=True, control_mode=InteractiveMarkerControl.NONE, r=0.5, g=1, b=0.5, a=1, PPX=-PLAYER_X, px=0, py=0, pz=0, sx = BORDER_SIZE, sy=PADDLE_SIZE, sz=BORDER_SIZE) self.server_.insert(paddle0_marker_disp)
paddle1_marker_disp = create_int_marker("paddle1_display", visible=True, control_mode=InteractiveMarkerControl.NONE, r=0.5, g=0.5, b=1.0, a=1, PPX=PLAYER_X, px=0, py=0, pz=0, sx = BORDER_SIZE, sy=PADDLE_SIZE, sz=BORDER_SIZE) self.server_.insert(paddle1_marker_disp)
|