當前位置: 首頁>>代碼示例>>Java>>正文


Java Application類代碼示例

本文整理匯總了Java中com.aldebaran.qi.Application的典型用法代碼示例。如果您正苦於以下問題:Java Application類的具體用法?Java Application怎麽用?Java Application使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Application類屬於com.aldebaran.qi包,在下文中一共展示了Application類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import com.aldebaran.qi.Application; //導入依賴的package包/類
public void run(String[] args) throws Exception {
	String url = "tcp://nao.local:9559";
	if (args.length == 1) {
		url = args[0];
	}
	String[] appArgs = { "--qi-url", url };
	Application application = new Application(appArgs);
	Session session = new Session();
	Future<Void> fut = session.connect(url);
	fut.get(1, TimeUnit.SECONDS);
	tts = session.service("ALTextToSpeech").get();
	callback = new CallBack(tts);
	memory = session.service("ALMemory").get();
	AnyObject subscriber = (AnyObject) memory.call("subscriber",
			"FrontTactilTouched").get();
	subscriber.connect("signal::(m)", "onTouch::(m)", callback);
	application.run();

}
 
開發者ID:aldebaran,項目名稱:libqi-java,代碼行數:20,代碼來源:ReactToEvents.java

示例2: main

import com.aldebaran.qi.Application; //導入依賴的package包/類
public static void main(String[] args) throws Exception {

        String robotUrl = "tcp://nao.local:9559";
        // Create a new application
        Application application = new Application(args, robotUrl);
        // Start your application
        application.start();
        System.out.println("Successfully connected to the robot");
        // Subscribe to selected ALMemory events
        ReactToEvents reactor = new ReactToEvents();
        reactor.run(application.session());
        System.out
                .println("Subscribed to FrontTactilTouched and RearTactilTouched.");
        // Run your application
        application.run();

    }
 
開發者ID:aldebaran,項目名稱:jnaoqi,代碼行數:18,代碼來源:ReactToEvents.java

示例3: notify

import com.aldebaran.qi.Application; //導入依賴的package包/類
@Override
public void notify(DelegateExecution delegateExecution) throws Exception {

    NaoConnection connection = new NaoConnection();

    String naoip = (String) delegateExecution.getVariable("naoip");

    String robotUrl = "tcp://" + naoip + ":9559";
    System.out.println(robotUrl);
    NaoConnection.app = new Application(new String[]{}, robotUrl);
    NaoConnection.app.start(); // will throw if connection fails

    System.out.println("Successfully connected to the robot");
}
 
開發者ID:umb,項目名稱:hackathon2017-bringing-nao-to-life,代碼行數:15,代碼來源:NaoStartAppListener.java

示例4: onCreate

import com.aldebaran.qi.Application; //導入依賴的package包/類
/**
 * Called when the activity is first created.
 * @param savedInstanceState If the activity is being re-initialized after
 * previously being shut down then this Bundle contains the data it most
 * recently supplied in onSaveInstanceState(Bundle). <b>Note: Otherwise it is null.</b>
 */
@Override
public void onCreate(Bundle savedInstanceState)
{
  super.onCreate(savedInstanceState);
  Log.i(TAG, "onCreate");
  setContentView(R.layout.main);

  app = new Application(null);
}
 
開發者ID:aldebaran,項目名稱:libqi-java,代碼行數:16,代碼來源:HelloAndroidActivity.java

示例5: main

import com.aldebaran.qi.Application; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
    String robotUrl = "tcp://nao.local:9559";

    // Create a new application
    Application application = new Application(args, robotUrl);

    // Create an instance of your service
    QiService service = new HelloService();

    // Create a DynamicObjectBuilder, that will render your service
    // compatible with other supported languages.
    DynamicObjectBuilder objectBuilder = new DynamicObjectBuilder();
    service.init(objectBuilder.object());

    // Advertise the greet method contained in your HelloService service.
    // You need to specify its signature.
    objectBuilder.advertiseMethod("greet::s(s)", service,
            "Greets the caller");

    // Start your application
    application.start();

    // Retrieve the created session
    Session session = application.session();

    // Register your service in your session
    session.registerService("MyHelloService", objectBuilder.object());

    // Run your application
    application.run();
}
 
開發者ID:aldebaran,項目名稱:jnaoqi,代碼行數:32,代碼來源:MyApplication.java

示例6: main

