Skip to content

Commit d395f5f

Browse files
committed
Remove unnecessary debug outputs
Signed-off-by: Michael X. Grey <[email protected]>
1 parent ee15de5 commit d395f5f

File tree

6 files changed

+28
-108
lines changed

6 files changed

+28
-108
lines changed

rclrs/src/client.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ where
8181
}
8282
.ok()?;
8383

84-
println!("vvvvvvvvv Sent client request {sequence_number} vvvvvvvvvvvv");
8584
// TODO(@mxgrey): Log errors here when logging becomes available.
8685
self.board.lock().unwrap().new_request(sequence_number, sender);
8786

@@ -317,13 +316,9 @@ where
317316
Ok((response, info)) => {
318317
let seq = info.request_id.sequence_number;
319318
if let Some(sender) = self.active_requests.remove(&seq) {
320-
dbg!();
321-
println!("Received response for {info:?}");
322319
// The active request is available, so send this response off
323320
sender.send_response(response, info);
324321
} else {
325-
dbg!();
326-
println!("Received loose response for {info:?}");
327322
// Weirdly there isn't an active request for this, so save
328323
// it in the loose responses map.
329324
self.loose_responses.insert(seq, (response, info));
@@ -333,11 +328,8 @@ where
333328
match err {
334329
RclrsError::RclError { code: RclReturnCode::ClientTakeFailed, .. } => {
335330
// This is okay, it means a spurious wakeup happened
336-
dbg!();
337-
println!("Spurious wakeup for client");
338331
}
339332
err => {
340-
dbg!();
341333
// TODO(@mxgrey): Log the error here once logging is available
342334
eprintln!("Error while taking a response for a client: {err}");
343335
}

rclrs/src/executor.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
mod basic_executor;
22
pub use self::basic_executor::*;
33

4-
use std::io::Write;
5-
64
use crate::{
75
Node, NodeOptions, RclrsError, Context, ContextHandle, Waitable, GuardCondition,
86
};
@@ -147,20 +145,13 @@ impl ExecutorCommands {
147145
let (mut sender, receiver) = oneshot::channel();
148146
self.channel.add_async_task(Box::pin(
149147
async move {
150-
dbg!();
151-
std::io::stdout().lock().flush().unwrap();
152148
let cancellation = sender.cancellation();
153149
let output = match select(cancellation, std::pin::pin!(f)).await {
154150
// The task was cancelled
155-
// Either::Left(_) => return,
151+
Either::Left(_) => return,
156152
// The task completed
157-
// Either::Right((output, _)) => output,
158-
159-
Either::Left(_) => { dbg!(); return; }
160-
Either::Right((output, _)) => { dbg!(); output }
153+
Either::Right((output, _)) => output,
161154
};
162-
dbg!();
163-
std::io::stdout().lock().flush().unwrap();
164155
sender.send(output).ok();
165156
}
166157
));

rclrs/src/executor/basic_executor.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ use crate::{
1919
Waitable, Context, WaitSetRunner,
2020
};
2121

22-
use std::io::Write;
23-
2422
/// The implementation of this runtime is based off of the async Rust reference book:
2523
/// https://rust-lang.github.io/async-book/02_execution/04_executor.html
2624
///
@@ -79,9 +77,7 @@ impl ExecutorRuntime for BasicExecutorRuntime {
7977
wait_set_finished_clone.store(true, Ordering::Release);
8078
}));
8179

82-
let mut count = 0;
8380
while let Ok(task) = self.next_task(&wait_set_finished) {
84-
dbg!();
8581
// SAFETY: If the mutex is poisoned then we have unrecoverable situation.
8682
let mut future_slot = task.future.lock().unwrap();
8783
if let Some(mut future) = future_slot.take() {
@@ -96,11 +92,6 @@ impl ExecutorRuntime for BasicExecutorRuntime {
9692
*future_slot = Some(future);
9793
}
9894
}
99-
100-
// count += 1;
101-
// if count > 20 {
102-
// panic!("Done {count} iterations");
103-
// }
10495
}
10596

10697
self.wait_set_runner = Some(
@@ -181,8 +172,6 @@ impl BasicExecutorRuntime {
181172
);
182173
}
183174
// TODO(@mxgrey): Log errors here when logging becomes available.
184-
dbg!();
185-
std::io::stdout().lock().flush().unwrap();
186175
guard_condition.trigger().ok();
187176
sender.send(()).ok();
188177
}));
@@ -202,7 +191,7 @@ impl BasicExecutorRuntime {
202191
}
203192
}
204193

