Skip to content
Closed
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
3 changes: 2 additions & 1 deletion r2r/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "r2r"
version = "0.7.3"
version = "0.7.4"
authors = ["Martin Dahl <martin.dahl@gmail.com>"]
description = "Easy to use, runtime-agnostic, async rust bindings for ROS2."
license = "MIT AND Apache-2.0"
Expand All @@ -24,6 +24,7 @@ r2r_msg_gen = { path = "../r2r_msg_gen", version = "0.3.11" }
r2r_actions = { path = "../r2r_actions", version = "0.3.10" }
uuid = { version = "1.2.2", features = ["serde", "v4"] }
futures = "0.3.25"
log = "0.4.18"

[dev-dependencies]
serde_json = "1.0.89"
Expand Down
22 changes: 11 additions & 11 deletions r2r/src/action_clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ where
});
Ok(future)
} else {
eprintln!("coult not send goal request {}", result);
log::error!("could not send goal request {}", result);
Err(Error::from_rcl_error(result))
}
}
Expand Down Expand Up @@ -260,7 +260,7 @@ where
});
Ok(future)
} else {
eprintln!("coult not send goal request {}", result);
log::error!("could not send goal request {}", result);
Err(Error::from_rcl_error(result))
}
}
Expand Down Expand Up @@ -300,7 +300,7 @@ where
match sender.send((accept, stamp)) {
Ok(()) => {}
Err(e) => {
println!("error sending to action client: {:?}", e);
log::debug!("error sending to action client: {:?}", e);
}
}
} else {
Expand All @@ -310,7 +310,7 @@ where
.map(|(id, _)| id.to_string())
.collect::<Vec<_>>()
.join(",");
eprintln!(
log::error!(
"no such req id: {}, we have [{}], ignoring",
request_id.sequence_number, we_have
);
Expand Down Expand Up @@ -339,7 +339,7 @@ where
let (_, sender) = self.cancel_response_channels.swap_remove(idx);
let response = action_msgs::srv::CancelGoal::Response::from_native(&response_msg);
if let Err(e) = sender.send(response) {
eprintln!("warning: could not send cancel response msg ({:?})", e)
log::error!("warning: could not send cancel response msg ({:?})", e)
}
} else {
let we_have: String = self
Expand All @@ -348,7 +348,7 @@ where
.map(|(id, _)| id.to_string())
.collect::<Vec<_>>()
.join(",");
eprintln!(
log::error!(
"no such req id: {}, we have [{}], ignoring",
request_id.sequence_number, we_have
);
Expand All @@ -370,7 +370,7 @@ where
.find(|(uuid, _)| uuid == &msg_uuid)
{
if let Err(e) = sender.try_send(feedback) {
eprintln!("warning: could not send feedback msg ({})", e)
log::error!("warning: could not send feedback msg ({})", e)
}
}
}
Expand Down Expand Up @@ -426,7 +426,7 @@ where
match sender.send((status, result)) {
Ok(()) => {}
Err(e) => {
println!("error sending result to action client: {:?}", e);
log::debug!("error sending result to action client: {:?}", e);
}
}
}
Expand All @@ -437,7 +437,7 @@ where
.map(|(id, _)| id.to_string())
.collect::<Vec<_>>()
.join(",");
eprintln!(
log::error!(
"no such req id: {}, we have [{}], ignoring",
request_id.sequence_number, we_have
);
Expand All @@ -461,7 +461,7 @@ where
if result == RCL_RET_OK as i32 {
self.result_requests.push((seq_no, uuid));
} else {
eprintln!("coult not send request {}", result);
log::error!("could not send request {}", result);
}
}

Expand Down Expand Up @@ -576,7 +576,7 @@ pub fn action_server_available_helper(
if result == RCL_RET_OK as i32 {
Ok(avail)
} else {
eprintln!("coult not check if action server is available {}", result);
log::error!("could not check if action server is available {}", result);
Err(Error::from_rcl_error(result))
}
}
20 changes: 10 additions & 10 deletions r2r/src/action_clients_untyped.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl ActionClientUntyped {
});
Ok(future)
} else {
eprintln!("coult not send goal request {}", result);
log::error!("could not send goal request {}", result);
Err(Error::from_rcl_error(result))
}
}
Expand Down Expand Up @@ -227,7 +227,7 @@ impl WrappedActionClientUntyped {
});
Ok(future)
} else {
eprintln!("coult not send goal request {}", result);
log::error!("could not send goal request {}", result);
Err(Error::from_rcl_error(result))
}
}
Expand Down Expand Up @@ -262,7 +262,7 @@ impl ActionClient_ for WrappedActionClientUntyped {
match sender.send((accept, stamp)) {
Ok(()) => {}
Err(e) => {
println!("error sending to action client: {:?}", e);
log::debug!("error sending to action client: {:?}", e);
}
}
} else {
Expand All @@ -272,7 +272,7 @@ impl ActionClient_ for WrappedActionClientUntyped {
.map(|(id, _)| id.to_string())
.collect::<Vec<_>>()
.join(",");
eprintln!(
log::error!(
"no such req id: {}, we have [{}], ignoring",
request_id.sequence_number, we_have
);
Expand Down Expand Up @@ -301,7 +301,7 @@ impl ActionClient_ for WrappedActionClientUntyped {
let (_, sender) = self.cancel_response_channels.swap_remove(idx);
let response = action_msgs::srv::CancelGoal::Response::from_native(&response_msg);
if let Err(e) = sender.send(response) {
eprintln!("warning: could not send cancel response msg ({:?})", e)
log::error!("warning: could not send cancel response msg ({:?})", e)
}
} else {
let we_have: String = self
Expand All @@ -310,7 +310,7 @@ impl ActionClient_ for WrappedActionClientUntyped {
.map(|(id, _)| id.to_string())
.collect::<Vec<_>>()
.join(",");
eprintln!(
log::error!(
"no such req id: {}, we have [{}], ignoring",
request_id.sequence_number, we_have
);
Expand All @@ -332,7 +332,7 @@ impl ActionClient_ for WrappedActionClientUntyped {
.find(|(uuid, _)| uuid == &msg_uuid)
{
if let Err(e) = sender.try_send(feedback) {
eprintln!("warning: could not send feedback msg ({})", e)
log::error!("warning: could not send feedback msg ({})", e)
}
}
}
Expand Down Expand Up @@ -385,7 +385,7 @@ impl ActionClient_ for WrappedActionClientUntyped {
match sender.send((status, result)) {
Ok(()) => {}
Err(e) => {
println!("error sending result to action client: {:?}", e);
log::debug!("error sending result to action client: {:?}", e);
}
}
}
Expand All @@ -396,7 +396,7 @@ impl ActionClient_ for WrappedActionClientUntyped {
.map(|(id, _)| id.to_string())
.collect::<Vec<_>>()
.join(",");
eprintln!(
log::error!(
"no such req id: {}, we have [{}], ignoring",
request_id.sequence_number, we_have
);
Expand All @@ -417,7 +417,7 @@ impl ActionClient_ for WrappedActionClientUntyped {
if result == RCL_RET_OK as i32 {
self.result_requests.push((seq_no, uuid));
} else {
eprintln!("coult not send request {}", result);
log::error!("could not send request {}", result);
}
}

Expand Down
36 changes: 18 additions & 18 deletions r2r/src/action_servers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ impl ActionServerCancelRequest {
/// Accepts the cancel request. The action server should now cancel the corresponding goal.
pub fn accept(self) {
if self.response_sender.send((self.uuid, true)).is_err() {
eprintln!("warning: could not send goal canellation accept msg")
log::error!("warning: could not send goal canellation accept msg")
}
}
/// Rejects the cancel request.
pub fn reject(self) {
if self.response_sender.send((self.uuid, false)).is_err() {
eprintln!("warning: could not send goal cancellation rejection")
log::error!("warning: could not send goal cancellation rejection")
}
}
}
Expand Down Expand Up @@ -195,7 +195,7 @@ where
let ret = unsafe { rcl_action_goal_handle_get_status(*handle, &mut state) };

if ret != RCL_RET_OK as i32 {
println!("action server: Failed to get goal handle state: {}", ret);
log::debug!("action server: Failed to get goal handle state: {}", ret);
return Err(Error::from_rcl_error(ret));
}
return Ok(state == action_msgs::msg::GoalStatus::STATUS_CANCELING as u8);
Expand All @@ -213,7 +213,7 @@ where
};

if ret != RCL_RET_OK as i32 {
println!(
log::debug!(
"action server: could not cancel goal: {}",
Error::from_rcl_error(ret)
);
Expand All @@ -239,7 +239,7 @@ where
unsafe { rcl_action_server_goal_exists(self.handle(), &*goal_info_native) };

if !goal_exists {
println!("tried to publish result without a goal");
log::debug!("tried to publish result without a goal");
return Err(Error::RCL_RET_ACTION_GOAL_HANDLE_INVALID);
}

Expand Down Expand Up @@ -286,7 +286,7 @@ where
});
}
Err(oneshot::Canceled) => {
eprintln!("Warning, cancel request not handled!");
log::error!("Warning, cancel request not handled!");
return false; // skip this request.
}
}
Expand Down Expand Up @@ -325,7 +325,7 @@ where
};

if ret != RCL_RET_OK as i32 {
println!("action server: could send cancel response. {}", ret);
log::debug!("action server: could send cancel response. {}", ret);
}
}
}
Expand Down Expand Up @@ -364,7 +364,7 @@ where

// send out request.
if let Err(e) = self.goal_request_sender.try_send(gr) {
eprintln!("warning: could not send service request ({})", e)
log::error!("warning: could not send service request ({})", e)
}
}

Expand Down Expand Up @@ -392,7 +392,7 @@ where
};

