Closed vivekmishra369 closed 7 years ago
hmm haven't encountered that before, but that was over a year ago. A possibility is that whatever object that was called got deleted, hence becoming a None
object, and when calling that <object>.distance
it blows up.
Could you paste the terminal output when it throws the errors here? would help to pin that down
The following error message is thrown right before the player thread dies:
Exception in thread think_loop: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 763, in run self.target(*self.args, **self.kwargs) File "/home/vivek/Desktop/robocup virtual/robocup-soccer-master/aigent/soccerpy/agent.py", line 219, in think_loop self.think() File "/home/vivek/Desktop/robocup virtual/robocup-soccer-master/aigent/agent_2.py", line 88, in think return self.decisionLoop() File "/home/vivek/Desktop/robocup virtual/robocup-soccer-master/aigent/agent_2.py", line 316, in decisionLoop ball_with_enemy = self.wm.is_ball_owned_by_enemy() File "/home/vivek/Desktop/robocup virtual/robocup-soccer-master/aigent/soccerpy/world_model.py", line 660, in is_ball_owned_by_enemy if p.side != self.side and self.euclidean_distance(self.get_object_absolute_coords(self.ball), self.get_object_absolute_coords(p)) < self.server_parameters.kickable_margin: File "/home/vivek/Desktop/robocup virtual/robocup-soccer-master/aigent/soccerpy/world_model.py", line 516, in get_object_absolute_coords if obj.distance is None: AttributeError: 'NoneType' object has no attribute 'distance'
For the time being, I am circumventing this problem by catching this error, I modified the method to the following:
` def is_ball_owned_by_enemy(self):
#Returns if the ball is in possession by the enemy team.
for p in self.players:
# skip enemy and unknwon players
try:
if p.side != self.side and self.euclidean_distance(self.get_object_absolute_coords(self.ball), self.get_object_absolute_coords(p)) < self.server_parameters.kickable_margin:
return True
except Exception as e:
print 'error in ball owned by enemy function : ',e
continue
else:
continue
return False`
Thanks in advance.
ok u could change https://github.com/kengz/robocup-soccer/blob/master/aigent/soccerpy/world_model.py#L514 by replacing with
# we can't calculate this without a distance to the object
if obj is None or obj.distance is None:
return None
Thanks
Hi,
I am using rcssserver-15.3.0. I tried running a sample game using two instances of the main.py file and used the agent_2.py as all my player clients. The clients throw an error " 'NoneType' object has no attribute 'distance' " in a few cases when the self.wm.is_ball_owned_by_enemy() method is invoked from the client methods like shall_move_to_ball(). This kills the client.
I want to know if I am doing something wrong or this is a known problem.