205-
pub struct BasicExecutorChannel {
194+
struct BasicExecutorChannel {
206195
task_sender: TaskSender,
207196
waitable_sender: UnboundedSender<Waitable>,
208197
}

rclrs/src/node.rs

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use futures::{
2121
channel::mpsc::{unbounded, UnboundedSender},
2222
};
2323

24-
// use async_std::future::timeout;
24+
use async_std::future::timeout;
2525

2626
use rosidl_runtime_rs::Message;
2727

@@ -33,10 +33,6 @@ use crate::{
3333
ServiceAsyncCallback, ExecutorCommands, TimeSource, ENTITY_LIFECYCLE_MUTEX,
3434
};
3535

36-
37-
use std::io::Write;
38-
39-
4036
/// A processing unit that can communicate with other nodes.
4137
///
4238
/// Nodes are a core concept in ROS 2. Refer to the official ["Understanding ROS 2 nodes"][1]
@@ -453,46 +449,38 @@ impl Node {
453449
) -> Promise<()> {
454450
let (listener, mut on_graph_change_receiver) = unbounded();
455451
let promise = self.commands.query(async move {
456-
dbg!();
457-
std::io::stdout().lock().flush().unwrap();
458452
loop {
459-
// match timeout(period, on_graph_change_receiver.next()).await {
460-
// Ok(Some(_)) | Err(_) => {
461-
// // Either we received a notification that there was a
462-
// // graph change, or the timeout elapsed. Either way, we
463-
// // want to check the condition and break out of the loop
464-
// // if the condition is true.
465-
// if condition() {
466-
// return;
467-
// }
468-
// }
469-
// Ok(None) => {
470-
// // We've been notified that the graph change sender is
471-
// // closed which means we will never receive another
472-
// // graph change update. This only happens when a node
473-
// // is being torn down, so go ahead and exit this loop.
474-
// return;
475-
// }
476-
// }
477-
478-
match on_graph_change_receiver.next().await {
479-
Some(_) => {
480-
dbg!();
481-
std::io::stdout().lock().flush().unwrap();
453+
match timeout(period, on_graph_change_receiver.next()).await {
454+
Ok(Some(_)) | Err(_) => {
455+
// Either we received a notification that there was a
456+
// graph change, or the timeout elapsed. Either way, we
457+
// want to check the condition and break out of the loop
458+
// if the condition is true.
482459
if condition() {
483-
// Condition is met
484-
dbg!();
485-
std::io::stdout().lock().flush().unwrap();
486460
return;
487461
}
488462
}
489-
None => {
490-
dbg!();
491-
std::io::stdout().lock().flush().unwrap();
492-
// Graph change sender is closed
463+
Ok(None) => {
464+
// We've been notified that the graph change sender is
465+
// closed which means we will never receive another
466+
// graph change update. This only happens when a node
467+
// is being torn down, so go ahead and exit this loop.
493468
return;
494469
}
495470
}
471+
472+
// match on_graph_change_receiver.next().await {
473+
// Some(_) => {
474+
// if condition() {
475+
// // Condition is met
476+
// return;
477+
// }
478+
// }
479+
// None => {
480+
// // Graph change sender is closed
481+
// return;
482+
// }
483+
// }
496484
}
497485
});
498486

rclrs/src/parameter/service.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,6 @@ mod tests {
327327
time::Duration,
328328
};
329329

330-
use std::io::Write;
331-
332330
struct TestNode {
333331
node: Arc<Node>,
334332
bool_param: MandatoryParameter<bool>,
@@ -454,25 +452,20 @@ mod tests {
454452

455453
#[test]
456454
fn test_list_parameters_service() -> Result<(), RclrsError> {
457-
dbg!();
458455
let context = Context::default();
459456
let (mut executor, _test, client_node) = construct_test_nodes(&context, "list");
460457
let list_client = client_node.create_client::<ListParameters>(
461458
"/list/node/list_parameters",
462459
QoSProfile::services_default(),
463460
)?;
464461

465-
dbg!();
466-
std::io::stdout().lock().flush().unwrap();
467462
// return Ok(());
468463
executor.spin(
469464
SpinOptions::default()
470465
.until_promise_resolved(list_client.notify_on_service_ready())
471466
.timeout(Duration::from_secs(2))
472467
);
473468

474-
dbg!();
475-
std::io::stdout().lock().flush().unwrap();
476469
// List all parameters
477470
let callback_ran = Arc::new(AtomicBool::new(false));
478471
let callback_ran_inner = Arc::clone(&callback_ran);
@@ -484,8 +477,6 @@ mod tests {
484477
.call_then(
485478
&request,
486479
move |response: ListParameters_Response| {
487-
dbg!();
488-
std::io::stdout().lock().flush().unwrap();
489480
// use_sim_time + all the manually defined ones
490481
let names = response.result.names;
491482
assert_eq!(names.len(), 5);
@@ -503,16 +494,12 @@ mod tests {
503494
)
504495
.unwrap();
505496

506-
dbg!();
507-
std::io::stdout().lock().flush().unwrap();
508497
executor.spin(
509498
SpinOptions::default()
510499
.until_promise_resolved(promise)
511500
.timeout(Duration::from_secs(5))
512501
);
513502
assert!(callback_ran.load(Ordering::Acquire));
514-
dbg!();
515-
std::io::stdout().lock().flush().unwrap();
516503

517504
// Limit depth, namespaced parameter is not returned
518505
let callback_ran = Arc::new(AtomicBool::new(false));
@@ -579,7 +566,6 @@ mod tests {
579566
&request,
580567
move |response: ListParameters_Response| {
581568
let names = response.result.names;
582-
dbg!(&names);
583569
assert_eq!(names.len(), 2);
584570
assert_eq!(names[0].to_string(), "bool");
585571
assert_eq!(names[1].to_string(), "use_sim_time");

rclrs/src/service/any_service_callback.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,46 +34,31 @@ impl<T: Service> AnyServiceCallback<T> {
3434
commands: &Arc<ExecutorCommands>,
3535
) -> Result<(), RclrsError> {
3636
let mut evaluate = || {
37-
dbg!();
3837
match self {
3938
AnyServiceCallback::OnlyRequest(cb) => {
40-
dbg!();
4139
let (msg, mut rmw_request_id) = Self::take_request(handle)?;
4240
let handle = Arc::clone(&handle);
4341
let response = cb(msg);
44-
dbg!();
4542
let _ = commands.run(async move {
46-
// TODO(@mxgrey): Log any errors here when logging is available
47-
dbg!();
48-
println!("Sending service response: {rmw_request_id:?}");
4943
if let Err(err) = Self::send_response(&handle, &mut rmw_request_id, response.await) {
5044
// TODO(@mxgrey): Use logging instead when it becomes available
5145
eprintln!("Error while sending service response for {rmw_request_id:?}: {err}");
52-
} else {
53-
println!("No error while sending {rmw_request_id:?}");
5446
}
5547
});
5648
}
5749
AnyServiceCallback::WithId(cb) => {
58-
dbg!();
5950
let (msg, mut rmw_request_id) = Self::take_request(handle)?;
6051
let request_id = RequestId::from_rmw_request_id(&rmw_request_id);
6152
let handle = Arc::clone(&handle);
6253
let response = cb(msg, request_id);
63-
dbg!();
6454
let _ = commands.run(async move {
65-
dbg!();
66-
println!("Sending service response: {rmw_request_id:?}");
6755
if let Err(err) = Self::send_response(&handle, &mut rmw_request_id, response.await) {
6856
// TODO(@mxgrey): Use logging instead when it becomes available
6957
eprintln!("Error while sending service response for {rmw_request_id:?}: {err}");
70-
} else {
71-
println!("No error while sending {rmw_request_id:?}");
7258
}
7359
});
7460
}
7561
AnyServiceCallback::WithInfo(cb) => {
76-
dbg!();
7762
let (msg, rmw_service_info) = Self::take_request_with_info(handle)?;
7863
let mut rmw_request_id = rmw_request_id_t {
7964
writer_guid: rmw_service_info.request_id.writer_guid,
@@ -82,16 +67,10 @@ impl<T: Service> AnyServiceCallback<T> {
8267
let service_info = ServiceInfo::from_rmw_service_info(&rmw_service_info);
8368
let handle = Arc::clone(&handle);
8469
let response = cb(msg, service_info);
85-
dbg!();
8670
let _ = commands.run(async move {
87-
// TODO(@mxgrey): Log any errors here when logging is available
88-
dbg!();
89-
println!("Sending service response: {rmw_request_id:?}");
9071
if let Err(err) = Self::send_response(&handle, &mut rmw_request_id, response.await) {
9172
// TODO(@mxgrey): Use logging instead when it becomes available
9273
eprintln!("Error while sending service response for {rmw_request_id:?}: {err}");
93-
} else {
94-
println!("No error while sending {rmw_request_id:?}");
9574
}
9675
});
9776
}
@@ -100,16 +79,13 @@ impl<T: Service> AnyServiceCallback<T> {
10079
Ok(())
10180
};
10281

103-
dbg!();
10482
match evaluate() {
10583
Err(RclrsError::RclError {
10684
code: RclReturnCode::ServiceTakeFailed,
10785
..
10886
}) => {
10987
// Spurious wakeup - this may happen even when a waitlist indicated that this
11088
// subscription was ready, so it shouldn't be an error.
111-
dbg!();
112-
println!("Spurious wakeup for service request");
11389
Ok(())
11490
}
11591
other => other,
@@ -152,7 +128,6 @@ impl<T: Service> AnyServiceCallback<T> {
152128
)
153129
}
154130
.ok()?;
155-
println!("^^^^^^^^^^ service request arrived: {request_id_out:?} ^^^^^^^^^^^^^^");
156131
Ok((T::Request::from_rmw_message(request_out), request_id_out))
157132
}
158133

@@ -171,7 +146,6 @@ impl<T: Service> AnyServiceCallback<T> {
171146
)
172147
}
173148
.ok()?;
174-
println!("^^^^^^^^^^^^ service request arrived: {service_info_out:?} ^^^^^^^^^^^^^");
175149
Ok((T::Request::from_rmw_message(request_out), service_info_out))
176150
}
177151

0 commit comments

Comments
 (0)