aiwc / test_world

AI World Cup simulation environment
MIT License
7 stars 12 forks source link

Support for Windows #58

Open omichel opened 4 years ago

omichel commented 4 years ago

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:

DavidMansolino commented 4 years ago

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):

CXX       := g++
CXXFLAGS  := -pedantic-errors -Wall -std=c++14
BUILD     := ./build
OBJ_DIR   := $(BUILD)/objects
TARGET    := general_image-fetch
INCLUDE   := -I../common -I../../extlibs/cppcodec/include -I../../extlibs/opencv/include
LIBRARIES := -L../../extlibs/opencv/x64/vc16/bin -lopencv_core346 -lopencv_highgui346 -lws2_32
SRC       := general_image-fetch.cpp ../common/participant.cpp

OBJECTS := $(SRC:%.cpp=$(OBJ_DIR)/%.o)

all: build $(TARGET)
    @echo "Done."

$(OBJ_DIR)/%.o: %.cpp
    @mkdir -p $(@D)
    $(CXX) $(CXXFLAGS) $(INCLUDE) -o $@ -c $<

$(TARGET): $(OBJECTS)
    @mkdir -p $(@D)
    $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $(TARGET) $(OBJECTS) $(LIBRARIES)

.PHONY: all build clean debug release

build:
    @mkdir -p $(OBJ_DIR)

debug: CXXFLAGS += -DDEBUG -g
debug: all

release: CXXFLAGS += -O2
release: all

clean:
    -@rm -rvf $(BUILD)
    -@rm -rvf $(TARGET)

I am not an expert of opencv, so maybe some libraries links are still missing, but the structure is now correct. Let me know if you still have issues with this.

chshong commented 4 years ago

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?

chshong commented 4 years ago

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.

DavidMansolino commented 4 years ago

Regarding ws2_32, I think we should modify Makefiles a bit to make it not try to link the windows library on Linux.

You are completely right, this should be included only in the Windows case (i.e. encapsulated in a if condition).

The received data look correct, but how the received image is displayed on the screen implies the pixel data order is not handled correctly (I copied the image handling method from general_image-fetch_cpp of old example so it can be possible that the data order was changed when the supervisor system was ported to python version)

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. How does look like the image displayed?

lfelipesv commented 4 years ago

Hi, I am developing a C++ reporter example and I found some problems:

  1. (solved.) The GAME_END flag is received in the finish() method.

  2. When a robot is kicking a penalty, if the ball enter the goal and go out the goal before the game is restarted, the simulator does not count the goal and the game is not restarted.

  3. The touch still does not seem to work well, as the robots seems to always wait 3s before unlock again in Kickoff, CornerKick and Goalkick situations. (I think this problem is already related to the issue list)

Regards.

omichel commented 4 years ago

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.

omichel commented 4 years ago

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?

omichel commented 4 years ago

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.

lfelipesv commented 4 years ago

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.

omichel commented 4 years ago

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.

lfelipesv commented 4 years ago

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.

omichel commented 4 years ago

Are sure you recompiled the physics plugin in https://github.com/omichel/test_world/tree/develop/plugins/physics/collision_detector?

lfelipesv commented 4 years ago

It was the compilation. Thanks! (1), (2), (3) solved.

lfelipesv commented 4 years ago

Hi @omichel,

  1. I was checking the issue number 17. To solve: _"If any of AI Soccer participant was not ready within WAIT_READYMS seconds, the game should be terminated." would be possible to create a wait_ready_ms variable in the else loop of the lines 959-961 of the supervisor? Add self.timeStep to the variable and then compare with constants.WAIT_READY_MS, finishing the program if the participants are not ready after the waiting time?

  2. Would be possible to add the feature: "Improve the sound effects (ball kick, ball bounce on borders, poles, players, player to player contacts, etc.)" for the recording of the matches of the competition that will be held in upcoming November?

Best Regards.

omichel commented 4 years ago
  1. Yes, please go ahead and implement your suggestion for resolving 17. I can review it once implemented.
  2. Yes, I can implement the sound effects. However, Webots is currently unable to save sounds when recording a movie. So, you will have to record sounds separately and synchronize them with the video recorded by Webots... Is that a practicable workflow for you?
lfelipesv commented 4 years ago

Hi @omichel,

  1. Ok!
  2. It seems a possible workflow for us, but we have a question regarding a potential issue. To record the sound, using an external recorder won't work because the simulation won't run in x1.0 consistently, yet the video will be recorded as consistent x1.0. So it will be hard to synchronize audio and video. Am I understanding that right? Can we have the sound with consistent x1.0 speed?
omichel commented 4 years ago

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.

lfelipesv commented 4 years ago

@omichel, i sent a pull request with a simple fix for (17).

Regards.

omichel commented 4 years ago

I just reviewed, accepted and merged your pull request for (17).

lfelipesv commented 4 years ago

@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.

omichel commented 4 years ago

Hi @lfelipesv: I just applied you patch here: https://github.com/omichel/test_world/pull/31 In the future, feel free to create a pull request yourself to fix bugs you may find. Thank you!