geek-ai / MAgent

A Platform for Many-Agent Reinforcement Learning
MIT License
1.68k stars 332 forks source link

can't watch videos #48

Closed Ayeliauk closed 4 years ago

Ayeliauk commented 5 years ago

Thanks for your brilliant code. When I open index.html in browser.The page show: magent : :render::RenderException: "invalid handle of the map configuration file",and didn't show videos.I want to know the reason.

Kipsora commented 5 years ago

Can you give me more details about your situation? Which MAgent environment are you working on? How did you run the render? Basically the exception is caused by broken JSON configuration file. And you should run the render under the work path which the render locates at.

Ayeliauk commented 5 years ago

Thank you for your answer.I run it on OSX ,python 3.6.....I open render under the folder /magent/bulid/render directly.

Kipsora commented 5 years ago

Can you package all of the render files to me including the render, the video files and JSON files. You can share via Google Drive or Dropbox if the file is too large.

Ayeliauk commented 5 years ago

How can I give you the files.I try to send it to your mail, but my mail was rejected.And these files are downloaded directly from your project

Kipsora commented 5 years ago

Have you trained the agents? The video files is generated from the scripts. You should train these agents first and then the video can be generated. Check if you have a video files named "video_xxx.txt" (xxx is a number) under /path/to/magent/build/render.

Ayeliauk commented 5 years ago

Thank you. I have run the python examples/api_demo.py, and it generate a file called video_1.txt. I think if the problems are in the JSON files.

Kipsora commented 5 years ago

Yes. You should execute examples/train_xxx.py to train the agents (there is an option --save_every for the frequency of generating videos) and the video files as well as the JSON configuration file will be automatically generated.

Ayeliauk commented 5 years ago

Sorry,I don't know how render work.Do you mean that I run examples/api_demo.py and then get video_1.txt, but it show noting normally.So I should run examples/train_xxx.py, and when it finished ,it can automatically generate another video files as well as the JSON configuration file?

Ayeliauk commented 5 years ago

I have run example/train_tigers just now.but it generate noting.

Kipsora commented 5 years ago

It takes 5 rounds to generate one video. You can either be patient or modify the behavior by giving the option --save-every=1.

Ayeliauk commented 5 years ago

It run 100 rounds but still generate nothing.what show in render is: cannot listen on port 9030 reason: Underlying Transport Error logout Saving session... ...copying shared history... ...saving history...truncating history files... ...completed. what this mean...

Kipsora commented 5 years ago

Thanks for your reply. To track your issues:

  1. Can you show the files under your folder /build/render?
  2. It is caused by your previously running render being anomaly shutdown. You can run ./render --port=9031 to run the render on another port 9031.
Ayeliauk commented 5 years ago

These files are config.json ,index.html, js, render , static.map ,vendor ,video_1.txt.

Ayeliauk commented 5 years ago

config.json: { "width": 100, "height": 100, "static-file": "static.map", "obstacle-style": "rgba(127,127,127,1)", "dynamic-file-directory": ".", "attack-style": "rgba(63,63,63,0.8)", "minimap-width": 300, "minimap-height": 250, "group" : [ { "height": 2, "width": 2, "style": "rgba(192,64,64,1)", "anchor": [0, 0], "max-speed": 1, "speed-style": "rgba(192,64,64,0.01)", "vision-radius": 5, "vision-angle": 360, "vision-style": "rgba(192,64,64,0.2)", "attack-radius": 2, "attack-angle": 360, "attack-style": "rgba(192,64,64,0.1)", "broadcast-radius": 1 }, { "height": 1, "width": 1, "style": "rgba(64,64,192,1)", "anchor": [0, 0], "max-speed": 1, "speed-style": "rgba(64,64,192,0.01)", "vision-radius": 4, "vision-angle": 360, "vision-style": "rgba(64,64,192,0.2)", "attack-radius": 0, "attack-angle": 360, "attack-style": "rgba(64,64,192,0.1)", "broadcast-radius": 1 } ] }

Kipsora commented 5 years ago

Got it. I forgot another option. Can you re-run the script with --render? That is,

$ python3 examples/train_tiger.py --render --save_every=1 --train

That should be working now. Additionally, you can check all of the options by,

$ python3 examples/train_tiger.py --help
Ayeliauk commented 5 years ago

thank you it now generate many video_xx .txt, what should I do next.I open index.html,change the txt ,for example video_8 txt. it still show magent::render::RenderException: "invalid handle of the map configuration file".......

