本文整理汇总了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();
}
示例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();
}
示例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");
}
示例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);
}
示例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();
}
示例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();
}
}
示例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();
}
}
示例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();
}
}