Exemplo n.º 1
0
shared_ptr<ActionObject> HingeEffector::GetActionObject(const Predicate& predicate)
{
    for(;;)
        {
            if (mJoint.get() == 0)
                {
                    break;
                }

            if (predicate.name != GetPredicate())
                {
                    GetLog()->Error()
                        << "ERROR: (HingeEffector) invalid predicate"
                        << predicate.name << "\n";
                    break;
                }

            Predicate::Iterator iter = predicate.begin();

            float velocity;
            if (! predicate.AdvanceValue(iter, velocity))
                {
                    GetLog()->Error()
                        << "ERROR: (HingeEffector) motor velocity expected\n";
                    break;
                }

            return shared_ptr<HingeAction>(new HingeAction(GetPredicate(),velocity));
        }

    return shared_ptr<ActionObject>();
}
Exemplo n.º 2
0
boost::shared_ptr<ActionObject>
SayEffector::GetActionObject(const Predicate& predicate)
{
    if (predicate.name != GetPredicate())
    {
        GetLog()->Error() << "ERROR: (SayEffector) invalid predicate"
                          << predicate.name << "\n";

        // some error happened
        return boost::shared_ptr<ActionObject>();
    }

    Predicate::Iterator iter = predicate.begin();

    std::string message;
    if (! predicate.AdvanceValue(iter, message))
    {
        GetLog()->Error()
            << "ERROR: (SayEffector) said message expected\n";

        // some error happened
        return boost::shared_ptr<ActionObject>();
    }

    // construct the SayAction object
    return boost::shared_ptr<SayAction>(new SayAction(GetPredicate(), message));

}
Exemplo n.º 3
0
boost::shared_ptr<ActionObject>
SceneEffector::GetActionObject(const Predicate& predicate)
{
    if (predicate.name != GetPredicate())
        {
            GetLog()->Error() << "(SceneEffector) ERROR: invalid predicate"
                              << predicate.name << "\n";
            return boost::shared_ptr<ActionObject>();
        }

    string scene;
    if (! predicate.GetValue(predicate.begin(), scene))
        {
            GetLog()->Error()
                << "ERROR: (SceneEffector) scene filename expected\n";
            return boost::shared_ptr<ActionObject>();
        };

    boost::shared_ptr<ParameterList> parameters(
        new ParameterList(predicate.parameter));
    parameters->Pop_Front();

    return boost::shared_ptr<ActionObject>(
        new SceneAction(GetPredicate(), scene, parameters));
}
Exemplo n.º 4
0
shared_ptr<ActionObject>
PanTiltEffector::GetActionObject(const Predicate& predicate)
{
    if (predicate.name != GetPredicate())
    {
        GetLog()->Error() << "ERROR: (PanTiltEffector) invalid predicate"
                          << predicate.name << "\n";
        return shared_ptr<ActionObject>();
    }

    Predicate::Iterator iter = predicate.begin();

    float pan;
    if (! predicate.AdvanceValue(iter, pan))
    {
        GetLog()->Error() << "ERROR: (PanTiltEffector) 2 float parameters expected\n";
        return shared_ptr<ActionObject>(new ActionObject(GetPredicate()));
    }
    float tilt;
    if (! predicate.AdvanceValue(iter, tilt))
    {
        GetLog()->Error() << "ERROR: (PanTiltEffector) float parameter expected\n";
        return shared_ptr<ActionObject>(new ActionObject(GetPredicate()));
    }
    return shared_ptr<ActionObject>(new PanTiltAction(GetPredicate(),pan,tilt));
}
Exemplo n.º 5
0
boost::shared_ptr<ActionObject>
InitEffector::GetActionObject(const Predicate& predicate)
{
    if (predicate.name != GetPredicate())
    {
        GetLog()->Error() << "ERROR: (InitEffector) invalid predicate"
                          << predicate.name << "\n";
        return boost::shared_ptr<ActionObject>();
    }

    std::string name;
    predicate.GetValue(predicate.begin(),"teamname",name);

    int unum = 0;
    predicate.GetValue(predicate.begin(),"unum",unum);

    return boost::shared_ptr<ActionObject>(new InitAction(GetPredicate(),name,unum));
}
Exemplo n.º 6
0
boost::shared_ptr<ActionObject>
DriveEffector::GetActionObject(const Predicate& predicate)
{
  if (predicate.name != GetPredicate())
    {
      GetLog()->Error() << "ERROR: (DriveEffector) invalid predicate"
                        << predicate.name << "\n";
      return boost::shared_ptr<ActionObject>();
    }

  Vector3f force;
  if (! predicate.GetValue(predicate.begin(), force))
  {
      GetLog()->Error()
          << "ERROR: (DriveEffector) Vector3f parameter expected\n";
      return boost::shared_ptr<ActionObject>(new ActionObject(GetPredicate()));
  }

  return boost::shared_ptr<ActionObject>(new DriveAction(GetPredicate(),force));
}
Exemplo n.º 7
0
shared_ptr<ActionObject>
KickEffector::GetActionObject(const Predicate& predicate)
{
  do
  {
      if (predicate.name != GetPredicate())
          {
              GetLog()->Error() << "ERROR: (KickEffector) invalid predicate"
                                << predicate.name << "\n";
              break;
          }

      Predicate::Iterator iter = predicate.begin();

      float angle;
      if (! predicate.AdvanceValue(iter, angle))
      {
          GetLog()->Error()
              << "ERROR: (KickEffector) kick angle parameter expected\n";
          break;
      }

      float power;
      if (! predicate.AdvanceValue(iter, power))
          {
              GetLog()->Error()
                  << "ERROR: (KickEffector) kick power expected\n";
              break;
          }

      // construct the KickAction object
      return shared_ptr<KickAction>(new KickAction(GetPredicate(),angle,power));

  } while (0);

  // some error happened
  return shared_ptr<ActionObject>();
}
Exemplo n.º 8
0
boost::shared_ptr<ActionObject>
BeamEffector::GetActionObject(const Predicate& predicate)
{
  if (predicate.name != GetPredicate())
    {
      GetLog()->Error() << "ERROR: (BeamEffector) invalid predicate"
                        << predicate.name << "\n";
      return boost::shared_ptr<ActionObject>();
    }

  Predicate::Iterator iter = predicate.begin();

  float posX;
  if (! predicate.AdvanceValue(iter, posX))
  {
      GetLog()->Error()
          << "ERROR: (BeamEffector) float expected for parameter1\n";
      return boost::shared_ptr<ActionObject>(new ActionObject(GetPredicate()));
  }

  float posY;
  if (! predicate.AdvanceValue(iter, posY))
  {
      GetLog()->Error()
          << "ERROR: (BeamEffector) float expected for parameter2\n";
      return boost::shared_ptr<ActionObject>(new ActionObject(GetPredicate()));
  }

  float angle;
  if (! predicate.AdvanceValue(iter, angle))
  {
      GetLog()->Error()
          << "ERROR: (BeamEffector) float expected for parameter3\n";
      return boost::shared_ptr<ActionObject>(new ActionObject(GetPredicate()));
  }

  return boost::shared_ptr<ActionObject>(new BeamAction(GetPredicate(), posX, posY, angle));
}
Exemplo n.º 9
0
shared_ptr<ActionObject> HMDPEffector::GetActionObject(const Predicate& predicate)
{
         //std::cout << " GetActionObject called " << std::endl;
    if (predicate.name != GetPredicate())
    {
        GetLog()->Error() << "ERROR: (HMDPEffector) invalid predicate"
                << predicate.name << "\n";
        return shared_ptr<ActionObject>();
    }

    std::string message;

    if (!predicate.GetValue(predicate.begin(), message))
    {
        GetLog()->Error()
                << "ERROR: (HMDPEffector) Some Problem while receiving the HMDP Message\n";
        return shared_ptr<ActionObject>();
    };

    inMessage = inMessage + message + "\r\n";

    //std::cout << inMessage << std::endl;
    return shared_ptr<ActionObject>(new HMDPAction(GetPredicate(), inMessage));
}