Add panic to sim time examples

This commit is contained in:
Martin Škoudlil 2024-03-22 18:36:19 +01:00
parent 0fd206ca4f
commit c23e2eb1f6
2 changed files with 7 additions and 0 deletions

View File

@ -32,4 +32,5 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
#[cfg(not(r2r__rosgraph_msgs__msg__Clock))] #[cfg(not(r2r__rosgraph_msgs__msg__Clock))]
fn main() { fn main() {
panic!("Sim_time_publisher example is not compiled with 'rosgraph_msgs'.");
} }

View File

@ -33,6 +33,7 @@ async fn timer_task(
/// Publication of time can be done either using the example `sim_time_publisher` /// Publication of time can be done either using the example `sim_time_publisher`
/// or with `ros2 bag play --clock <clock_frequency> <the_bag>` /// or with `ros2 bag play --clock <clock_frequency> <the_bag>`
#[cfg(r2r__rosgraph_msgs__msg__Clock)]
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
let ctx = r2r::Context::create()?; let ctx = r2r::Context::create()?;
let mut node = r2r::Node::create(ctx, "testnode", "")?; let mut node = r2r::Node::create(ctx, "testnode", "")?;
@ -80,3 +81,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Ok(()) Ok(())
} }
#[cfg(not(r2r__rosgraph_msgs__msg__Clock))]
fn main() {
panic!("Timer_sim_time example is not compiled with 'rosgraph_msgs'.");
}