virtual bool initialize(SimpleControllerIO* io) override
	{
		ostream& os = io->os();
		Body* body = io->body();
		root = io->body()->rootLink();

		thrusts << body->devices();

		DeviceList<Light> lights(body->devices());

		if(!lights.empty()){
			light = lights.front();

		}

		prevLightButtonState = false;

		if(!joystick.isReady()){
			os << "Joystick is not ready: " << joystick.errorMessage() << endl;

		}

		if(joystick.numAxes() < 5){
			os << "The number of the joystick axes is not sufficient for controlling the robot." << endl;

		}

		if(joystick.numButtons() < 1){
			os << "The number of the joystick buttons is not sufficient for controlling the robot." << endl;

		}

		return true;

	}
Beispiel #2
0
void Body::copy(const Body& org)
{
    initialize();

    impl->centerOfMass = org.impl->centerOfMass;
    impl->mass = org.impl->mass;
    impl->name = org.impl->name;
    impl->modelName = org.impl->modelName;
    impl->info = org.impl->info;

    setRootLink(cloneLinkTree(org.rootLink()));

    // deep copy of the devices
    const DeviceList<>& orgDevices = org.devices();
    for(size_t i=0; i < orgDevices.size(); ++i){
        const Device& orgDevice = *orgDevices[i];
        Device* device = orgDevice.clone();
        device->setLink(link(orgDevice.link()->index()));
        addDevice(device);
    }

    // deep copy of the extraJoints
    for(size_t i=0; i < org.extraJoints_.size(); ++i){
        const ExtraJoint& orgExtraJoint = org.extraJoints_[i];
        ExtraJoint extraJoint(orgExtraJoint);
        for(int j=0; j < 2; ++j){
            extraJoint.link[j] = link(orgExtraJoint.link[j]->index());
        }
        extraJoints_.push_back(extraJoint);
    }

    if(org.impl->customizerInterface){
        installCustomizer(org.impl->customizerInterface);
    }
}