LARG / HFO

Half Field Offense in Robocup 2D Soccer
MIT License
231 stars 93 forks source link

Python communication agent is broken #53

Closed DurgeshSamant closed 6 years ago

DurgeshSamant commented 6 years ago

Upon attempting to run it, one gets error message of the form base_left 7: [4778, 0] recv error message [(error illegal_command_form)] base_left 7: [4778, 0] lost say? at [4778, 0] sense=0 internal=1

Quite strangely the above error disappears if in hfo/hfo_c_wrapper.h, instead of hfo.say(message)
one uses hfo.say("anyfixedstring") One can then hear() back "anyfixedstring". Alas this is of no use - what one wishes is to be able to send custom messages through the python communication agent. Playing around with const char* message with different datatype + variable combination did not get me anywhere.

Further examination reveals that the 'say_msg' in /src/agent.h:setSayMsg() does seem to be set correctly. So the sending code seems to be correct (atleast till that point).

In an attempt to locate the function that prints the obtained error message, I looked at analyzeError() functions in ./build/librcsc-prefix/src/librcsc/rcsc/coach/coach_agent.cpp ./build/librcsc-prefix/src/librcsc/rcsc/player/player_agent.cpp ./build/librcsc-prefix/src/librcsc/rcsc/trainer/trainer_agent.cpp However, none of these seem to be throwing the error.

Any help from someone more knowledgeable about the internals would be greatly appreciated.

drallensmith commented 6 years ago

"Illegal command form" sounds like it would be coming from the server, actually. Yes - take a look at player.cpp in the rcssserver code. (BTW, does a fixed string still work if it has a space in it, for instance?)

-Allen

On Fri, Oct 27, 2017 at 5:27 AM, DurgeshSamant notifications@github.com wrote:

Upon attempting to run it, one gets error message of the form base_left 7: [4778, 0] recv error message [(error illegal_command_form)] base_left 7: [4778, 0] lost say? at [4778, 0] sense=0 internal=1

Quite strangely the above error disappears if in hfo/hfo_c_wrapper.h, instead of hfo.say(message) one uses hfo.say("anyfixedstring") One can then hear() back "anyfixedstring". Alas this is of no use - what one wishes is to be able to send custom messages through the python communication agent.

Further examination reveals that the 'say_msg' in /src/agent.h:setSayMsg() does seem to be set correctly.

It is at this point that the trail goes cold. In an attempt to locate the function that prints the obtained error message, I tried to looked at analyzeError() functions in ./build/librcsc-prefix/src/librcsc/rcsc/coach/coach_agent.cpp ./build/librcsc-prefix/src/librcsc/rcsc/player/player_agent.cpp ./build/librcsc-prefix/src/librcsc/rcsc/trainer/trainer_agent.cpp However, none of these seem to be throwing the error.

Any help from someone more knowledgeable about the internals would be greatly appreciated.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/LARG/HFO/issues/53, or mute the thread https://github.com/notifications/unsubscribe-auth/AZsckVZg-fRCzhbtGLORMKJpcRPgymvzks5swbASgaJpZM4QI2w5 .

drallensmith commented 6 years ago

Note also for longer-term reference that it is most helpful to do messages if the "attentionto" is set properly - e.g., with the current setup, for offense to whichever teammate has the ball, to more likely receive pass messages. (Admittedly, IIRC these will only actually be picked up currently on doing Dribble or Reorient.)

On Sun, Oct 29, 2017 at 7:46 PM, Allen Smith allen.w.smith1@gmail.com wrote:

"Illegal command form" sounds like it would be coming from the server, actually. Yes - take a look at player.cpp in the rcssserver code. (BTW, does a fixed string still work if it has a space in it, for instance?)

-Allen

On Fri, Oct 27, 2017 at 5:27 AM, DurgeshSamant notifications@github.com wrote:

Upon attempting to run it, one gets error message of the form base_left 7: [4778, 0] recv error message [(error illegal_command_form)] base_left 7: [4778, 0] lost say? at [4778, 0] sense=0 internal=1

