Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ A comprehensive RTLola tutorial can be found [here](https://rtlola.cispa.de/play

Tested using Rust Version 1.87.0

> If you want to use ``ros2 run rtlola_node rtlola_ros2_monitor`` then call ``colcon build`` within [rtlola_node](rtlola_node) to build a workspace you can source (ie the monitor must be build first).
> If you want to use ``ros2 run rtlola_node rtlola_ros2_monitor`` then call ``colcon build`` within [rtlola_node](rtlola_node) to build a workspace you can source.

## Contributors
- Sebastian Schirmer
Expand Down
2 changes: 1 addition & 1 deletion monitor/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn main() {
let mut rust_generator =
RustFileGenerator::new(ros2_reader, config.Destination.path.clone());
rust_generator.generate_file_inputs(&subscribable_topics, &rtlolaout_service);
rust_generator.generate_file_main(&subscribable_topics, rtlolaout_service.is_some());
rust_generator.generate_file_main( &config.Specification.location, &subscribable_topics, rtlolaout_service.is_some());
rust_generator.generate_file_ros2handler(
&config,
&subscribable_topics,
Expand Down
6 changes: 6 additions & 0 deletions monitor/build_src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use serde::Deserialize;
#[allow(non_snake_case)]
#[derive(Debug, Deserialize)]
pub struct Config {
pub Specification: Specification,
pub GenerateFlag: GenerateFlag,
pub LocalSetupScript: LocalSetupScript,
pub QoS_Default: QoS,
Expand All @@ -15,6 +16,11 @@ pub struct Config {
pub Destination: Destination,
}

#[derive(Debug, Deserialize)]
pub struct Specification {
pub location: String,
}

#[derive(Debug, Deserialize)]
pub struct GenerateFlag {
pub generate: bool,
Expand Down
3 changes: 2 additions & 1 deletion monitor/build_src/fn_generator/generate_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{
};

impl RustFileGenerator {
pub fn generate_file_main(&self, topics: &Vec<(String, String, QoS)>, has_service: bool) {
pub fn generate_file_main(&self, spec_location: &String, topics: &Vec<(String, String, QoS)>, has_service: bool) {
// File that is generated
let file_location = format!("{}/main.rs", self.dest_path);
let file = File::create(&file_location).unwrap();
Expand All @@ -35,6 +35,7 @@ impl RustFileGenerator {
file_content = file_content.replace("$SERVICEAVAILABLE$", "");
}
file_content = file_content.replace("$INPUTMODS$", &pub_mods_content);
file_content = file_content.replace("$SPECLOCATION$", &spec_location);
// Write input source codeto file
writeln!(&file, "{}", file_content).unwrap();
// Format generated file
Expand Down
7 changes: 2 additions & 5 deletions monitor/build_src/templates/t_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ use crate::{
input::rtloladata::RTLolaData, input::rtloladata::RTLolaDataFactory, ros2_handler::Ros2Handler,
};
use rtlola_interpreter::{input::AssociatedFactory, monitor::Incremental, ConfigBuilder, Monitor};
use std::{env, fs};
use std::fs;

#[tokio::main]
async fn main() {
let args: Vec<String> = env::args().collect();
assert_eq!(args.len(), 2);
// Reads specification
let spec = fs::read_to_string(&args[1]).unwrap();
let spec = fs::read_to_string("$SPECLOCATION$").unwrap();
// Creates monitor
let monitor: Monitor<RTLolaDataFactory, rtlola_interpreter::config::OnlineMode> =
ConfigBuilder::new()
Expand Down
3 changes: 3 additions & 0 deletions monitor/ros2_config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# SPDX-FileCopyrightText: 2023 German Aerospace Center (DLR)
# SPDX-License-Identifier: Apache-2.0

[Specification]
location = "../specs/test_spec.lola"

# allows to freeze, i.e., disables build.rs
[GenerateFlag]
generate = true
Expand Down
20 changes: 20 additions & 0 deletions rtlola_node/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@
cmake_minimum_required(VERSION 3.5)
project(rtlola_node)


###
# Build the monitor first
###

execute_process(
COMMAND cargo build
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../monitor
RESULT_VARIABLE CARGO_RESULT
)

if(NOT CARGO_RESULT EQUAL 0)
message(FATAL_ERROR "cargo build failed")
endif()


###
# Wrap the result as a Ros2 Node
###

find_package(ament_cmake REQUIRED)

set(MONITOR_EXECUTABLE ${CMAKE_CURRENT_SOURCE_DIR}/../monitor/target/release/rtlola_ros2_monitor)
Expand Down
Loading