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

Physics simulation causes "time_out" during render_script #94

Open
yuanfei-Wang opened this issue Jul 19, 2023 · 4 comments
Open

Physics simulation causes "time_out" during render_script #94

yuanfei-Wang opened this issue Jul 19, 2023 · 4 comments

Comments

@yuanfei-Wang
Copy link

I am trying the unity_demo.ipynb provided in this repo. Everything is fine until I start to run the physics simulation code.
The render_script of putting an apple on the desk gets stuck and the error appears to be "time_out".
However, if I skip the comm.activate_physics(), then comm.render_script works normally.
The detailed error outputs are listed below. Thanks in advance!

╭─────────────────────────────────────── Traceback (most recent call last) ───────────────────────────────────────╮
│ /home/unison/Miniconda3/envs/virth/lib/python3.8/site-packages/urllib3/connectionpool.py:384 in _make_request │
│ │
│ 381 │ │ │ │ except Exception as e: │
│ 382 │ │ │ │ │ # Remove the TypeError from the exception chain in Python 3; │
│ 383 │ │ │ │ │ # otherwise it looks like a programming error was the cause. │
│ ❱ 384 │ │ │ │ │ six.raise_from(e, None) │
│ 385 │ │ except (SocketTimeout, BaseSSLError, SocketError) as e: │
│ 386 │ │ │ self._raise_timeout(err=e, url=url, timeout_value=read_timeout) │
│ 387 │ │ │ raise │
│ in raise_from:2 │
│ │
│ /home/unison/Miniconda3/envs/virth/lib/python3.8/site-packages/urllib3/connectionpool.py:380 in _make_request │
│ │
│ 377 │ │ │ │ httplib_response = conn.getresponse(buffering=True) │
│ 378 │ │ │ except TypeError: # Python 3 │
│ 379 │ │ │ │ try: │
│ ❱ 380 │ │ │ │ │ httplib_response = conn.getresponse() │
│ 381 │ │ │ │ except Exception as e: │
│ 382 │ │ │ │ │ # Remove the TypeError from the exception chain in Python 3; │
│ 383 │ │ │ │ │ # otherwise it looks like a programming error was the cause. │
│ │
│ /home/unison/Miniconda3/envs/virth/lib/python3.8/http/client.py:1348 in getresponse │
│ │
│ 1345 │ │ │
│ 1346 │ │ try: │
│ 1347 │ │ │ try: │
│ ❱ 1348 │ │ │ │ response.begin() │
│ 1349 │ │ │ except ConnectionError: │
│ 1350 │ │ │ │ self.close() │
│ 1351 │ │ │ │ raise │
│ │
│ /home/unison/Miniconda3/envs/virth/lib/python3.8/http/client.py:316 in begin │
│ │
│ 313 │ │ │
│ 314 │ │ # read until we get a non-100 response │
│ 315 │ │ while True: │
│ ❱ 316 │ │ │ version, status, reason = self._read_status() │
│ 317 │ │ │ if status != CONTINUE: │
│ 318 │ │ │ │ break │
│ 319 │ │ │ # skip the header from the 100 response │
│ │
│ /home/unison/Miniconda3/envs/virth/lib/python3.8/http/client.py:277 in _read_status │
│ │
│ 274 │ │ self.will_close = _UNKNOWN # conn will close at end of response │
│ 275 │ │
│ 276 │ def _read_status(self): │
│ ❱ 277 │ │ line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") │
│ 278 │ │ if len(line) > _MAXLINE: │
│ 279 │ │ │ raise LineTooLong("status line") │
│ 280 │ │ if self.debuglevel > 0: │
│ │
│ /home/unison/Miniconda3/envs/virth/lib/python3.8/socket.py:669 in readinto │
│ │
│ 666 │ │ │ raise OSError("cannot read from timed out object") │
│ 667 │ │ while True: │
│ 668 │ │ │ try: │
│ ❱ 669 │ │ │ │ return self._sock.recv_into(b) │
│ 670 │ │ │ except timeout: │
│ 671 │ │ │ │ self._timeout_occurred = True │
│ 672 │ │ │ │ raise │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
timeout: timed out

During handling of the above exception, another exception occurred:

