We have summarized the flow of development and registration of Sota-kun application using Java. The source for the app created in this article can be found on GitHub.
In this article, we have developed an application for Intel (R) Edison version Sota (developer version).
In the official documentation, there are two ways to develop the Sota app:
-[Try using VstoneMagic](http://www.vstone.co.jp/sotamanual/index.php?VstoneMagic%E3%82%92%E4%BD%BF%E3%81%A3%E3%81 % A6% E3% 81% BF% E3% 82% 8B) -[Try programming with Java](http://www.vstone.co.jp/sotamanual/index.php?Java%E3%81%A7%E3%83%97%E3%83%AD%E3 % 82% B0% E3% 83% A9% E3% 83% 9F% E3% 83% B3% E3% 82% B0% E3% 82% 92% E3% 81% 97% E3% 81% A6% E3% 81 % BF% E3% 82% 8B)
VstoneMagic is a programming software for Sota that develops apps by connecting pre-prepared instruction blocks. As an advantage of VstoneMagic, how to register the application is written in the official document, and you can execute the application created from "Run application" just by operating Sota itself. However, there are restrictions on application development due to the specifications that connect instruction blocks. Therefore, in this article, we will develop an application in Java. The registration method of the application developed in Java is not written in the official document, so I will explain the method below.
First of all, [Try programming with Java](http://www.vstone.co.jp/sotamanual/index.php?Java%E3%81%A7%E3%83%97%E3%83%] AD% E3% 82% B0% E3% 83% A9% E3% 83% 9F% E3% 83% B3% E3% 82% B0% E3% 82% 92% E3% 81% 97% E3% 81% A6% Follow E3% 81% BF% E3% 82% 8B) to execute the sample program.
In the following, we will explain assuming that you have Eclipse as the development environment and SotaSample
as the sample program project.
From here, we will develop applications in Java.
In this article, Sota will develop an app that recognizes what you say and returns it to you.
It is the same as SpeechRecSample.java
in SotaSample
.
First, create a new project from "File"-> "New"-> "Java Project". The project name should be SotaRepeat
. By the way, when managing with GitHub, I think that GitHub and Eclipse cooperation and summary --Qiita will be helpful.
After creating a new project, right-click on the src folder → "New" → "Package" to create a package. I named the package com.example.sotarepeat
(I don't know how to name the package).
Right-click on the package name → "New" → "Class" to create the main Java file SotaRepeat.java
and implement it. The flow of the application is as follows.
The implemented SotaRepeat.java
is listed below.
SotaRepeat.java
/* SotaRepeat.java
*An application that returns the voice recognition result with TTS
*/
package com.example.sotarepeat;
import jp.vstone.RobotLib.CPlayWave;
import jp.vstone.RobotLib.CRobotMem;
import jp.vstone.RobotLib.CSotaMotion;
import jp.vstone.sotatalk.MotionAsSotaWish;
import jp.vstone.sotatalk.SpeechRecog;
import jp.vstone.sotatalk.SpeechRecog.RecogResult;
import jp.vstone.sotatalk.TextToSpeechSota;
public class SotaRepeat {
static final String TAG = "SotaRepeat";
static final int LOOP_NUM = 10;
public static void main(String[] args) {
//VSMD and communication socket / memory access class
CRobotMem mem = new CRobotMem();
//Motion control class for Sota
CSotaMotion motion = new CSotaMotion(mem);
SpeechRecog recog = new SpeechRecog(motion);
MotionAsSotaWish wish = new MotionAsSotaWish(motion);
if (mem.Connect()) {
//Initialize VSMD to Sota spec
motion.InitRobot_Sota();
motion.ServoOn();
for (int i=0; i<LOOP_NUM; i++) {
//Voice recognition (supports voice up to 10 seconds)
RecogResult result = recog.getRecognition(10000);
if (result.recognized) {
//TextToSpeech the recognition result
wish.Say(result.getBasicResult(), MotionAsSotaWish.MOTION_TYPE_TALK);
//CPlayWave.PlayWave(TextToSpeechSota.getTTSFile(result.getBasicResult()),true);
if(result.getBasicResult().contains("end")){
CPlayWave.PlayWave(TextToSpeechSota.getTTSFile("I'm done"),true);
break;
}
}
if (i == LOOP_NUM - 1) {
CPlayWave.PlayWave(TextToSpeechSota.getTTSFile("I'm tired so I'm done"), true);
}
}
motion.ServoOff();
}
}
}
If Eclipse gets angry that there is no such thing in the place to import jp.vstone.RobotLib.CPlayWave
etc., right click on SotaRepeat
→ "Build Path" → "External Archive" From "Add", specify sotalib.jar
in the lib
folder in SotaSample
.
Create a jar file to register the developed application in Sota.
First, right-click on SotaRepeat
→ select "Export" → "JAR File".
Make sure that SotaRepeat is checked on the "JAR Export" screen, specify the jar file to export to, and click "Next".
Leave the default settings for "JAR Package Options" and click "Next".
For "JAR Manifest Specifications", check "Save Manifest in Workspace" as shown in the screen below, and specify the manifest file name. Also, specify SotaRepeat
as the main class. And "done".
Next, edit the created MANIFEST.MF
. If it is left as it is, the classpath is not described, so an error will occur when the application is executed.
If you created a manifest file like the image above, you should see MANIFEST.MF
look like this:
MANIFEST.MF
Manifest-Version: 1.0
Sealed: true
Main-Class: com.example.sotarepeat.SotaRepeat
Add the following description here.
Class-Path: . /home/vstone/lib/core-2.2.jar /home/vstone/lib/javase-2.2.jar /home/vstone/lib/jna-4.1.0.jar /home/vstone/lib/opencv-310.jar /home/vstone/lib/sotalib.jar /home/vstone/lib/SRClientHelper.jar /home/vstone/lib/gson-2.6.1.jar
It may be unnecessary because it is added to the classpath indiscriminately, but the miso is adding / home / vstone / lib / gson-2.6.1.jar
. I didn't write it at first because it is not included in the lib
folder of SotaSample
, but when I ran it on the Sota console, I got an error saying that gson was needed, so I added it.
Use this manifest file to create a new jar file. Create a jar file in the same way as before, but in the "JAR manifest specification", check "Use existing manifest in workspace" as shown below. And "done".
Transfer the created jar file to Sota. For the flow from here, How to register your own jar in Sota --Qiita was very helpful. What is written is basically the same.
In my environment, I am connected to Sota via wireless LAN, so I will transfer using WinSCP.
Create a SotaRepeat
directory under / home / vstone / vstonemagic / app / jar
in Sota, and put the created jar file in it.
The program to be executed from "Run App" of Sota is described in the configuration file / home / vstone / vstonemagic / app / jar / app.properties
. Rewrite this configuration file as follows.
app.properties
length=1 #Number of apps
Debug=false
TimeZone=Asia/Tokyo
app1.title=SotaRepeat
app1.workingdir=SotaRepeat/
app1.jar=SotaRepeat.jar
app1.type=app
app1.trigger=
app1.triggeroption=
Make sure the value of length
matches the number of apps. Also, if you develop a new app, add it as `ʻapp2.title = hogehoge``.
Now that registration is complete, restart Sota.
After restarting, you can run the developed app by pressing the button on the back and selecting "Setting mode" → "Run app".
-GitHub and Eclipse cooperation and summary --Qiita -How to register your own jar in Sota-Qiita