Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed touch detection #27

Merged
merged 5 commits into from
Aug 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions controllers/supervisor/supervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,11 @@ def reset_robot(self, team, id, x, y, z, th):
robot.resetPhysics()
self.robot[team][id]['active'] = True
self.robot[team][id]['touch'] = False
self.robot[team][id]['fall_time'] = 0
self.robot[team][id]['fall_time'] = self.time
self.robot[team][id]['sentout_time'] = 0
self.deadlock_time = self.getTime()
self.set_speeds(team, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
self.robot[team][id]['niopa_time'] = self.time # not_in_opponent_penalty_area time
self.robot[team][id]['ipa_time'] = self.time # goalkeeper in_penalty_area time
self.stop_robots()

def reset(self, red_formation, blue_formation):
# reset the ball
Expand Down Expand Up @@ -358,15 +359,8 @@ def reset(self, red_formation, blue_formation):
constants.ROBOT_FORMATION[formation][id][1] * s,
constants.ROBOT_FORMATION[formation][id][2] + a - constants.PI / 2)

# reset touch
# reset recent touch
self.recent_touch = [[False] * constants.NUMBER_OF_ROBOTS, [False] * constants.NUMBER_OF_ROBOTS]
# reset activeness, fall time and sentout time
for t in constants.TEAMS:
for id in range(constants.NUMBER_OF_ROBOTS):
self.robot[t][id]['active'] = True
self.robot[t][id]['fall_time'] = self.time
self.robot[t][id]['sentout_time'] = 0
self.stop_robots()
self.deadlock_time = self.time
# flush touch packet
self.flush_touch_ball()
Expand Down Expand Up @@ -455,7 +449,7 @@ def get_robot_touch_ball(self):
message = self.receiver.getData()
for team in constants.TEAMS:
for id in range(constants.NUMBER_OF_ROBOTS):
if message[2 * id + team] == '1':
if message[2 * id + team] == 1:
rc[team][id] = True
self.receiver.nextPacket()
return rc
Expand Down Expand Up @@ -996,13 +990,13 @@ def run(self):
self.publish_current_frame()
self.reset_reason = Game.NONE

# if any of the robots has touched the ball at this frame, update self.recent_touch
# update touch statuses of robots
touch = self.get_robot_touch_ball()
for team in constants.TEAMS:
for id in range(constants.NUMBER_OF_ROBOTS):
if touch[team][id]:
self.robot[team][id]['touch'] = touch[team][id]
if touch[team][id]: # if any of the robots has touched the ball at this frame, update touch status
self.recent_touch = touch
break

# check if any of robots has fallen
for team in constants.TEAMS:
Expand Down