╭─────────────────────────────────────── Traceback (most recent call last) ───────────────────────────────────────╮
│ /home/unison/Miniconda3/envs/virth/lib/python3.8/site-packages/requests/adapters.py:439 in send │
│ │
│ 436 │ │ │
│ 437 │ │ try: │
│ 438 │ │ │ if not chunked: │
│ ❱ 439 │ │ │ │ resp = conn.urlopen( │
│ 440 │ │ │ │ │ method=request.method, │
│ 441 │ │ │ │ │ url=url, │
│ 442 │ │ │ │ │ body=request.body, │
│ │
│ /home/unison/Miniconda3/envs/virth/lib/python3.8/site-packages/urllib3/connectionpool.py:637 in urlopen │
│ │
│ 634 │ │ │ elif isinstance(e, (SocketError, HTTPException)): │
│ 635 │ │ │ │ e = ProtocolError('Connection aborted.', e) │
│ 636 │ │ │ │
│ ❱ 637 │ │ │ retries = retries.increment(method, url, error=e, _pool=self, │
│ 638 │ │ │ │ │ │ │ │ │ │ _stacktrace=sys.exc_info()[2]) │
│ 639 │ │ │ retries.sleep() │
│ 640 │
│ │
│ /home/unison/Miniconda3/envs/virth/lib/python3.8/site-packages/urllib3/util/retry.py:368 in increment │
│ │
│ 365 │ │ elif error and self._is_read_error(error): │
│ 366 │ │ │ # Read retry? │
│ 367 │ │ │ if read is False or not self._is_method_retryable(method): │
│ ❱ 368 │ │ │ │ raise six.reraise(type(error), error, stacktrace) │
│ 369 │ │ │ elif read is not None: │
│ 370 │ │ │ │ read -= 1 │
│ 371 │
│ │
│ /home/unison/Miniconda3/envs/virth/lib/python3.8/site-packages/urllib3/packages/six.py:686 in reraise │
│ │
│ 683 │ │ │ value = tp() │
│ 684 │ │ if value.traceback is not tb: │
│ 685 │ │ │ raise value.with_traceback(tb) │
│ ❱ 686 │ │ raise value │
│ 687 │
│ 688 else: │
│ 689 │ def exec
(code, globs=None, locs=None): │
│ │
│ /home/unison/Miniconda3/envs/virth/lib/python3.8/site-packages/urllib3/connectionpool.py:597 in urlopen │
│ │
│ 594 │ │ │ │ self._prepare_proxy(conn) │
│ 595 │ │ │ │
│ 596 │ │ │ # Make the request on the httplib connection object. │
│ ❱ 597 │ │ │ httplib_response = self._make_request(conn, method, url, │
│ 598 │ │ │ │ │ │ │ │ │ │ │ │ timeout=timeout_obj, │
│ 599 │ │ │ │ │ │ │ │ │ │ │ │ body=body, headers=headers, │
│ 600 │ │ │ │ │ │ │ │ │ │ │ │ chunked=chunked) │
│ │
│ /home/unison/Miniconda3/envs/virth/lib/python3.8/site-packages/urllib3/connectionpool.py:386 in _make_request │
│ │
│ 383 │ │ │ │ │ # otherwise it looks like a programming error was the cause. │
│ 384 │ │ │ │ │ six.raise_from(e, None) │
│ 385 │ │ except (SocketTimeout, BaseSSLError, SocketError) as e: │
│ ❱ 386 │ │ │ self._raise_timeout(err=e, url=url, timeout_value=read_timeout) │
│ 387 │ │ │ raise │
│ 388 │ │ │
│ 389 │ │ # AppEngine doesn't have a version attr. │
│ │
│ /home/unison/Miniconda3/envs/virth/lib/python3.8/site-packages/urllib3/connectionpool.py:306 in _raise_timeout │
│ │
│ 303 │ │ """Is the error actually a timeout? Will raise a ReadTimeout or pass""" │
│ 304 │ │ │
│ 305 │ │ if isinstance(err, SocketTimeout): │
│ ❱ 306 │ │ │ raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % time │
│ 307 │ │ │
│ 308 │ │ # See the above comment about EAGAIN in Python 3. In Python 2 we have │
│ 309 │ │ # to specifically catch it and throw the timeout error │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
ReadTimeoutError: HTTPConnectionPool(host='127.0.0.1', port=8082): Read timed out. (read timeout=30)

During handling of the above exception, another exception occurred:

╭─────────────────────────────────────── Traceback (most recent call last) ───────────────────────────────────────╮
│ /home/unison/Github/virtualhome/src/virtualhome/demo/../simulation/unity_simulator/comm_unity.py:92 in │
│ post_command │
│ │
│ 89 │ │ │ if repeat: │
│ 90 │ │ │ │ resp = self.requests_retry_session().post(self._address, json=request_di │
│ 91 │ │ │ else: │
│ ❱ 92 │ │ │ │ resp = requests.post(self._address, json=request_dict, timeout=self.time │
│ 93 │ │ │ if resp.status_code != requests.codes.ok: │
│ 94 │ │ │ │ print(resp) │
│ 95 │ │ │ │ raise UnityEngineException(resp.status_code, resp.json()) │
│ │
│ /home/unison/Miniconda3/envs/virth/lib/python3.8/site-packages/requests/api.py:116 in post │
│ │
│ 113 │ :rtype: requests.Response │
│ 114 │ """ │
│ 115 │ │
│ ❱ 116 │ return request('post', url, data=data, json=json, **kwargs) │
│ 117 │
│ 118 │
│ 119 def put(url, data=None, **kwargs): │
│ │
│ /home/unison/Miniconda3/envs/virth/lib/python3.8/site-packages/requests/api.py:60 in request │
│ │
│ 57 │ # avoid leaving sockets open which can trigger a ResourceWarning in some │
│ 58 │ # cases, and look like a memory leak in others. │
│ 59 │ with sessions.Session() as session: │
│ ❱ 60 │ │ return session.request(method=method, url=url, **kwargs) │
│ 61 │
│ 62 │
│ 63 def get(url, params=None, **kwargs): │
│ │
│ /home/unison/Miniconda3/envs/virth/lib/python3.8/site-packages/requests/sessions.py:533 in request │
│ │
│ 530 │ │ │ 'allow_redirects': allow_redirects, │
│ 531 │ │ } │
│ 532 │ │ send_kwargs.update(settings) │
│ ❱ 533 │ │ resp = self.send(prep, **send_kwargs) │
│ 534 │ │ │
│ 535 │ │ return resp │
│ 536 │
│ │
│ /home/unison/Miniconda3/envs/virth/lib/python3.8/site-packages/requests/sessions.py:646 in send │
│ │
│ 643 │ │ start = preferred_clock() │
│ 644 │ │ │
│ 645 │ │ # Send the request │
│ ❱ 646 │ │ r = adapter.send(request, **kwargs) │
│ 647 │ │ │
│ 648 │ │ # Total elapsed time of the request (approximately) │
│ 649 │ │ elapsed = preferred_clock() - start │
│ │
│ /home/unison/Miniconda3/envs/virth/lib/python3.8/site-packages/requests/adapters.py:529 in send │
│ │
│ 526 │ │ │ │ # This branch is for urllib3 versions earlier than v1.22 │
│ 527 │ │ │ │ raise SSLError(e, request=request) │
│ 528 │ │ │ elif isinstance(e, ReadTimeoutError): │
│ ❱ 529 │ │ │ │ raise ReadTimeout(e, request=request) │
│ 530 │ │ │ else: │
│ 531 │ │ │ │ raise │
│ 532 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
ReadTimeout: HTTPConnectionPool(host='127.0.0.1', port=8082): Read timed out. (read timeout=30)

During handling of the above exception, another exception occurred:

╭─────────────────────────────────────── Traceback (most recent call last) ───────────────────────────────────────╮
│ in :9 │
│ │
│ 6 │ │ ' [grab] ({})'.format(apple), │
│ 7 │ │ ' [put] ({}) ({} 0,-3)'.format(apple, desk), │
│ 8 │ │ ] │
│ ❱ 9 success, message = comm.render_script(script=script[:2], │
│ 10 │ │ │ │ │ │ │ │ │ find_solution=True, │
│ 11 │ │ │ │ │ │ │ │ │ processing_time_limit=80, │
│ 12 │ │ │ │ │ │ │ │ │ frame_rate=15, │
│ │
│ /home/unison/Github/virtualhome/src/virtualhome/demo/../simulation/unity_simulator/comm_unity.py:492 in │
│ render_script │
│ │
│ 489 │ │ │ │ 'camera_mode': camera_mode, 'recording': recording, │
│ 490 │ │ │ │ 'image_width': image_width, 'image_height': image_height, │
│ 491 │ │ │ │ 'time_scale': time_scale, 'skip_animation': skip_animation} │
│ ❱ 492 │ │ response = self.post_command({'id': str(time.time()), 'action': 'render_script', │
│ 493 │ │ │ │ │ │ │ │ │ 'stringParams': [json.dumps(params)] + script}) │
│ 494 │ │ │
│ 495 │ │ try: │
│ │
│ /home/unison/Github/virtualhome/src/virtualhome/demo/../simulation/unity_simulator/comm_unity.py:98 in │
│ post_command │
│ │
│ 95 │ │ │ │ raise UnityEngineException(resp.status_code, resp.json()) │
│ 96 │ │ │ return resp.json() │
│ 97 │ │ except requests.exceptions.RequestException as e: │
│ ❱ 98 │ │ │ raise UnityCommunicationException(str(e)) │
│ 99 │ │
│ 100 │ def check_connection(self): │
│ 101 │ │ response = self.post_command( │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
UnityCommunicationException: HTTPConnectionPool(host='127.0.0.1', port=8082): Read timed out. (read timeout=30)

@HuiHuiSun
Copy link

Hello!
I'm meeting the same error. Did you solve it?

1 similar comment
@RichardChangCA
Copy link

Hello!
I'm meeting the same error. Did you solve it?

@RichardChangCA
Copy link

@HuiHuiSun Hello!
I'm meeting the same error. Did you solve it?

@YoheiHayamizu
Copy link

Hello!

I realized that render_script raises the error when the argument types are wrong. e.g., image_synthesis and camera_mode must be lists.

I could get it working by adding the following line to ensure the parameters sent to the unity simulator are correct.

  def render_script(self, script, randomize_execution=False, random_seed=-1, processing_time_limit=10,
                    skip_execution=False, find_solution=False, output_folder='Output/', file_name_prefix="script",
                    frame_rate=5, image_synthesis=['normal'], save_pose_data=False,
                    image_width=640, image_height=480, recording=False,
                    save_scene_states=False, camera_mode=['AUTO'], time_scale=1.0, skip_animation=False):
      assert isinstance(script, list), \
          "Script must be a list of strings"
      assert isinstance(image_synthesis, list), \
          "image_synthesis must be a list of strings"
      assert isinstance(camera_mode, list), \
          "camera_mode must be a list of strings"
      ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants