当前位置: 首页>>代码示例>>Java>>正文


Java Application.session方法代码示例

本文整理汇总了Java中com.aldebaran.qi.Application.session方法的典型用法代码示例。如果您正苦于以下问题:Java Application.session方法的具体用法?Java Application.session怎么用?Java Application.session使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.aldebaran.qi.Application的用法示例。


在下文中一共展示了Application.session方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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.session方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。