Commit 4f59331d authored by Dimosthenis Kitisos's avatar Dimosthenis Kitisos

Initial Commit

parent 397da096
Ο χρήστης ανοίγει το διάγραμμα Sirius και επιλέγει αρχικά ένα στοιχείο Start ως αφετερία των διεργασιών που θέλει το ρομπότ να πραγματοποιήσει.
Στη συνέχεια, επιλέγει οποιοδήποτε επόμενο στοιχείο, συμπληρώνει τις παραμέτρους που του δίνονται στα Properties των στοιχείων και δημιουργεί
την μετάβαση (Transition) από το στοιχείο Start στο επόμενο στοιχείο.
Η διαδικασία αυτή επαναλαμβάνεται έως ότου επιλεχθεί το στοιχείο End που σημαίνει το πέρας του διαγράμματος.
Ο χρήστης πρέπει να εισάγει μόνο ένα στοιχείο Start και ένα μόνο στοιχείο End.
Ο χρήστης πρέπει να συνδέσει με μετάβαση όλα τα στοιχεία.
Ο χρήστης πρέπει να συμπληρώσει όλες τις απαραίτητες παραμέτρους για να επικυρωθεί (validate) το διάγραμμα.
Έπειτα, ο χρήστης μπορεί να μεταβεί στο Acceleo project και συγκεκριμένα στο αρχείο generate.mtl όπου τρέχοντας το (run as Launch Acceleo Application),
με τη σωστή διαμόρφωση, εμφανίζεται ο κώδικας γλώσσας προγραμματισμού Python (αρχείο code.py) στο φάκελο Destination_Folder του ίδιου Project.
Ο κώδικας αυτός είναι έτοιμος προς χρήση στο ρομπότ Nao.
\ No newline at end of file
# 2018_Dimosthenis_Kitsios_Symeonidis
Το project "org.eclipse.sirius.sample.nao" περιέχει το Emf Metamodel του συστήματος με όνομα "nao.ecore".
Με Generate All στο "nao.genmodel" εμφανίζονται τα αρχεία org.eclipse.sirius.sample.nao.edit/editor/tests.
Το project "org.eclipse.sirius.nao.design" είναι το Viewpoint specification model. Το nao.design περιέχει τα nodes, τα relations και τα validation rules
του διαγράμματος Sirius.
Το project "org.eclipse.sirius.sample.nao.sample" περιέχει το My.Nao που είναι το διάγραμμα του Sirius που ο χρήστης δημιουργεί.
Το project "org.eclipse.acceleo.module.sample" περιλαμβάνει το .mtl αρχείο generate.mtl όπου βρίσκεται ο κώδικας Acceleo που παράγει τον τελικό
Python Κώδικα στο Destination_folder.
To αρχείο NaoUpdateSite.zip είναι το Plug-in του Sirius για να μην χρειάζονται δύο στιγμιότυπα Eclipse.
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="nao" nsURI="http://www.example.org/sirius/sample/nao" nsPrefix="nao">
<eClassifiers xsi:type="ecore:EClass" name="Nao">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="function" upperBound="-1"
eType="#//Function" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Function" abstract="true">
<eStructuralFeatures xsi:type="ecore:EReference" name="NextTransition" eType="#//Function"
eOpposite="#//Function/PreviousTransition"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="PreviousTransition" eType="#//Function"
eOpposite="#//Function/NextTransition"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="speak" eType="#//Speak"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="takephoto" eType="#//TakePhoto"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="end" eType="#//End"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="start" eType="#//Start"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="setvolume" eType="#//SetVolume"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="sit" eType="#//Sit"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="record" eType="#//Record"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="stand" eType="#//Stand"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="batterylevels" eType="#//BatteryLevels"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="tellajoke" eType="#//TellAJoke"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="stop" eType="#//Stop"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="moveto" eType="#//MoveTo"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="dance" eType="#//Dance"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="playfile" eType="#//PlayFile"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="tactilemeasurements" eType="#//TactileMeasurements"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="speechdetection" eType="#//SpeechDetection"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="MoveTo" eSuperTypes="#//Function">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="x" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EFloat"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="y" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EFloat"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="theta" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EFloat"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Speak" eSuperTypes="#//Function">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="text" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="language" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Stop" eSuperTypes="#//Function"/>
<eClassifiers xsi:type="ecore:EClass" name="Dance" eSuperTypes="#//Function">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="hand_name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="angles" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="speed" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EFloat"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="joints" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Sit" eSuperTypes="#//Function"/>
<eClassifiers xsi:type="ecore:EClass" name="Stand" eSuperTypes="#//Function"/>
<eClassifiers xsi:type="ecore:EClass" name="Record" eSuperTypes="#//Function">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="filename" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="seconds" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="TakePhoto" eSuperTypes="#//Function">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="filepath" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="cameraId" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="resolution" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="TellAJoke" eSuperTypes="#//Function">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="text" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="language" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="SetVolume" eSuperTypes="#//Function">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="volume" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="BatteryLevels" eSuperTypes="#//Function"/>
<eClassifiers xsi:type="ecore:EClass" name="Start" eSuperTypes="#//Function"/>
<eClassifiers xsi:type="ecore:EClass" name="End" eSuperTypes="#//Function"/>
<eClassifiers xsi:type="ecore:EClass" name="PlayFile" eSuperTypes="#//Function">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="filename" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="TactileMeasurements" eSuperTypes="#//Function">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="wait" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EFloat"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="get_history" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="SpeechDetection" eSuperTypes="#//Function">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="wait" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EFloat"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="vocabulary" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="language" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
</ecore:EPackage>
<?xml version="1.0" encoding="UTF-8"?>
<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/org.eclipse.sirius.sample.nao/src" creationIcons="false"
modelPluginID="org.eclipse.sirius.sample.nao" modelName="Nao" rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container"
importerID="org.eclipse.emf.importer.ecore" complianceLevel="8.0" copyrightFields="false"
operationReflection="true" importOrganizing="true">
<foreignModel>nao.ecore</foreignModel>
<genPackages prefix="Nao" basePackage="org.eclipse.sirius.sample" disposableProviderFactory="true"
ecorePackage="nao.ecore#/">
<genClasses ecoreClass="nao.ecore#//Nao">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute nao.ecore#//Nao/name"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference nao.ecore#//Nao/function"/>
</genClasses>
<genClasses ecoreClass="nao.ecore#//Function">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute nao.ecore#//Function/name"/>
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference nao.ecore#//Function/motion"/>
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference nao.ecore#//Function/audio"/>
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference nao.ecore#//Function/stop"/>
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference nao.ecore#//Function/relate"/>
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference nao.ecore#//Function/norelate"/>
</genClasses>
<genClasses ecoreClass="nao.ecore#//MoveTo">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute nao.ecore#//MoveTo/x"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute nao.ecore#//MoveTo/y"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute nao.ecore#//MoveTo/theta"/>
<genOperations ecoreOperation="nao.ecore#//MoveTo/moveTo"/>
</genClasses>
<genClasses ecoreClass="nao.ecore#//Speak">
<genOperations ecoreOperation="nao.ecore#//Speak/Speak"/>
</genClasses>
<genClasses ecoreClass="nao.ecore#//Stop">
<genOperations ecoreOperation="nao.ecore#//Stop/stop"/>
</genClasses>
</genPackages>
</genmodel:GenModel>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" output="bin" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.acceleo.module.sample</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.acceleo.ide.ui.acceleoBuilder</name>
<arguments>
<dictionary>
<key>compilation.kind</key>
<value>compilation.platform.resource</value>
</dictionary>
<dictionary>
<key>compliance</key>
<value>pragmatic</value>
</dictionary>
<dictionary>
<key>resource.kind</key>
<value>xmi</value>
</dictionary>
<dictionary>
<key>trim-position</key>
<value>false</value>
</dictionary>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.acceleo.ide.ui.acceleoNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
</projectDescription>
import time
import sys
from rapp_robot_api import RappRobot
rh = RappRobot()
def moveTo(x,y,theta):
rh.motion.moveTo(x,y,theta)
def Speak(text,language):
rh.audio.speak(text,language)
def main():
x = 0.0
y = 0.0
theta = 0.0
moveTo(x,y,theta)
text = ""
language = ""
Speak(text,language)
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Acceleo Sample Module Runtime Plug-in
Bundle-SymbolicName: org.eclipse.acceleo.module.sample
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: org.eclipse.acceleo.module.sample.Activator
Bundle-Vendor: Eclipse Modeling Project
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emf.ecore,
org.eclipse.emf.ecore,
org.eclipse.emf.ecore.xmi,
org.eclipse.ocl,
org.eclipse.ocl.ecore,
org.eclipse.acceleo.common;bundle-version="3.3.0",
org.eclipse.acceleo.model;bundle-version="3.3.0",
org.eclipse.acceleo.profiler;bundle-version="3.3.0",
org.eclipse.acceleo.engine;bundle-version="3.3.0",
com.google.guava
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Eclipse-LazyStart: true
Export-Package: org.eclipse.acceleo.module.sample.common
Import-Package: org.eclipse.sirius.sample.nao
Automatic-Module-Name: org.eclipse.acceleo.module.sample
This source diff could not be displayed because it is too large. You can view the blob instead.
[comment encoding = UTF-8 /]
[module generate('http://www.example.org/sirius/sample/nao')]
[template public generateElement(aNao : Nao)]
[comment @main /]
[file ('code.py',false)]
import time
import sys
from rapp_robot_api import RappRobot
rh = RappRobot()
[for (m : MoveTo | aNao.eContents(MoveTo))]
def moveTo(x,y,theta):
rh.motion.moveTo(x,y,theta)
[/for]
[for (s : Speak | aNao.eContents(Speak))]
def Speak(text,language):
rh.audio.speak(text,language)
[/for]
[for (s : Sit | aNao.eContents(Sit))]
def Sit():
rh.humanoid_motion.goToPosture("Sit",0.5)
[/for]
[for (s : Stand | aNao.eContents(Stand))]
def Stand():
rh.humanoid_motion.goToPosture("Stand",0.5)
[/for]
[for (s : SetVolume | aNao.eContents(SetVolume))]
def SetVolume(volume):
rh.audio.setVolume()
[/for]
[for (t : TakePhoto | aNao.eContents(TakePhoto))]
def TakePhoto(filepath,camera_id,resolution):
rh.vision.capturePhoto(filepath,camera_id,resolution)
[/for]
[for (p : PlayFile | aNao.eContents(PlayFile))]
def PlayFile(filename):
rh.audio.playFile(filename)
[/for]
[for (d : Dance | aNao.eContents(Dance))]
def Dance():
rh.humanoid_motion.openHand("Right")
rh.humanoid_motion.openHand("Left")
time.sleep(2)
rh.humanoid_motion.closeHand("Right")
rh.humanoid_motion.closeHand("Left")
time.sleep(2)
rh.humanoid_motion.setJointAngles( ['['/]"HeadYaw", "HeadPitch"[']'/], ['['/]0.1, 0.2[']'/], 0.5 )
rh.humanoid_motion.setJointAngles( ['['/]"HeadYaw", "HeadPitch"[']'/], ['['/]0.0, 0.0[']'/], 0.0 )
[/for]
[for (t : TellAJoke | aNao.eContents(TellAJoke))]
def TellAJoke():
rh.audio.speak("Why are most midgets good guys ","English")
time.sleep(2)
rh.audio.speak("Because they do not look down on people ","English")
[/for]
[for (r : Record | aNao.eContents(Record))]
def Record(filepath, seconds, audio_type, sample_rate):
rh.audio.record( filepath ,seconds , "ogg", 16000 , ['['/]0,0,1,0[']'/] )
[/for]
[for (t : TactileMeasurements| aNao.eContents(TactileMeasurements))]
def TactileMeasurements(wait,get_history)
while 1:
c=rh.sensors.getTactileMeasurements(wait, get_history)
if c['['/]"tactiles"[']'/]['['/]"head_front"[']'/] == 1.0 :
moveTo(0.5,0.0,0.0)
if c['['/]"tactiles"[']'/]['['/]"head_rear"[']'/] == 1.0 :
moveTo(-0.5,0.0,0.0)
if c['['/]"tactiles"[']'/]['['/]"left_hand_back"[']'/] == 1.0:
moveTo(0.0,0.5,0.0)
if c['['/]"tactiles"[']'/]['['/]"right_hand_back"[']'/] == 1.0:
moveTo(0.0,-0.5,0.0)
if c['['/]"tactiles"[']'/]['['/]"head_middle"[']'/] == 1.0 :
text= "Ok, since you wish so, i will stop now"
Speak(text,language)
Sit()
text="Bye"
Speak(text,language)
break
else :
text="You do not want to touch me. Bye then"
Speak(text,language)
Sit()
break
[/for]
def main():
[for (f : Function| function.NextTransition -> excluding(null))]
[if (f.name = 'Move To') ]
[for (mo : MoveTo | f)]
x = [self.x/]
y = [self.y/]
theta = [self.theta/]
moveTo(x,y,theta)
[/for]
[/if]
[if (f.name = 'Speak') ]
[for (sp : Speak | f)]
text = "[self.text/]"
language = "[self.language/]"
Speak(text,language)
[/for]
[/if]
[if (f.name = 'Sit') ]
[for (si : Sit | f)]
Sit()
[/for]
[/if]
[if (f.name = 'Stand') ]
[for (st : Stand | f)]
Stand()
[/for]
[/if]
[if (f.name = 'Dance') ]
[for (d : Dance | f)]
Dance()
[/for]
[/if]
[if (f.name = 'TakePhoto') ]
[for (t : TakePhoto | f)]
filepath = "[self.filepath/]"
camera_id = "[self.cameraId/]"
resolution = '[self.resolution/]'
TakePhoto("filepath","camera_id","resolution")
[/for]
[/if]
[if (f.name = 'TellAJoke') ]
[for (te : TellAJoke | f)]
TellAJoke()
[/for]
[/if]
[if (f.name = 'Record') ]
[for (r : Record | f)]
filename = [self.filename/]
seconds = [self.seconds/]
Record("/home/filename.ogg", seconds , "ogg", 16000 , ['['/]0,0,1,0[']'/] )
[/for]