Sheep training flock _ improver
This commit is contained in:
@@ -133,6 +133,19 @@ while robot.step(timestep) != -1:
|
||||
|
||||
fx, fy = 0.0, 0.0
|
||||
|
||||
# Outside the pen: repel from the exterior of the side and back walls so
|
||||
# sheep don't get pinned against them when fleeing from the dog.
|
||||
# The pen entrance is open on the north (y > PEN_Y_MAX), so only push away
|
||||
# from the west (x≈PEN_X_MIN), east (x≈PEN_X_MAX), and south (y≈PEN_Y_MIN) exteriors.
|
||||
PEN_EXT_MARGIN = 1.2
|
||||
if not penned:
|
||||
if PEN_Y_MIN - PEN_EXT_MARGIN < y < PEN_Y_MAX and x < PEN_X_MIN + PEN_EXT_MARGIN:
|
||||
fx -= ((PEN_X_MIN + PEN_EXT_MARGIN - x) / PEN_EXT_MARGIN) * 8.0
|
||||
if PEN_Y_MIN - PEN_EXT_MARGIN < y < PEN_Y_MAX and x > PEN_X_MAX - PEN_EXT_MARGIN:
|
||||
fx += ((x - (PEN_X_MAX - PEN_EXT_MARGIN)) / PEN_EXT_MARGIN) * 8.0
|
||||
if y < PEN_Y_MIN + PEN_EXT_MARGIN and PEN_X_MIN < x < PEN_X_MAX:
|
||||
fy += ((PEN_Y_MIN + PEN_EXT_MARGIN - y) / PEN_EXT_MARGIN) * 8.0
|
||||
|
||||
if penned:
|
||||
# Inside pen: wander freely, strong boundary forces prevent exit,
|
||||
# separation still active to avoid collisions with other penned sheep.
|
||||
|
||||
Reference in New Issue
Block a user