if ret != RCL_RET_OK as i32 {
println!("action server: could not process cancel request. {}", ret);
log::debug!("action server: could not process cancel request. {}", ret);
return;
}

Expand All @@ -414,7 +414,7 @@ where
};
match cancel_sender.try_send(cr) {
Err(_) => {
eprintln!("warning: could not send goal cancellation request");
log::error!("warning: could not send goal cancellation request");
None
}
_ => Some(r),
Expand All @@ -438,12 +438,12 @@ where
rcl_action_expire_goals(&self.rcl_handle, &mut *goal_info, 1, &mut num_expired)
};
if ret != RCL_RET_OK as i32 {
println!("action server: could not expire goal.");
log::debug!("action server: could not expire goal.");
return;
}
let gi = action_msgs::msg::GoalInfo::from_native(&goal_info);
let uuid = uuid_msg_to_uuid(&gi.goal_id);
println!("goal expired: {} - {}", uuid, num_expired);
log::debug!("goal expired: {} - {}", uuid, num_expired);
// todo
// self.goals.remove(&uuid);
self.result_msgs.remove(&uuid);
Expand All @@ -456,7 +456,7 @@ where
let mut status = rcl_action_get_zero_initialized_goal_status_array();
let ret = rcl_action_get_goal_status_array(&self.rcl_handle, &mut status);
if ret != RCL_RET_OK as i32 {
println!(
log::debug!(
"action server: failed to get goal status array: {}",
Error::from_rcl_error(ret)
);
Expand All @@ -467,7 +467,7 @@ where
&status as *const _ as *const std::os::raw::c_void,
);
if ret != RCL_RET_OK as i32 {
println!(
log::debug!(
"action server: failed to publish status: {}",
Error::from_rcl_error(ret)
);
Expand All @@ -490,7 +490,7 @@ where
rcl_action_send_result_response(&self.rcl_handle, &mut req, msg.void_ptr_mut())
};
if ret != RCL_RET_OK as i32 {
println!(
log::debug!(
"action server: could send result request response. {}",
Error::from_rcl_error(ret)
);
Expand Down Expand Up @@ -551,7 +551,7 @@ where
};

if ret != RCL_RET_OK as i32 {
println!(
log::debug!(
"action server: could send result request response. {}",
Error::from_rcl_error(ret)
);
Expand Down Expand Up @@ -624,7 +624,7 @@ where
};

if ret != RCL_RET_OK as i32 {
eprintln!("coult not publish {}", Error::from_rcl_error(ret));
log::error!("could not publish {}", Error::from_rcl_error(ret));
}
Ok(()) // todo: error codes
}
Expand All @@ -651,7 +651,7 @@ where
unsafe { rcl_action_server_goal_exists(action_server.handle(), &*goal_info_native) };

if !goal_exists {
println!("tried to publish result without a goal");
log::debug!("tried to publish result without a goal");
return Err(Error::RCL_RET_ACTION_GOAL_HANDLE_INVALID);
}

Expand Down
Loading