UPenn-RoboCup / UPennalizers

Open Source Repository for Team UPennalizers
GNU General Public License v3.0
69 stars 38 forks source link

How to Monitor Darwin-OP #19

Closed meisamb closed 11 years ago

meisamb commented 12 years ago

Hi After running robot successfully, now i am interested to get logs and monitor Darwin in network by Logger.m and MonitorNet.m you have provided. i read wiki to find how can i do that. but i got confused in steps and Matlab can not get logs. here is all i have done, please let me know if i am wrong:

  1. i have changed Darwin wireless IP rang to our rang in all files in this directory: UPennalizers/Lib/Platform/OP/Comm/
  2. i have typed "make setup_op" command again in this directory: UPennalizers/Lib/
  3. then i executed run_dcm.lua and run_cognition.lua.
  4. i executed run_monitor.lua, but it returns this error:

    lua: run_monitor.lua:3: module 'unix' not found: no field package.preload['unix'] [.... and more lines] then i changed some in top lines of run_monitor.lua and then it works and shows this line periodically: fps: 40.22553823892, Level: 0

  5. after all and coping "UPennalizers/Lib/Util/Matlab" to the laptop, i changed wireless ip address in "libMonitor.h" and then i have executed "Logger.m" in Matlab that installed in windows. but it seems it can not receive any data packet and shows error after a while.

I feel i have done something wrong! Please let me know it.

yida commented 12 years ago

Hi meisamb,

Thank you for interested in our code base. However, all our tools do not support windows at all. Matlab scripts might work in windows, but it required a unix c library to receive message. The run_monitor.lua depends on unix.so library, you might either copy from Player/Lib or compile one in Lib/Util/Unix.

Since we stop update github open source for match preparation, we are not able to help you debugging all problems. Please try to understand the whole sending and receiving pipeline, it is really not that hard.

Yida

On Thu, Mar 15, 2012 at 12:16 PM, meisamb < reply@reply.github.com

wrote:

Hi After running robot successfully, now i am interested to get logs and monitor Darwin in network by Logger.m and MonitorNet.m you have provided. i read wiki to find how can i do that. but i got confused in steps and Matlab can not get logs. here is all i have done, please let me know if i am wrong:

  1. i have changed Darwin wireless IP rang to our rang in all files in this directory: UPennalizers/Lib/Platform/OP/Comm/
  2. i have typed "make setup_op" command again in this directory: UPennalizers/Lib/
  3. then i executed run_dcm.lua and run_cognition.lua.
  4. i executed run_monitor.lua, but it return this error:

    lua: run_monitor.lua:3: module 'unix' not found: no field package.preload['unix'] [.... and more lines] then i changed some lines in top lines of run_monitor.lua and then it works and shows this line periodically: fps: 40.22553823892, Level: 0

  5. after all and coping "UPennalizers/Lib/Util/Matlab" to the laptop, i changed wireless ip address in "libMonitor.h" and then i have executed "Logger.m" in Matlab that installed in windows. but it seems it can not receive any data packet.

i feel i have done something wrong! Please let me know it.


Reply to this email directly or view it on GitHub: https://github.com/UPenn-RoboCup/UPennalizers/issues/19

jbrindza commented 12 years ago

Hi, unfortunately there are a number of things that could be causing the problem.

The most common is that your network router/firewall is not allowing broadcast packets or there is a mistake with the the IP/port configuration.

Can you do a quick test to make sure you can send and receive messages with the robot. Can you run the commands under the "UDP Communication" section of the Inter Robot Communication Wiki Page.

You can start Lua from the Player folder on the robot and just run the commands in the first code block interactively. And on your personal computer you can start Lua from the Player folder and run the code from the second block. (Make sure you require Comm on your computer before you try to send anything from the robot.)

Let us know if that works. It means the problem is in the Matlab or monitor code and I can give you some tests to figure out which.

-Jordan

jbrindza commented 12 years ago

Sorry, I didn't see you were trying to run it under Windows.

The mex files we provide are for unix based operating systems (linux, mac osx). If you want to be able to monitor the robot on Windows you will need a version of libMonitor that uses the Windows socket API to send and receive the UDP packets.

There is not much difference between windows and unix socket programing, so it is definitely possible to do.

meisamb commented 12 years ago

Thank you Yida, I have copied unix.so from "Player/Lib" directory beside the "run_monitor.lua" and it runs without any changes required. but unfortunately my problem in receiving its data didn't solved yet.

meisamb commented 12 years ago

thank you brindza, you got me helpful information. i did what you said. first i have wrote two files from Inter Robot Communication Wiki Page to send UDP packets in "Upennalizers/Player". here is the "send_udp.lua" source code, it's sending a test table every 3 seconds from Darwin-OP:

send_udp.lua

-- init.lua will include subpaths and C-libraries
dofile('init.lua');
require('serialization')
require('Comm')
require('unix')

-- create a table to test with
testTable = {pose={x=2, y=4, a=math.pi}, s='this is a string', v={0,1,2,3}};
--testTable = 'YRA humanoid';
-- serialize the table
s = serialization.serialize(testTable);

count=0;

-- send the data
while 1 do
    Comm.send(s);
    count=count+1;
    print('Number of sent: '..count);

    unix.usleep(3000000);
end

and here is the UDP packet receiver that runs in my laptop in "Upennalizers/Player" and tries to receive any available packet every 100 milliseconds:

receive_udp.lua

dofile('init.lua');
require('serialization')
require('Comm')

while 1 do

    -- receive the packet
    s = Comm.receive();

    if s~=nil then
        -- de-serialize the table
        deserializedTable = serialization.deserialize(s);
        for k,v in pairs(deserializedTable) do print(k,v) end
        for k,v in pairs(deserializedTable.pose) do print(k,v) end
        for k,v in pairs(deserializedTable.v) do print(k,v) end
    end
    unix.usleep(100000);
end

but it doesn't receive any packet from Darwin. i have monitored our network transmission by wireshark but there was no UDP packet from robot's IP in the network. I'm pretty sure that router doesn't block broadcast packets because i have tested another project later. what should I do till packets can come out from robot?

also I have provided a Linux edition of the Matlab R2011a from laboratory. and its now working in Ubuntu 10.10 witch has been installed in a virtual machine. Then in "Upennalizers/Lib/Util/Matlab" in my Ubuntu 10.10 I have tried to execute makefile but it got me an error about finding mex command, so I did some changes in make file by adding this line:

MEX = /usr/local/MATLAB/R2011a/bin/mex

and changing last lines same as below:

mex -O $^ libMonitor.o $(INCLUDES) ----> $(MEX) -O $^ libMonitor.o $(INCLUDES)

so makfile compiled this folder on my computer. after running "MonitorNet.m", it shows 'Empty monitor struct!'. and both robot and Matlab scripts are using default team's and robot's number, so I don't think it's because of wrong team or robot information.

What do you think about this issue? Is it related to sending data from robot? or I was wrong somewhere else?

jbrindza commented 12 years ago

I would try it just using static IPs over a wired connection. There are some instructions here on how to set it up on the robot and your personal computer (https://github.com/UPenn-RoboCup/UPennalizers/wiki/Networking).

Note, you will need to set your the static IP from Windows if you are using a virtual machine to run Ubuntu. Set your IP and the robots: PC: 192.168.0.1 DARWIN: 192.168.0.2

Then change the IP definition in the Comm module files to: #define IP "192.168.0.255"

Make sure whatever number is defined as PORT in the Comm module is the same on both your computer and the robot.

If you can ssh into the robot over the wired connection $ ssh darwin@192.168.0.2

Then see if you are able to use the UDP communication over the wired connection.

meisamb commented 12 years ago

thank you brindza, :) Now my robot is able to send and receive UDP packets over wired connection. I have send and receive packets by codes above. in config files there is a line that should change. dev.comm='NullComm'; to dev.comm='OPComm';

now I'm trying to receive monitoring packets by Matlab scripts provided by you. I have executed "run_monitor.lua" when i press "g" on keyboard it sends packets to the net. I can see it's packets in my network by wireshark (a free software to monitor netwoks). but Matlab doesn't receive them, the team and player numbers are correct.

what solution do you suggest me?

jbrindza commented 12 years ago

There are two different ports that the robots use for communication.

There is the team communication one that the robots use to send data to each other, which is specified in the OpComm and then there is the one that they use to send out the monitoring data which is used by MonitorComm. The ports used must be different.

Make sure the libMonitorComm.h file in the matlab folder has the same IP and PORT as the luaOPMonitorCommWired.cc file has (or whichever Comm module you specified in dev.monitor_comm = 'OPMonitorCommWired';). Make sure you use a different port than what is used in OPComm.

Sorry, the Comm modules are not very organized or documented well right now.

meisamb commented 12 years ago

Sorry I have deleted my last post, because of a clear mistake in running project. Now robot is sending the logs to the computer and Matlab is receiving them successfully. :) According to the wiki to create a new LUT I should run Logger. This is Logger message:

>> Logger(18,2)
??? Reference to non-existent field 'get_width'.

Error in ==> shm_robot>get_yuyv at 109
        width = h.vcmImage.get_width();

Error in ==> Logger at 23
  LOG.camera(ilog).yuyv = robot.get_yuyv() + 0;

Is there any config on the robot that must be set to send images to the computer?

or something is wrong in running project? I called startup function in Matlab then Logger(18,2) while run_monitor is running in level 3.

jbrindza commented 12 years ago

The Logger.m function is meant to be run on the robot itself (or on your computer if you want to log from the Webots simulation).

The log is simply a matlab struct array with the fields: time yuyv headAngles select

The yuyv field is the only one used when making a colortable.

There is currently no way to log images remotely but if you are not able to install matlab on the robot all of the data is there if you wanted to add that ability to the monitor code. The robot variables in the monitor functions should have a function called get_yuyv() that will return the yuyv data. You could add something to the monitor code that periodically stores the yuyv data into an array (you can just set all the other fields of the struct to empty arrays).

meisamb commented 12 years ago

Thanks a lot brindza, I have installed MATLAB on a flash drive and ran on robot. I got logs in various light conditions and I am making new LUT.

Now I am going to upgrade myself in using your project to have an intelligent robot. player.lua is a good sample for understanding your project, but i am beginner in lua and coding for soccer robots.

is there any sample that robot use game control or kick throw a goal?

jbrindza commented 12 years ago

In the config file there is a 'fsm' parameter that determines which state machines the robot will run (these determine the high level behavior of the robot). You can set them all to 'OpDemo' which is the simplest set we have.

fsm = {};
fsm.game = 'OpDemo';
fsm.head = 'OpDemo';
fsm.head = 'OpDemo';

The basic behavior is: Search for the ball -> Walk up to the ball -> Kick the ball, repeat