Kipsora commented 5 years ago

It is strange. You may clone a new repo and run all of the following scripts, which is passed on Ubuntu 18.04.

git clone git@github.com:geek-ai/MAgent.git
cd MAgent
sudo apt-get install cmake libboost-system-dev libjsoncpp-dev libwebsocketpp-dev
bash build.sh
export PYTHONPATH=$(pwd)/python:$PYTHONPATH
python3 examples/train_tiger.py --render --save_every=1 --train

# start another terminal and run
cd MAgent/build/render

# I think you have start render before so the following command 
# is used to kill the render you started earlier.
pkill render
./render

If you still have problems, package all of your MAgent files and send it back to me.

Ayeliauk commented 5 years ago

Thank you a lot for your patience.I will try to clone a new repo to see if it can work thank you again

voanhkha commented 4 years ago

Hi Kipsora. I have another problem with render. I run "$ python3 examples/train_tiger.py --render --save_every=1 --train" as you told, but in build/render, there is nothing except video_xx.txt files and config.json. There is no subfolder render or index.html... I tried several other training scenarios, but still I can't see ./render under build/render. I run on MacOS. Could you please help me with this case? Thanks so much. Kha.

Kipsora commented 4 years ago

@voanhkha Can you post the build process for me to pinpoint your issue?

voanhkha commented 4 years ago

@voanhkha Can you post the build process for me to pinpoint your issue?

@Kipsora Thanks for your support. The building error is extremely long. I just copied a head of it. For the remaining part, they are just repeated patterns of the later part of the below copied text. The key thing is the error "no member named... asio..." as copied. I also tried the solution here https://github.com/geek-ai/MAgent/issues/14, but still has the problem.

(base) Vos-MacBook-Pro:MAgent voanhkha$ bash build.sh -- Configuring done -- Generating done -- Build files have been written to: /Users/voanhkha/Desktop/MAgent/build [ 12%] Building CXX object CMakeFiles/render.dir/src/render/backend/websocket.cc.o [ 18%] Building CXX object CMakeFiles/render.dir/src/render/backend/render.cc.o [ 84%] Built target magent [ 84%] Built target testlib In file included from /Users/voanhkha/Desktop/MAgent/src/render/backend/websocket.cc:1: In file included from /Users/voanhkha/Desktop/MAgent/src/render/backend/websocket.h:4: In file included from /usr/local/include/websocketpp/config/asio_no_tls_client.hpp:32: In file included from /usr/local/include/websocketpp/transport/asio/endpoint.hpp:32: In file included from /usr/local/include/websocketpp/transport/asio/connection.hpp:31: In file included from /usr/local/include/websocketpp/transport/asio/base.hpp:31: In file included from /usr/local/include/websocketpp/common/asio.hpp:61: In file included from /usr/local/include/boost/asio/steady_timer.hpp:22: In file included from /usr/local/include/boost/asio/basic_waitable_timer.hpp:27: In file included from /usr/local/include/boost/asio/executor.hpp:338: /usr/local/include/boost/asio/impl/executor.hpp:179:22: error: no member named 'context' in 'std::__1::reference_wrapper' return executor_.context();


/usr/local/include/boost/asio/impl/executor.hpp:142:3: note: in instantiation of
      member function
      'boost::asio::executor::impl<std::__1::reference_wrapper<boost::asio::io_context>,
      std::__1::allocator<void> >::context' requested here
  impl(const Executor& e, const Allocator& a) BOOST_ASIO_NOEXCEPT
  ^
/usr/local/include/boost/asio/impl/executor.hpp:137:30: note: in instantiation
      of member function
      'boost::asio::executor::impl<std::__1::reference_wrapper<boost::asio::io_context>,
      std::__1::allocator<void> >::impl' requested here
    impl* p = new (mem.ptr_) impl(e, a);
Kipsora commented 4 years ago

@voanhkha This problem is caused by upgraded boost which is incompatible with the old version of websocketpp. You can downgrade your boost via:

brew uninstall boost
brew install boost@1.55
brew link --force boost@1.55

And try bash build.sh again.

voanhkha commented 4 years ago

@Kipsora Thanks for your help. It works now!

luohc2004 commented 4 years ago

It seems the render program should run under render folder to parse config.json correctly. Otherwise it will report a ': magent : :render::RenderException: "invalid handle of the map configuration file"' error.