Ros2Rag.parser 2.86 KB
Newer Older
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
Ros2Rag ros2rag
  = update_definition.d ros2rag.r       {: r.getUpdateDefinitionList().insertChild(d, 0); return r; :}
  | dependency_definition.d ros2rag.r   {: r.getDependencyDefinitionList().insertChild(d, 0); return r; :}
  | mapping_definition.d ros2rag.r      {: r.getMappingDefinitionList().insertChild(d, 0); return r; :}
  |                                     {: return new Ros2Rag(); :}
;

// read Joint.CurrentPosition using LinkStateToIntPosition ;
// write RobotArm._AppropriateSpeed using CreateSpeedMessage ;
UpdateDefinition update_definition
  = READ ID.type_name DOT ID.token_name SCOL
    {:
      ReadFromMqttDefinition result = new ReadFromMqttDefinition();
      result.setToken(TokenComponent.createRef(type_name + "." + token_name));
      return result;
    :}
  | READ ID.type_name DOT ID.token_name USING ID.mapping_def SCOL
    {:
      ReadFromMqttDefinition result = new ReadFromMqttDefinition();
      result.setToken(TokenComponent.createRef(type_name + "." + token_name));
      result.setMapping(MappingDefinition.createRef(mapping_def));
      return result;
    :}
  | WRITE ID.type_name DOT ID.token_name SCOL
    {:
      WriteToMqttDefinition result = new WriteToMqttDefinition();
      result.setToken(TokenComponent.createRef(type_name + "." + token_name));
      return result;
    :}
  | WRITE ID.type_name DOT ID.token_name USING ID.mapping_def SCOL
    {:
      WriteToMqttDefinition result = new WriteToMqttDefinition();
      result.setToken(TokenComponent.createRef(type_name + "." + token_name));
      result.setMapping(MappingDefinition.createRef(mapping_def));
      return result;
    :}
;

// RobotArm._AppropriateSpeed canDependOn Joint.CurrentPosition as dependency1 ;
DependencyDefinition dependency_definition
  = ID.target_type DOT ID.target_token CAN_DEPEND_ON ID.source_type DOT ID.source_token AS ID.id SCOL
    {:
      DependencyDefinition result = new DependencyDefinition();
      result.setSource(TokenComponent.createRef(source_type + "." + source_token));
      result.setTarget(TokenComponent.createRef(target_type + "." + target_token));
      result.setID(id);
      return result;
    :}
;

//LinkStateToIntPosition maps protobuf panda.Linkstate.PandaLinkState x to IntPosition y {
//  panda.Linkstate.PandaLinkState.Position p = x.getPos();
//  y = IntPosition.of((int) p.getPositionX(), (int) p.getPositionY(), (int) p.getPositionZ());
//}
MappingDefinition mapping_definition
  = ID.id MAPS java_type_use.from_type ID.from_variable TO java_type_use.to_type ID.to_variable LB_CURLY mapping_def_content.content RB_CURLY
    {:
      MappingDefinition result = new MappingDefinition();
      result.setID(id);
      result.setFrom(from_type);
      result.setFromVariable(from_variable);
      result.setTo(to_type);
      result.setToVariable(to_variable);
      result.setContent(content);
      return result;
    :}
;

String mapping_def_content = ID ;