Exemple #1
0
int main(int argc, char** argv)
{
  std::string robotName;  // = "valkyrie";  // "atlas"

  if (argc >= 2)
  {
    ROS_ERROR("Robot Name: %s", argv[1]);
    robotName = argv[1];
  }
  else
  {
    ROS_ERROR("Need to have an argument: robot name");
    exit(-1);
  }

  ros::init(argc, argv, "lcm2ros", ros::init_options::NoSigintHandler);
  boost::shared_ptr<lcm::LCM> lcm(new lcm::LCM);
  if (!lcm->good())
  {
    std::cerr << "ERROR: lcm is not good()" << std::endl;
  }
  ros::NodeHandle nh;

  LCM2ROS handlerObject(lcm, nh, robotName);
  ROS_ERROR("LCM2ROS IHMC Translator Ready [robotName: %s]", robotName.c_str());

  while (0 == lcm->handle())
  {
  }

  return 0;
}
	void HTTPClientBinding::Receive(const ValueList& args, KValueRef result)
	{
		args.VerifyException("receive", "m|o ?s|o|0");

		// Set output handler
		this->outstream = 0;
		result->SetBool(false);

		if (args.at(0)->IsMethod())
		{
			this->outputHandler = args.at(0)->ToMethod();
		}
		else if (args.at(0)->IsObject())
		{
			KObjectRef handlerObject(args.at(0)->ToObject());
			KMethodRef writeMethod(handlerObject->GetMethod("write", 0));
			if (writeMethod.isNull())
			{
				logger->Error("Unsupported object type as output handler:"
					" does not have write method");
			}
			else
			{
				this->outputHandler = writeMethod;
			}
		}
		else
		{
			logger->Error("Invalid type as output handler!");
			return;
		}

		// Get the send data if provided
		KValueRef sendData(args.GetValue(1));
		result->SetBool(this->BeginRequest(sendData));
	}