Skip to content

Commit 8411a49

Browse files
committed
Reworking launch files
1 parent 03bcf9d commit 8411a49

5 files changed

Lines changed: 28 additions & 27 deletions

File tree

.DS_Store

0 Bytes
Binary file not shown.

jvm/.DS_Store

0 Bytes
Binary file not shown.

jvm/src/.DS_Store

0 Bytes
Binary file not shown.

jvm/src/test

Submodule test updated from 65d506d to 301c7f4

shared/src/main/scala/org/sireum/hamr/codegen/ros2/GeneratorPy.scala

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package org.sireum.hamr.codegen.ros2
44

55
import org.sireum._
66
import org.sireum.hamr.codegen.common.containers.Marker
7-
import org.sireum.hamr.codegen.common.symbols.{AadlDataPort, AadlEventDataPort, AadlPort, AadlThread, Dispatch_Protocol}
7+
import org.sireum.hamr.codegen.common.symbols.{AadlDataPort, AadlEventDataPort, AadlPort, AadlSystem, AadlThread, Dispatch_Protocol}
88
import org.sireum.hamr.codegen.common.types.{AadlType, EnumType}
99
import org.sireum.hamr.ir.Direction
1010
import org.sireum.message.Reporter
@@ -154,7 +154,6 @@ object GeneratorPy {
154154
// build entry point declarations
155155
var entry_point_decls: ISZ[ST] = IS()
156156
for (comp <- threadComponents) {
157-
val launch_node_decl_nameT = genPyFormatLaunchNodeDeclName(genNodeName(comp))
158157
entry_point_decls =
159158
entry_point_decls :+ genPySetupEntryPointDecl(modelName, genNodeName(comp))
160159
}
@@ -527,36 +526,38 @@ object GeneratorPy {
527526
}
528527

529528
// For example, see https://github.com/santoslab/ros-examples/blob/main/tempControl_ws/src/tc_bringup/launch/tc.launch.py
530-
def genPyFormatLaunchFile(modelName: String, threadComponents: ISZ[AadlThread]): (ISZ[String], ST, B, ISZ[Marker]) = {
531-
val fileName = genPyLaunchFileName(modelName)
529+
def genPyFormatLaunchFile(modelName: String, threadComponents: ISZ[AadlThread],
530+
systemComponents: ISZ[AadlSystem]): ISZ[(ISZ[String], ST, B, ISZ[Marker])] = {
532531

533532
val top_level_package_nameT: String = genPyPackageName(modelName)
534533

535-
var node_decls: ISZ[ST] = IS()
536-
var ld_entries: ISZ[ST] = IS()
534+
var launchFiles: ISZ[(ISZ[String], ST, B, ISZ[Marker])] = IS()
535+
536+
for (system <- systemComponents) {
537+
val fileName = genPyFormatLaunchNodeDeclName(system.identifier)
538+
539+
val node_decls: ISZ[ST] = IS()
540+
val ld_entries: ISZ[ST] = IS()
541+
542+
val launchFileBody =
543+
st"""from launch import LaunchDescription
544+
|from launch_ros.actions import Node
545+
|
546+
|def generate_launch_description():
547+
| ld = LaunchDescription()
548+
|
549+
| ${(node_decls, "\n")}
550+
| ${(ld_entries, "\n")}
551+
|
552+
| return ld
553+
"""
537554

538-
for (comp <- threadComponents) {
539-
val launch_node_decl_nameT = genPyFormatLaunchNodeDeclName(genNodeName(comp))
540-
node_decls = node_decls :+ genPyFormatLaunchNodeDecl(launch_node_decl_nameT, top_level_package_nameT, comp)
541-
ld_entries = ld_entries :+ genPyFormatLaunchAddAction(launch_node_decl_nameT)
542-
}
555+
val filePath: ISZ[String] = IS("src", s"${top_level_package_nameT}_bringup", "launch", fileName)
543556

544-
val launchFileBody =
545-
st"""from launch import LaunchDescription
546-
|from launch_ros.actions import Node
547-
|
548-
|def generate_launch_description():
549-
| ld = LaunchDescription()
550-
|
551-
| ${(node_decls, "\n")}
552-
| ${(ld_entries, "\n")}
553-
|
554-
| return ld
555-
"""
556-
557-
val filePath: ISZ[String] = IS("src", s"${top_level_package_nameT}_bringup", "launch", fileName)
557+
launchFiles = launchFiles :+ (filePath, launchFileBody, T, IS())
558+
}
558559

559-
return (filePath, launchFileBody, T, IS())
560+
return launchFiles
560561
}
561562

562563
//================================================

0 commit comments

Comments
 (0)