-
Notifications
You must be signed in to change notification settings - Fork 12
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
Support for Windows #58
Support for Windows #58
Comments
Currently the rulebased python example is not working (robots do not move at all and "Error: participant.py: Invalid JSON object." message is displayed many times). Is this an issue tied with 11? |
Yes. This message is displayed when the received frames cannot be handled correctly because they are truncated. It is very likely that fixing the main loop in |
In compiling the C++ example program (which seems to use Unix headers), should I use MSYS environment? Could there be an easier way to compile on Windows? |
Using MSYS should indeed fix the problem (can you confirm that please?). We can write a Makefile so that it will be possible to use Webots to compile the program, would this be fine for you? |
I am not sure how I can use cmake on MSYS console to generate makefile and build the program. I used MinGW64 console, cmake -G "MSYS Makefiles", make and the result says it cannot find "arpa/inet.h" |
and yes, if we can build the program using Webots + makefiles, it would be more convenient for the participants |
I will also fix |
I will add a makefile in #8 |
I believe all the major issues are now fixed. @chshong: can you test it? |
I got this error when I ran the simulation right after the start. Could it be only happening on Linux? |
Are you using Python 2? |
Yes I do, we currently support both Python 2 and 3. |
I see, it's probably a Python 2 issue. I will investigate and try to fix it. |
Meanwhile can you test with Python 3? |
I just tested on a fresh Ubuntu 18.04 with Python 2.7.15+, Webots R2019b and the current version of AIWC from https://github.com/omichel/test_world and I don't get any error. The rulebased-B python program seems to work fine and is able to score goals. I get no error. Can you try again and let me know? |
I have tried again with print commands to locate the issue. It seems like the message is sometimes not a complete message as can be seen below (role: True means Team Red - rulebased-B and False means Team Blue - random-walk). It looks like the connection between the supervisor and participant programs is not stable. I ran the same setting several times and observed that the program sometimes run correctly but crashes like below occasionally. Case 1
Case 2
|
👀 (I suspect that a message from a socket is not fully read in some cases, I will try to reproduce and fix this) |
I assume this happens on Linux with Python 2.7, right? |
Yes, my testing environment was Ubuntu 16.04, Python 2.7 |
I believe I fixed the problem here: omichel#14 |
This maybe an unrelated issue but I keep getting below message even when I change the shebang of supervisor.py to #!/usr/bin/python3
Does Webots print the message regardless of the Python version using? |
Can you make a working example of image-fetch in python? It seems like simply migrating the old example to new example does not work. Are the contents of 'subimages' sent by the supervisor different from the old one? |
The format is similar (same base64 encoding and same sub-image resolution) however, it is encoded in a JSON string. I will create a simple image-fetch example in python. |
Webots is ignoring the shebang line in controller programs. Rather, it is using the python version specified in the Webots preferences, regardless of the shebang. So, if the Webots preferences specify python2, it will use python2 even though the shebang request python3. We could possibly fix that in Webots, but it will be integrated only in the next version. |
Okay, I think I should notify this along with AIWC simulation program distribution since the message may confuse the participants |
This is now fixed in omichel#25 |
@omichel Can you give @lfelipesv permissions to make changes on Python porting fork? He will join us reviewing this work from this Wednesday or Thursday. |
Done. I just added @lfelipesv as a developer on our repo. |
nevermind |
Regarding the image data sent from supervisor to participants, does the supervisor send image with RGBA channels instead of RGB channels? If so, how should the supervisor be changed to make the supervisor send RGB image instead of RGBA image? This is because since the AIWC system does not use the alpha channel, it would be more efficient to send RGB only. Also, can you check the C++ general_image-fetch example pushed here? It currently has two issues.
|
Yes, the supervisor does indeed send RGBA channels, this is done for efficiency reason, on the supervisor side we do send all the image in a bulk, this avoid having to loop through each pixels and therefore speedup the sending of images (we do indeed send a bit more data, but this is still more efficient than having to loop through each pixels). I will check your C++ general_image-fetch example. |
I checked your general_image-fetch example, the Makefile has several issues:
Here is an example with all this corrections (of course you may need to adjust path and version of opencv):
I am not an expert of opencv, so maybe some libraries links are still missing, but the structure is now correct. |
Thank you. I have found that mainly $(LIBRARIES) part missing was where I could not locate the issue. Regarding ws2_32, I think we should modify Makefiles a bit to make it not try to link the windows library on Linux. Were you able to locate the issue making the displayed image incorrectly on image-fetch C++ example? |
From tomorrow, I will not be on work for 4 weeks for my country's military service. @lfelipesv will continue from here working on this project. |
You are completely right, this should be included only in the Windows case (i.e. encapsulated in a if condition).
I am not able to compile it (because of missing dependencies, such as opencv on my system). But the handeling method should be very similar to the previous version (except that the A channel is sent too, but I saw you already updated this). I checked in particular this part: https://github.com/omichel/test_world/blob/feature/new_examples/examples_new/general_image-fetch_cpp/general_image-fetch.cpp#L46 and everything seems fine. |
Hi, I am developing a C++ reporter example and I found some problems:
Regards. |
Hi Felipe, nice to see you posting here. I see that you resolved (1). Did you patch the python supervisor? If so, it would be nice to create a new PR to commit your changes here: https://github.com/omichel/test_world I will investigate (2) and (3) today and revert back to you about it. |
I cannot reproduce (3). For me at the kick-off, as soon as a robot hits the ball, all the other robots start moving. Are you sure you are up-to-date with https://github.com/omichel/test_world on the develop branch? |
About (2): I believe it might happen if the time step at which the supervisor is monitoring the ball position is too high. Lowering this time step might fix the problem. I will try to implement this next week. |
Hi Olivier =), I will create another branch from Chansol's one in the https://github.com/omichel/test_world repository. About (3), test if you can reproduce for Cornerkicks and Goalkicks situations. I will check the supervisor about the time step problem with (2), thanks. |
I just tested both the corner kick and goal kick situations and still cannot reproduce (3). The other players start moving as soon as the ball is hit. |
Interesting. I tested in two computers and it seems that it never enter the loop from line 457 (supervisor.py). Also I printed the touch vector from line 1006 and is always False (for all the robots). I think (2) and (3) are related to the touch problem, because if there is no touch in the penalty kick, the game is never back to STATE_DEFAULT. |
Are sure you recompiled the physics plugin in https://github.com/omichel/test_world/tree/develop/plugins/physics/collision_detector? |
It was the compilation. Thanks! (1), (2), (3) solved. |
Hi @omichel,
Best Regards. |
|
Hi @omichel,
|
Regarding sound recording, yes, this is an issue. We currently have no solution to record a movie and sound at the same time. The only way would be to display Webots in full screen and record both the video and audio using some external video/audio recording tool, not the built-in Webots movie feature. |
@omichel, i sent a pull request with a simple fix for (17). Regards. |
I just reviewed, accepted and merged your pull request for (17). |
@omichel , I found a bug: when the "deadlock" is changed to false in config.json, the deadlock is still enforced. The solution is to change line 730 of the supervisor.py file to: if not config['rule']['deadlock']: Regards. |
Hi @lfelipesv: I just applied you patch here: omichel#31 |
An effort to port AIWC simulation to Windows is being conducted at https://github.com/omichel/test_world. Basically, the communication system between the simulation supervisor and competitor code was changed. The supervisor was ported to Python and uses a simplified network protocol without any dependency on boost or bonefish libraries. This issue lists all the remaining problems and bugs that need to be fixed to complete the support for Windows:
1. Commentator and Reporter APIs: Fixed by @stefaniapedrazzi.
2. The Python supervisor does not transfer image frames to the participant programs (also image_buffer.cpp/hpp is not in Python counterpart). Fixed by @DavidMansolino.
3. C++ participant example program is missing.
player_random-walk_py
was converted to C++ by @DavidMansolino,4. Robot positions reset are not matched to the formations. Fixed by @chshong.
5. The sample participant program is not working as intended: If the program is correct, F2 robot should move toward and kick the ball to initiate the kickoff. Instead, F2 robot seems to move away from the ball (it seems like it is highly possible that either incorrect position/orientation data are sent to the participant or the wheel speeds sent from the participant programs are not applied to the robots correctly. Fixed by @omichel.
6. The key string is not used in validation of the participant programs' credentials. The only place the key is used is in Line 171. Since this only checks if the key is same with Team RED's key, the commentator and the reporter will be able to control Team BLUE's robots if they use 'aiwc.set_speeds'. In the cpp program, 'aiwc.set_speeds' can only be used by red and blue participants, 'aiwc.comment' by commentator, and 'aiwc.report' by reporter.
Fixed by @stefaniapedrazzi .
7. Rules do not seem to be applied accordingly.
8. The timestamp (one updated by update_label()) is not updated in real time but once in a second. Fixed by @chshong.
9. 'address already in use' error seems to happen occasionally. Fixed by @stefaniapedrazzi.
10. reset_reason messages are sent to the client programs multiple times instead of just one. Fixed by @stefaniapedrazzi.
11. frame messages sent could be concatenated and truncated when reading them from the socket buffer in the client program. Fixed by @stefaniapedrazzi and @DavidMansolino.
12. Remove the dependency on
boost
from thesoccer_robot
controller. Fixed by @omichel.13. 'data path' not handed over to AI Soccer programs. Fixed by @stefaniapedrazzi.
14. The simulation runs slower than when C++ controllers were used (with C++ controllers, the simulation usually ran in x1.0. with Python controllers, the simulation runs in about x0.66). Simulation not running in real-time can greatly affect participant programs since the simulation should be asynchronous. (additional note: This looks like a bug. The simulation returns to x1.0 speed when a goal is made and game is resumed. Only the "beginning->first goal of the game" segment is slowed down) (additional note 2: The issue looks more severe on Windows. The simulation speed even drops to about x0.33. The simulation returns to normal speed just like on Linux after a goal is made.). Fixed by @omichel.
15. The reporter's report is not received by the supervisor.
16. Participant programs seem to start operate 0.2-0.5 seconds (in simulation game_time) after the game begins. This can be seen by the timestamp put on the comments and the robots not moving for about first 0.2-0.5 seconds. Fixed by @omichel (note: after fixing 14, I could not reproduce this problem).
17. The supervisor does not start or terminate the game after WAIT_READY_MS seconds have passed when one of programs does not send aiwc.ready. If at least two AI Soccer participants are ready, the supervisor should drop not responding commentator/reporter and start the game. If any of AI Soccer participant was not ready within WAIT_READY_MS seconds, the game should be terminated.
18. The goalkeeper behavior of rulebased when put on Team B seems to imply that the team acts as if they are located on left in view of spectators. The data sent to Team B should be rotated by 180 degrees.
19. When the supervisor launches the participant program, it ignores the shebang on Linux. (Although the shebang specified python3, the python launched is python2 - can be checked by print(sys.version))
20. The supervisor publishes frames 10 ms period (basic time step) instead of 50 ms period (PERIOD_MS). (In the C++ AIWC system, we have
game::step(std::size_t ms)
method to be used instead of directly using Webots' supervisor step method.) This mismatch between the basic time step and supervisor step was an intended one so that the simulator can have more continuous simulation (such as minimizing the chance for the ball to pierce through robots due to the simulation step being too large) while the participants can control the robot with 50 ms period (50 ms is the control period of real AI Soccer robots).21. The comments made by commentator are handled bit delayed. When a goal is made, the commentator's "Team Red Scored!!" message was shown immediately in C++ system. In current Python system, the message is displayed only after the field is reset and the game resumes. (I checked that the commentator program receives the frame as soon as the goal is made. However, when the commentator program sends the comment to the supervisor,
callback(self, client, message)
method is called after the game resumes instead of before the game goes in halt.)22. In the game_info json, unnecessary information are handed over to the participants (team_info and key). In the case of 'key', TeamA's key is distributed to the commentator and reporter in game_info that this makes a door for the commentator and reporter algorithms to masquerade as Team A.
The text was updated successfully, but these errors were encountered: