RE: [robocup-rescue-s] need help

From: Baris Eker (baris.eker@cs.com.tr)
Date: Thu 17 Feb 2005 - 13:13:24 GMT


Hi,

I got a similar error before. If you look at the motionlesPosition() code,
it is

return position().motionlessPosition();

This means that sometimes position() method returns null, so you
get a "Null pointer exception" at that line. I think this happes when
you didn't have any information about the position of the civilian before.
I advise using like below;

if (mo != null){
  if (mo.position()!=null)
        lstPosNeedsHelp.add(mo.motionlessPosition());
}

Best regards;

Baris Eker
RoboAKUT Team

-----Original Message-----
From: robocup-rescue-s-bounces@cc.gatech.edu
[mailto:robocup-rescue-s-bounces@cc.gatech.edu]On Behalf Of Ray U
Sent: Thursday, February 17, 2005 2:25 PM
To: RCR Forum
Subject: [robocup-rescue-s] need help

Dear Researchers,

I am working on defining behavior of a custom RCR
agent within YabAPI framework. I got the following
output when hear() function was called:

OUTPUT
========

Action:HC224316744 hear() :(264179229) say :help_me
Action:HC242920931 hear() :(264179229) say :help_me
Action:HC266726397 hear() :(264179229) say :help_me
Action:HC99154190 hear() :(264179229) say :help_me
Action:HC116720810 hear() :(150429587) say :help_me
Action:HC180331927 hear() :(150429587) say :help_me
Action:HC223417615 hear() :(150429587) say :help_me
Action:HC230085738 hear() :(150429587) say :help_me
java.lang.NullPointerException
        at
yab.agent.object.MovingObject.motionlessPosition(MovingObject.java:29)
        at
sample.HelperCivilianAgent.hear(HelperCivilianAgent.java:143)
        at yab.agent.Agent.hearSay(Agent.java:37)
        at yab.agent.Agent.run(Agent.java:74)
Action:HC65981308 hear() :(150429587) say :help_me
java.lang.NullPointerException
        at
yab.agent.object.MovingObject.motionlessPosition(MovingObject.java:29)
        at
sample.HelperCivilianAgent.hear(HelperCivilianAgent.java:143)
        at yab.agent.Agent.hearSay(Agent.java:37)
        at yab.agent.Agent.run(Agent.java:74)
Action:HC56383441 hear() :(150429587) say :help_me
java.lang.NullPointerException
        at
yab.agent.object.MovingObject.motionlessPosition(MovingObject.java:29)
        at
sample.HelperCivilianAgent.hear(HelperCivilianAgent.java:143)
        at yab.agent.Agent.hearSay(Agent.java:37)
        at yab.agent.Agent.run(Agent.java:74)
Action:HC266268660 hear() :(264179229) say :help_me
java.lang.NullPointerException
        at
yab.agent.object.MovingObject.motionlessPosition(MovingObject.java:29)
        at
sample.HelperCivilianAgent.hear(HelperCivilianAgent.java:143)
        at yab.agent.Agent.hearSay(Agent.java:37)
        at yab.agent.Agent.run(Agent.java:74)

You will find the function definitions toward the end
of the message.

The check ascertains that the local DisasterSpace
contains the sender object (pls see getAgentByID()
function). When either sender.motionlessPosition() or
mo.motionlessPosition() was called, I got a
NullPointerException.

I need to know if those errors are direct cause due to
my custom agent or the errors are intended behavior of
the RCR system.

Thank you so much for your attention.

Raymond U

CODE
=======

    protected void hear(RealObject sender, String
message) {
        // do nothing
        if (self().hp() == 0) {
                super.hear(sender, message);
                return;
        }

        System.err.println("Action:HC"+self().id+" hear()
:("+sender.id+") say :"+message);

        if (message.equals("help_me")) {
                MovingObject mo = getAgentByID(sender.id);
                if (mo != null)
                        lstPosNeedsHelp.add(mo.motionlessPosition());
                else
                        System.out.println("Debug hear: the agent is
unknown");
        }
        super.hear(sender, message);
    }

    protected MovingObject getAgentByID(int id) {
        RealObject ro = world.get(id);
        if (ro instanceof MovingObject)
                return (MovingObject) ro;
        else
                return null;
    }

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
robocup-rescue-s mailing list
robocup-rescue-s@mailman.cc.gatech.edu
https://mailman.cc.gatech.edu/mailman/listinfo/robocup-rescue-s

_______________________________________________
robocup-rescue-s mailing list
robocup-rescue-s@mailman.cc.gatech.edu
https://mailman.cc.gatech.edu/mailman/listinfo/robocup-rescue-s



This archive was generated by hypermail 2.1.3 : Thu 17 Feb 2005 - 13:45:21 GMT