Quite strangely the above error disappears if in hfo/hfo_c_wrapper.h, instead of hfo.say(message) one uses hfo.say("anyfixedstring") One can then hear() back "anyfixedstring". Alas this is of no use - what one wishes is to be able to send custom messages through the python communication agent.

Further examination reveals that the 'say_msg' in /src/agent.h:setSayMsg() does seem to be set correctly.

It is at this point that the trail goes cold. In an attempt to locate the function that prints the obtained error message, I tried to looked at analyzeError() functions in ./build/librcsc-prefix/src/librcsc/rcsc/coach/coach_agent.cpp ./build/librcsc-prefix/src/librcsc/rcsc/player/player_agent.cpp ./build/librcsc-prefix/src/librcsc/rcsc/trainer/trainer_agent.cpp However, none of these seem to be throwing the error.

Any help from someone more knowledgeable about the internals would be greatly appreciated.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/LARG/HFO/issues/53, or mute the thread https://github.com/notifications/unsubscribe-auth/AZsckVZg-fRCzhbtGLORMKJpcRPgymvzks5swbASgaJpZM4QI2w5 .

drallensmith commented 6 years ago

Another question re the python agent - python 3 strings are Unicode by default (with whether it's UTF-8 or UTF-16 varying by OS). What version of Python are you trying it with?

On Sun, Oct 29, 2017 at 7:46 PM, Allen Smith allen.w.smith1@gmail.com wrote:

"Illegal command form" sounds like it would be coming from the server, actually. Yes - take a look at player.cpp in the rcssserver code. (BTW, does a fixed string still work if it has a space in it, for instance?)

-Allen

On Fri, Oct 27, 2017 at 5:27 AM, DurgeshSamant notifications@github.com wrote:

Upon attempting to run it, one gets error message of the form base_left 7: [4778, 0] recv error message [(error illegal_command_form)] base_left 7: [4778, 0] lost say? at [4778, 0] sense=0 internal=1

Quite strangely the above error disappears if in hfo/hfo_c_wrapper.h, instead of hfo.say(message) one uses hfo.say("anyfixedstring") One can then hear() back "anyfixedstring". Alas this is of no use - what one wishes is to be able to send custom messages through the python communication agent.

Further examination reveals that the 'say_msg' in /src/agent.h:setSayMsg() does seem to be set correctly.

It is at this point that the trail goes cold. In an attempt to locate the function that prints the obtained error message, I tried to looked at analyzeError() functions in ./build/librcsc-prefix/src/librcsc/rcsc/coach/coach_agent.cpp ./build/librcsc-prefix/src/librcsc/rcsc/player/player_agent.cpp ./build/librcsc-prefix/src/librcsc/rcsc/trainer/trainer_agent.cpp However, none of these seem to be throwing the error.

Any help from someone more knowledgeable about the internals would be greatly appreciated.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/LARG/HFO/issues/53, or mute the thread https://github.com/notifications/unsubscribe-auth/AZsckVZg-fRCzhbtGLORMKJpcRPgymvzks5swbASgaJpZM4QI2w5 .

DurgeshSamant commented 6 years ago

Hi Allen,

Thanks for the reply.

In hfo/hfo_c_wrapper.h, instead of hfo.say(message) if one uses hfo.say("a b") One can then hear() back "a b". So a message containing a space separated string works well as long as it is hard-coded into the wrapper.

I am using python3.4 on Ubuntu 14.04.5 LTS.

DurgeshSamant commented 6 years ago

In HFO/build/rcssserver-prefix/src/rcssserver/src/player.cpp, I tried to insert prints in the parseMsg() and parseCommand(). However, they did not show up on the output or in the logs. So I'm not sure if I'm doing it right.

DurgeshSamant commented 6 years ago

It turns out that the issue was rather benign. The default message string "Hello!" had the special charachter '!'. Removing it, makes everything work smoothly. Here is an additional list of what the message string can and cannot contain

the message string can contain charachters a-z A-Z 0-9

  # the message string can contain special charachters like ?SPACE-*()+_<>/
  # the message string cannot contain !@#$^&={}[];:"'