import com.aldebaran.qi.Application; //導入依賴的package包/類
public static void main(String[] args) {
    APP_NAME += System.currentTimeMillis();
    // Connect to the robot
    application = new Application(args, RobotInfo.URL);

    try {
        System.out.printf("Connect to " + RobotInfo.PORT);
        application.start();
        tts = new ALTextToSpeech(application.session());
        alMemory = new ALMemory(application.session());
        motion = new ALMotion(application.session());
        alAnimatedSpeech = new ALAnimatedSpeech(application.session());
        awareness = new ALBasicAwareness(application.session());
        alSpeechRecognition = new ALSpeechRecognition(application.session());
        alAudioPlayer = new ALAudioPlayer(application.session());

        alMemory.subscribeToEvent("RearTactilTouched",
                new EventCallback<Float>() {

                    @Override
                    public void onEvent(Float value)
                            throws InterruptedException, CallError {
                        System.out.println(APP_NAME + " : Touch " + value);
                        if (value == 1.0) {
                            stateMachine(STEP_END);
                        }
                    }
                });
        stateMachine(STEP_STARTUP);
        application.run();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:aldebaran,項目名稱:jnaoqi,代碼行數:35,代碼來源:ExScenar1.java

示例7: main

import com.aldebaran.qi.Application; //導入依賴的package包/類
public static void main(String[] args) {
      String robotUrl = "tcp://" + RobotInfo.IP + ":" + RobotInfo.PORT;
Application application = new Application(args, robotUrl);
      try {
          application.start();

       ALMemory alMemory = new ALMemory(application.session());
          tts = new ALTextToSpeech(application.session());

       alMemory.subscribeToEvent("FrontTactilTouched", touch -> {
        if ((float) touch == 1.0) {
	        tts.say("Front");
        }
       });
          alMemory.subscribeToEvent("MiddleTactilTouched", touch -> {
           if ((float) touch == 1.0) {
            tts.say("Middle");
           }
          });
          alMemory.subscribeToEvent("RearTactilTouched", touch -> {
           if ((float) touch == 1.0) {
            tts.say("Rear");
           }
          });;
          alMemory.subscribeToEvent("LeftBumperPressed", touch -> {
           if ((float) touch == 1.0) {
            tts.say("Left bumper");
           }
          });
          alMemory.subscribeToEvent("RightBumperPressed", touch -> {
           if ((float) touch == 1.0) {
            tts.say("Right bumper");
           }
          });

          tts.say("I am ready");
          application.run();
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
 
開發者ID:aldebaran,項目名稱:jnaoqi,代碼行數:42,代碼來源:ExReactToTouch.java

示例8: main

import com.aldebaran.qi.Application; //導入依賴的package包/類
public static void main(String[] args) {

        application = new Application(args, RobotInfo.URL);

        try {
            application.start();

            alMemory = new ALMemory(application.session());
            motion = new ALMotion(application.session());
            alSpeechRecognition = new ALSpeechRecognition(application.session());
            tts = new ALTextToSpeech(application.session());

            ArrayList<String> listOfWords = new ArrayList<String>();
            listOfWords.add("wake up");
            listOfWords.add("come");
            listOfWords.add("stop");

            alSpeechRecognition.setVocabulary(listOfWords, false);

            alSpeechRecognition.subscribe(APP_NAME);
            alMemory.subscribeToEvent("WordRecognized",
                    new EventCallback<List<Object>>() {

                        @Override
                        public void onEvent(List<Object> words)
                                throws InterruptedException, CallError {
                            String word = (String) words.get(0);
                            System.out.println("Word " + word);

                            if (word.equals("wake") && !isAwake) {
                                tts.say("hi");
                                alSpeechRecognition.pause(true);
                                motion.wakeUp();
                                alSpeechRecognition.pause(false);
                                isAwake = true;
                            } else if (word.equals("come") && isAwake) {
                                motion.moveToward(0.6f, 0f, 0f);
                            } else if (word.equals("stop") && isAwake) {
                                motion.moveToward(0f, 0f, 0f);
                            }
                        }
                    });
            alMemory.subscribeToEvent("MiddleTactilTouched",
                    new EventCallback<Float>() {

                        @Override
                        public void onEvent(Float touch)
                                throws InterruptedException, CallError {
                            if (touch == 1.0) {
                                tts.say("Application is stopping");
                                motion.rest();
                                alSpeechRecognition.unsubscribe(APP_NAME);
                                application.stop();

                            }
                        }
                    });
            application.run();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
開發者ID:aldebaran,項目名稱:jnaoqi,代碼行數:63,代碼來源:ExReactToVoice.java


注:本文中的com.aldebaran.qi.Application類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。