RTT::base::InputPortInterface*  Task::createInputPort(::std::string const & port_name, ::std::string const & type_name){
	RTT::base::PortInterface *pi = getPort(port_name);

	if(pi){
			// Port exists. Returns success.
			log(Info) << "Port " << port_name << " is already registered." << endlog();
			return 0;
	}

	RTT::types::TypeInfo* type = getType(type_name);

	if (!type){
		return NULL;
	}

	/* Create input port */
	RTT::base::InputPortInterface *in_port = type->inputPort(port_name);
	if (!in_port)
	{
			log(Error) << "An error occurred during input port generation." << endlog();
			return NULL;
	}
	ports()->addEventPort(in_port->getName(), *(in_port) );

	return in_port;
}
orogen_transports::TypelibMarshallerBase* orogen_transports::getMarshallerFor(std::string const& type)
{
    RTT::types::TypeInfoRepository::shared_ptr type_registry =
        RTT::types::TypeInfoRepository::Instance();
    RTT::types::TypeInfo* ti = type_registry->type(type);
    if (!ti)
    {
	// Try harder. Some base types don't have a
	// typelib-normalized name, so we should look
	// for the type without the leading slash
	ti = type_registry->type(type.substr(1));
	if (!ti)
	    throw std::runtime_error("type " + type + " is not registered in the RTT type system");
    }

    if (!ti->hasProtocol(orogen_transports::TYPELIB_MARSHALLER_ID))
        throw std::runtime_error("type " + type + " is registered in the RTT type system, but does not have a typelib transport");

    orogen_transports::TypelibMarshallerBase* typelib_marshaller =
        dynamic_cast<orogen_transports::TypelibMarshallerBase*>(ti->getProtocol(orogen_transports::TYPELIB_MARSHALLER_ID));
    if (!typelib_marshaller)
        throw std::runtime_error("the transport object registered as typelib transport for type " + type + " is not a TypelibMarshallerBase");

    return typelib_marshaller;
}
void loadTorquesType() {
    const std::string NAME("rstrt.dynamics.Torques");

    RTT::types::TypeInfoRepository::shared_ptr repository = RTT::types::Types();

    repository->addType(new RTT::types::StructTypeInfo<rstrt::dynamics::Torques,
                                                       true>
                        (NAME));
    RTT::types::TypeInfo* typeInfo = repository->type(NAME);
    typeInfo->addConstructor(RTT::types::newConstructor(&createTorques_Values));

    repository->addType(
        new RTT::types::SequenceTypeInfo<std::vector<rstrt::dynamics::Torques> >
        (NAME + "[]"));
}
Exemple #4
0
void loadTwistType() {
	const std::string NAME("rstrt.kinematics.Twist");

	RTT::types::TypeInfoRepository::shared_ptr repository = RTT::types::Types();

	repository->addType(
			new RTT::types::StructTypeInfo<rstrt::kinematics::Twist, true>(
					NAME));
	RTT::types::TypeInfo* typeInfo = repository->type(NAME);
	typeInfo->addConstructor(RTT::types::newConstructor(&createTwist_Values));

	typeInfo->addConstructor(
			RTT::types::newConstructor(&createTwist_NestedTypes));

	repository->addType(
			new RTT::types::SequenceTypeInfo<
					std::vector<rstrt::kinematics::Twist> >(NAME + "[]"));
}
Exemple #5
0
bool Logger::createLoggingPort(const std::string& portname, const std::string& typestr, std::vector<logger::StreamMetadata> const& metadata)
{
    RTT::types::TypeInfoRepository::shared_ptr ti = RTT::types::TypeInfoRepository::Instance();
    RTT::types::TypeInfo* type = ti->type(typestr);
    if (! type)
    {
	cerr << "cannot find " << typestr << " in the type info repository" << endl;
	return false;
    }
    
    RTT::base::PortInterface *pi = ports()->getPort(portname);
    if(pi) {
	cerr << "port with name " << portname << " already exists" << endl;
	return false;
    }

    RTT::base::InputPortInterface *ip= type->inputPort(portname);
    return addLoggingPort(ip, portname, metadata);
}