-
Notifications
You must be signed in to change notification settings - Fork 6
/
acting_agent.asl
129 lines (108 loc) · 6.07 KB
/
acting_agent.asl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// acting agent
/* Initial beliefs and rules */
// The agent has a belief about the location of the W3C Web of Thing (WoT) Thing Description (TD)
// that describes a Thing of type https://ci.mines-stetienne.fr/kg/ontology#PhantomX
robot_td("https://raw.githubusercontent.com/Interactions-HSG/example-tds/main/tds/leubot1.ttl").
/* Initial goals */
!start. // the agent has the goal to start
/*
* Plan for reacting to the addition of the goal !start
* Triggering event: addition of goal !start
* Context: the agent believes that it can manage a group and a scheme in an organization
* Body: greets the user
*/
@start_plan
+!start : true <-
.print("Hello world").
/*
* Plan for reacting to the addition of the belief organization_deployed(OrgName)
* Triggering event: addition of belief organization_deployed(OrgName)
* Context: true (the plan is always applicable)
* Body: joins the workspace and the organization named OrgName
*/
@organization_deployed_plan
+organization_deployed(OrgName) : true <-
.print("Notified about organization deployment of ", OrgName);
// joins the workspace
joinWorkspace(OrgName);
// looks up for, and focuses on the OrgArtifact that represents the organization
lookupArtifact(OrgName, OrgId);
focus(OrgId).
/*
* Plan for reacting to the addition of the belief available_role(Role)
* Triggering event: addition of belief available_role(Role)
* Context: true (the plan is always applicable)
* Body: adopts the role Role
*/
@available_role_plan
+available_role(Role) : true <-
.print("Adopting the role of ", Role);
adoptRole(Role).
/*
* Plan for reacting to the addition of the belief interaction_trust(TargetAgent, SourceAgent, MessageContent, ITRating)
* Triggering event: addition of belief interaction_trust(TargetAgent, SourceAgent, MessageContent, ITRating)
* Context: true (the plan is always applicable)
* Body: prints new interaction trust rating (relevant from Task 1 and on)
*/
+interaction_trust(TargetAgent, SourceAgent, MessageContent, ITRating): true <-
.print("Interaction Trust Rating: (", TargetAgent, ", ", SourceAgent, ", ", MessageContent, ", ", ITRating, ")").
/*
* Plan for reacting to the addition of the certified_reputation(CertificationAgent, SourceAgent, MessageContent, CRRating)
* Triggering event: addition of belief certified_reputation(CertificationAgent, SourceAgent, MessageContent, CRRating)
* Context: true (the plan is always applicable)
* Body: prints new certified reputation rating (relevant from Task 3 and on)
*/
+certified_reputation(CertificationAgent, SourceAgent, MessageContent, CRRating): true <-
.print("Certified Reputation Rating: (", CertificationAgent, ", ", SourceAgent, ", ", MessageContent, ", ", CRRating, ")").
/*
* Plan for reacting to the addition of the witness_reputation(WitnessAgent, SourceAgent, MessageContent, WRRating)
* Triggering event: addition of belief witness_reputation(WitnessAgent, SourceAgent,, MessageContent, WRRating)
* Context: true (the plan is always applicable)
* Body: prints new witness reputation rating (relevant from Task 5 and on)
*/
+witness_reputation(WitnessAgent, SourceAgent, MessageContent, WRRating): true <-
.print("Witness Reputation Rating: (", WitnessAgent, ", ", SourceAgent, ", ", MessageContent, ", ", WRRating, ")").
/*
* Plan for reacting to the addition of the goal !select_reading(TempReadings, Celcius)
* Triggering event: addition of goal !select_reading(TempReadings, Celcius)
* Context: true (the plan is always applicable)
* Body: unifies the variable Celcius with the 1st temperature reading from the list TempReadings
*/
@select_reading_task_0_plan
+!select_reading(TempReadings, Celcius) : true <-
.nth(0, TempReadings, Celcius).
/*
* Plan for reacting to the addition of the goal !manifest_temperature
* Triggering event: addition of goal !manifest_temperature
* Context: the agent believes that there is a temperature in Celcius and
* that a WoT TD of an onto:PhantomX is located at Location
* Body: converts the temperature from Celcius to binary degrees that are compatible with the
* movement of the robotic arm. Then, manifests the temperature with the robotic arm
*/
@manifest_temperature_plan
+!manifest_temperature : temperature(Celcius) & robot_td(Location) <-
.print("I will manifest the temperature: ", Celcius);
makeArtifact("covnerter", "tools.Converter", [], ConverterId); // creates a converter artifact
convert(Celcius, -20.00, 20.00, 200.00, 830.00, Degrees)[artifact_id(ConverterId)]; // converts Celcius to binary degress based on the input scale
.print("Temperature Manifesting (moving robotic arm to): ", Degrees);
/*
* If you want to test with the real robotic arm,
* follow the instructions here: https://github.com/HSG-WAS-SS24/exercise-8/blob/main/README.md#test-with-the-real-phantomx-reactor-robot-arm
*/
// creates a ThingArtifact based on the TD of the robotic arm
makeArtifact("leubot1", "org.hyperagents.jacamo.artifacts.wot.ThingArtifact", [Location, true], Leubot1Id);
// sets the API key for controlling the robotic arm as an authenticated user
//setAPIKey("77d7a2250abbdb59c6f6324bf1dcddb5")[artifact_id(Leubot1Id)];
// invokes the action onto:SetWristAngle for manifesting the temperature with the wrist of the robotic arm
invokeAction("https://ci.mines-stetienne.fr/kg/ontology#SetWristAngle", ["https://www.w3.org/2019/wot/json-schema#IntegerSchema"], [Degrees])[artifact_id(Leubot1Id)].
/* Import behavior of agents that work in CArtAgO environments */
{ include("$jacamoJar/templates/common-cartago.asl") }
/* Import behavior of agents that work in MOISE organizations */
{ include("$jacamoJar/templates/common-moise.asl") }
/* Import behavior of agents that reason on MOISE organizations */
{ include("$moiseJar/asl/org-rules.asl") }
/* Import behavior of agents that react to organizational events
(if observing, i.e. being focused on the appropriate organization artifacts) */
{ include("inc/skills.asl") }
/* Import interaction trust ratings */
{ include("inc/interaction_trust_ratings.asl") }