rustfmt
This commit is contained in:
parent
93cd1756cd
commit
892dd4ab48
|
|
@ -1,11 +1,10 @@
|
|||
|
||||
#[cfg(not(feature = "doc-only"))]
|
||||
use {
|
||||
quote::{format_ident, quote},
|
||||
rayon::prelude::*,
|
||||
std::fmt,
|
||||
std::fs::{File, OpenOptions},
|
||||
std::io::{self, prelude::*, BufWriter},
|
||||
std::fmt,
|
||||
};
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
|
@ -283,11 +282,7 @@ fn generate_bindings(bindgen_dir: &Path) {
|
|||
}
|
||||
|
||||
fn copy_files(src_dir: &Path, tgt_dir: &Path) {
|
||||
eprintln!(
|
||||
"Copy files from '{}' to '{}'",
|
||||
src_dir.display(),
|
||||
tgt_dir.display()
|
||||
);
|
||||
eprintln!("Copy files from '{}' to '{}'", src_dir.display(), tgt_dir.display());
|
||||
|
||||
let src_list_file = src_dir.join(LIST_FILENAME);
|
||||
let tgt_list_file = tgt_dir.join(LIST_FILENAME);
|
||||
|
|
|
|||
|
|
@ -44,11 +44,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
let nested_task_done = nested_task_done.clone();
|
||||
let nested_goal = nested_goal.clone();
|
||||
async move {
|
||||
println!(
|
||||
"new feedback msg {:?} -- {:?}",
|
||||
msg,
|
||||
nested_goal.get_status()
|
||||
);
|
||||
println!("new feedback msg {:?} -- {:?}", msg, nested_goal.get_status());
|
||||
|
||||
// 50/50 that cancel the goal before it finishes.
|
||||
if msg.sequence.len() == 4 && rand::random::<bool>() {
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@ use std::sync::{Arc, Mutex};
|
|||
|
||||
// main goal handling routine.
|
||||
async fn run_goal(
|
||||
node: Arc<Mutex<r2r::Node>>,
|
||||
g: r2r::ActionServerGoal<Fibonacci::Action>,
|
||||
node: Arc<Mutex<r2r::Node>>, g: r2r::ActionServerGoal<Fibonacci::Action>,
|
||||
) -> Fibonacci::Result {
|
||||
let mut timer = node // local timer, will be dropped after this request is processed.
|
||||
.lock()
|
||||
|
|
@ -38,17 +37,13 @@ async fn run_goal(
|
|||
}
|
||||
|
||||
async fn fibonacci_server(
|
||||
spawner: LocalSpawner,
|
||||
node: Arc<Mutex<r2r::Node>>,
|
||||
spawner: LocalSpawner, node: Arc<Mutex<r2r::Node>>,
|
||||
mut requests: impl Stream<Item = r2r::ActionServerGoalRequest<Fibonacci::Action>> + Unpin,
|
||||
) {
|
||||
loop {
|
||||
match requests.next().await {
|
||||
Some(req) => {
|
||||
println!(
|
||||
"Got goal request with order {}, goal id: {}",
|
||||
req.goal.order, req.uuid
|
||||
);
|
||||
println!("Got goal request with order {}, goal id: {}", req.goal.order, req.uuid);
|
||||
// 1/4 chance that we reject the goal for testing.
|
||||
if rand::random::<bool>() && rand::random::<bool>() {
|
||||
println!("rejecting goal");
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ use std::io::Write;
|
|||
use r2r::example_interfaces::srv::AddTwoInts;
|
||||
|
||||
async fn requester_task(
|
||||
node_available: impl Future<Output = r2r::Result<()>>,
|
||||
c: r2r::Client<AddTwoInts::Service>,
|
||||
node_available: impl Future<Output = r2r::Result<()>>, c: r2r::Client<AddTwoInts::Service>,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut x: i64 = 0;
|
||||
println!("waiting for service...");
|
||||
|
|
|
|||
|
|
@ -37,10 +37,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
})?;
|
||||
|
||||
println!("node name: {}", node.name()?);
|
||||
println!(
|
||||
"node fully qualified name: {}",
|
||||
node.fully_qualified_name()?
|
||||
);
|
||||
println!("node fully qualified name: {}", node.fully_qualified_name()?);
|
||||
println!("node namespace: {}", node.namespace()?);
|
||||
|
||||
// print all params every 5 seconds.
|
||||
|
|
|
|||
|
|
@ -78,10 +78,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
spawner.spawn_local(async move {
|
||||
loop {
|
||||
let elapsed = timer.tick().await.expect("could not tick");
|
||||
println!(
|
||||
"doing other async work, {}ms since last call",
|
||||
elapsed.as_millis()
|
||||
);
|
||||
println!("doing other async work, {}ms since last call", elapsed.as_millis());
|
||||
}
|
||||
})?;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@ use futures::task::LocalSpawnExt;
|
|||
use futures::Future;
|
||||
|
||||
async fn requester_task(
|
||||
node_available: impl Future<Output = r2r::Result<()>>,
|
||||
c: r2r::ClientUntyped,
|
||||
node_available: impl Future<Output = r2r::Result<()>>, c: r2r::ClientUntyped,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut x: i64 = 0;
|
||||
println!("waiting for service...");
|
||||
|
|
|
|||
|
|
@ -8,11 +8,7 @@ async fn timer_task(mut t: r2r::Timer) -> Result<(), Box<dyn std::error::Error>>
|
|||
let mut x: i32 = 0;
|
||||
loop {
|
||||
let elapsed = t.tick().await?;
|
||||
println!(
|
||||
"timer called ({}), {}us since last call",
|
||||
x,
|
||||
elapsed.as_micros()
|
||||
);
|
||||
println!("timer called ({}), {}us since last call", x, elapsed.as_micros());
|
||||
|
||||
x += 1;
|
||||
if x == 10 {
|
||||
|
|
|
|||
|
|
@ -86,8 +86,7 @@ where
|
|||
/// - A new future for the eventual result.
|
||||
/// - A stream of feedback messages.
|
||||
pub fn send_goal_request(
|
||||
&self,
|
||||
goal: T::Goal,
|
||||
&self, goal: T::Goal,
|
||||
) -> Result<
|
||||
impl Future<
|
||||
Output = Result<(
|
||||
|
|
@ -219,8 +218,7 @@ where
|
|||
}
|
||||
|
||||
pub fn send_cancel_request(
|
||||
&mut self,
|
||||
goal: &uuid::Uuid,
|
||||
&mut self, goal: &uuid::Uuid,
|
||||
) -> Result<impl Future<Output = Result<()>>>
|
||||
where
|
||||
T: WrappedActionTypeSupport,
|
||||
|
|
@ -326,7 +324,8 @@ where
|
|||
.join(",");
|
||||
log::error!(
|
||||
"no such req id: {}, we have [{}], ignoring",
|
||||
request_id.sequence_number, we_have
|
||||
request_id.sequence_number,
|
||||
we_have
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -364,7 +363,8 @@ where
|
|||
.join(",");
|
||||
log::error!(
|
||||
"no such req id: {}, we have [{}], ignoring",
|
||||
request_id.sequence_number, we_have
|
||||
request_id.sequence_number,
|
||||
we_have
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -453,7 +453,8 @@ where
|
|||
.join(",");
|
||||
log::error!(
|
||||
"no such req id: {}, we have [{}], ignoring",
|
||||
request_id.sequence_number, we_have
|
||||
request_id.sequence_number,
|
||||
we_have
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -513,9 +514,7 @@ where
|
|||
}
|
||||
|
||||
pub fn create_action_client_helper(
|
||||
node: &mut rcl_node_t,
|
||||
action_name: &str,
|
||||
action_ts: *const rosidl_action_type_support_t,
|
||||
node: &mut rcl_node_t, action_name: &str, action_ts: *const rosidl_action_type_support_t,
|
||||
) -> Result<rcl_action_client_t> {
|
||||
let mut client_handle = unsafe { rcl_action_get_zero_initialized_client() };
|
||||
let action_name_c_string =
|
||||
|
|
@ -539,12 +538,8 @@ pub fn create_action_client_helper(
|
|||
}
|
||||
|
||||
pub fn action_client_get_num_waits(
|
||||
rcl_handle: &rcl_action_client_t,
|
||||
num_subs: &mut usize,
|
||||
num_gc: &mut usize,
|
||||
num_timers: &mut usize,
|
||||
num_clients: &mut usize,
|
||||
num_services: &mut usize,
|
||||
rcl_handle: &rcl_action_client_t, num_subs: &mut usize, num_gc: &mut usize,
|
||||
num_timers: &mut usize, num_clients: &mut usize, num_services: &mut usize,
|
||||
) -> Result<()> {
|
||||
unsafe {
|
||||
let result = rcl_action_client_wait_set_get_num_entities(
|
||||
|
|
@ -581,8 +576,7 @@ where
|
|||
}
|
||||
|
||||
pub fn action_server_available_helper(
|
||||
node: &rcl_node_t,
|
||||
client: &rcl_action_client_t,
|
||||
node: &rcl_node_t, client: &rcl_action_client_t,
|
||||
) -> Result<bool> {
|
||||
let mut avail = false;
|
||||
let result = unsafe { rcl_action_server_is_available(node, client, &mut avail) };
|
||||
|
|
|
|||
|
|
@ -165,10 +165,7 @@ pub fn make_action_client_untyped(
|
|||
ActionClientUntyped { client }
|
||||
}
|
||||
|
||||
pub type ResultSender = (
|
||||
uuid::Uuid,
|
||||
oneshot::Sender<(GoalStatus, Result<serde_json::Value>)>,
|
||||
);
|
||||
pub type ResultSender = (uuid::Uuid, oneshot::Sender<(GoalStatus, Result<serde_json::Value>)>);
|
||||
pub struct WrappedActionClientUntyped {
|
||||
pub action_type_support: UntypedActionSupport,
|
||||
pub rcl_handle: rcl_action_client_t,
|
||||
|
|
@ -189,8 +186,7 @@ impl WrappedActionClientUntyped {
|
|||
}
|
||||
|
||||
pub fn send_cancel_request(
|
||||
&mut self,
|
||||
goal: &uuid::Uuid,
|
||||
&mut self, goal: &uuid::Uuid,
|
||||
) -> Result<impl Future<Output = Result<()>>> {
|
||||
let msg = action_msgs::srv::CancelGoal::Request {
|
||||
goal_info: action_msgs::msg::GoalInfo {
|
||||
|
|
@ -288,7 +284,8 @@ impl ActionClient_ for WrappedActionClientUntyped {
|
|||
.join(",");
|
||||
log::error!(
|
||||
"no such req id: {}, we have [{}], ignoring",
|
||||
request_id.sequence_number, we_have
|
||||
request_id.sequence_number,
|
||||
we_have
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -326,7 +323,8 @@ impl ActionClient_ for WrappedActionClientUntyped {
|
|||
.join(",");
|
||||
log::error!(
|
||||
"no such req id: {}, we have [{}], ignoring",
|
||||
request_id.sequence_number, we_have
|
||||
request_id.sequence_number,
|
||||
we_have
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -412,7 +410,8 @@ impl ActionClient_ for WrappedActionClientUntyped {
|
|||
.join(",");
|
||||
log::error!(
|
||||
"no such req id: {}, we have [{}], ignoring",
|
||||
request_id.sequence_number, we_have
|
||||
request_id.sequence_number,
|
||||
we_have
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ pub trait ActionServer_ {
|
|||
fn handle_goal_expired(&mut self);
|
||||
fn publish_status(&self);
|
||||
fn set_goal_state(
|
||||
&mut self,
|
||||
uuid: &uuid::Uuid,
|
||||
new_state: rcl_action_goal_event_t,
|
||||
&mut self, uuid: &uuid::Uuid, new_state: rcl_action_goal_event_t,
|
||||
) -> Result<()>;
|
||||
fn add_result(&mut self, uuid: uuid::Uuid, msg: Box<dyn VoidPtr>);
|
||||
fn cancel_goal(&mut self, uuid: &uuid::Uuid);
|
||||
|
|
@ -77,10 +75,7 @@ where
|
|||
/// Returns a handle to the goal and a stream on which cancel requests can be received.
|
||||
pub fn accept(
|
||||
mut self,
|
||||
) -> Result<(
|
||||
ActionServerGoal<T>,
|
||||
impl Stream<Item = ActionServerCancelRequest> + Unpin,
|
||||
)> {
|
||||
) -> Result<(ActionServerGoal<T>, impl Stream<Item = ActionServerCancelRequest> + Unpin)> {
|
||||
let uuid_msg = unique_identifier_msgs::msg::UUID {
|
||||
uuid: self.uuid.as_bytes().to_vec(),
|
||||
};
|
||||
|
|
@ -213,18 +208,13 @@ where
|
|||
};
|
||||
|
||||
if ret != RCL_RET_OK as i32 {
|
||||
log::debug!(
|
||||
"action server: could not cancel goal: {}",
|
||||
Error::from_rcl_error(ret)
|
||||
);
|
||||
log::debug!("action server: could not cancel goal: {}", Error::from_rcl_error(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn set_goal_state(
|
||||
&mut self,
|
||||
uuid: &uuid::Uuid,
|
||||
new_state: rcl_action_goal_event_t,
|
||||
&mut self, uuid: &uuid::Uuid, new_state: rcl_action_goal_event_t,
|
||||
) -> Result<()> {
|
||||
let goal_info = action_msgs::msg::GoalInfo {
|
||||
goal_id: unique_identifier_msgs::msg::UUID {
|
||||
|
|
@ -725,9 +715,7 @@ where
|
|||
}
|
||||
|
||||
pub fn create_action_server_helper(
|
||||
node: &mut rcl_node_t,
|
||||
action_name: &str,
|
||||
clock_handle: *mut rcl_clock_t,
|
||||
node: &mut rcl_node_t, action_name: &str, clock_handle: *mut rcl_clock_t,
|
||||
action_ts: *const rosidl_action_type_support_t,
|
||||
) -> Result<rcl_action_server_t> {
|
||||
let mut server_handle = unsafe { rcl_action_get_zero_initialized_server() };
|
||||
|
|
@ -754,12 +742,8 @@ pub fn create_action_server_helper(
|
|||
}
|
||||
|
||||
pub fn action_server_get_num_waits(
|
||||
rcl_handle: &rcl_action_server_t,
|
||||
num_subs: &mut usize,
|
||||
num_gc: &mut usize,
|
||||
num_timers: &mut usize,
|
||||
num_clients: &mut usize,
|
||||
num_services: &mut usize,
|
||||
rcl_handle: &rcl_action_server_t, num_subs: &mut usize, num_gc: &mut usize,
|
||||
num_timers: &mut usize, num_clients: &mut usize, num_services: &mut usize,
|
||||
) -> Result<()> {
|
||||
unsafe {
|
||||
let result = rcl_action_server_wait_set_get_num_entities(
|
||||
|
|
|
|||
|
|
@ -57,8 +57,7 @@ impl ClientUntyped {
|
|||
///
|
||||
/// Returns a `Future` of Result<serde_json::Value>.
|
||||
pub fn request(
|
||||
&self,
|
||||
msg: serde_json::Value,
|
||||
&self, msg: serde_json::Value,
|
||||
) -> Result<impl Future<Output = Result<Result<serde_json::Value>>>> {
|
||||
// upgrade to actual ref. if still alive
|
||||
let client = self.client.upgrade().ok_or(Error::RCL_RET_CLIENT_INVALID)?;
|
||||
|
|
@ -110,8 +109,7 @@ unsafe impl Send for UntypedClient_ {}
|
|||
|
||||
impl UntypedClient_ {
|
||||
pub fn request(
|
||||
&mut self,
|
||||
msg: serde_json::Value,
|
||||
&mut self, msg: serde_json::Value,
|
||||
) -> Result<impl Future<Output = Result<Result<serde_json::Value>>>> {
|
||||
let native_msg = (self.service_type.make_request_msg)();
|
||||
native_msg.from_json(msg)?;
|
||||
|
|
@ -193,7 +191,8 @@ where
|
|||
.join(",");
|
||||
log::error!(
|
||||
"no such req id: {}, we have [{}], ignoring",
|
||||
request_id.sequence_number, we_have
|
||||
request_id.sequence_number,
|
||||
we_have
|
||||
);
|
||||
}
|
||||
} // TODO handle failure.
|
||||
|
|
@ -279,7 +278,8 @@ impl Client_ for UntypedClient_ {
|
|||
.join(",");
|
||||
log::error!(
|
||||
"no such req id: {}, we have [{}], ignoring",
|
||||
request_id.sequence_number, we_have
|
||||
request_id.sequence_number,
|
||||
we_have
|
||||
);
|
||||
}
|
||||
} // TODO handle failure.
|
||||
|
|
@ -319,9 +319,7 @@ impl Client_ for UntypedClient_ {
|
|||
}
|
||||
|
||||
pub fn create_client_helper(
|
||||
node: *mut rcl_node_t,
|
||||
service_name: &str,
|
||||
service_ts: *const rosidl_service_type_support_t,
|
||||
node: *mut rcl_node_t, service_name: &str, service_ts: *const rosidl_service_type_support_t,
|
||||
) -> Result<rcl_client_t> {
|
||||
let mut client_handle = unsafe { rcl_get_zero_initialized_client() };
|
||||
let service_name_c_string =
|
||||
|
|
|
|||
|
|
@ -36,11 +36,7 @@ impl Clock {
|
|||
|
||||
let rcl_ct = clock_type_to_rcl(&ct);
|
||||
let ret = unsafe {
|
||||
rcl_clock_init(
|
||||
rcl_ct,
|
||||
clock_handle.as_mut_ptr(),
|
||||
&mut rcutils_get_default_allocator(),
|
||||
)
|
||||
rcl_clock_init(rcl_ct, clock_handle.as_mut_ptr(), &mut rcutils_get_default_allocator())
|
||||
};
|
||||
if ret != RCL_RET_OK as i32 {
|
||||
log::error!("could not create {:?} clock: {}", ct, ret);
|
||||
|
|
|
|||
|
|
@ -13,14 +13,8 @@ pub mod generated_msgs {
|
|||
#![allow(clippy::all)]
|
||||
use super::*;
|
||||
include!(concat!(env!("OUT_DIR"), "/_r2r_generated_msgs.rs"));
|
||||
include!(concat!(
|
||||
env!("OUT_DIR"),
|
||||
"/_r2r_generated_untyped_helper.rs"
|
||||
));
|
||||
include!(concat!(
|
||||
env!("OUT_DIR"),
|
||||
"/_r2r_generated_service_helper.rs"
|
||||
));
|
||||
include!(concat!(env!("OUT_DIR"), "/_r2r_generated_untyped_helper.rs"));
|
||||
include!(concat!(env!("OUT_DIR"), "/_r2r_generated_service_helper.rs"));
|
||||
include!(concat!(env!("OUT_DIR"), "/_r2r_generated_action_helper.rs"));
|
||||
}
|
||||
|
||||
|
|
@ -70,23 +64,19 @@ pub trait WrappedActionTypeSupport: Debug + Clone {
|
|||
fn get_ts() -> &'static rosidl_action_type_support_t;
|
||||
|
||||
fn make_goal_request_msg(
|
||||
goal_id: unique_identifier_msgs::msg::UUID,
|
||||
goal: Self::Goal,
|
||||
goal_id: unique_identifier_msgs::msg::UUID, goal: Self::Goal,
|
||||
) -> <<Self as WrappedActionTypeSupport>::SendGoal as WrappedServiceTypeSupport>::Request;
|
||||
fn make_goal_response_msg(
|
||||
accepted: bool,
|
||||
stamp: builtin_interfaces::msg::Time,
|
||||
accepted: bool, stamp: builtin_interfaces::msg::Time,
|
||||
) -> <<Self as WrappedActionTypeSupport>::SendGoal as WrappedServiceTypeSupport>::Response;
|
||||
fn make_feedback_msg(
|
||||
goal_id: unique_identifier_msgs::msg::UUID,
|
||||
feedback: Self::Feedback,
|
||||
goal_id: unique_identifier_msgs::msg::UUID, feedback: Self::Feedback,
|
||||
) -> Self::FeedbackMessage;
|
||||
fn make_result_request_msg(
|
||||
goal_id: unique_identifier_msgs::msg::UUID,
|
||||
) -> <<Self as WrappedActionTypeSupport>::GetResult as WrappedServiceTypeSupport>::Request;
|
||||
fn make_result_response_msg(
|
||||
status: i8,
|
||||
result: Self::Result,
|
||||
status: i8, result: Self::Result,
|
||||
) -> <<Self as WrappedActionTypeSupport>::GetResult as WrappedServiceTypeSupport>::Response;
|
||||
fn destructure_goal_request_msg(
|
||||
msg: <<Self as WrappedActionTypeSupport>::SendGoal as WrappedServiceTypeSupport>::Request,
|
||||
|
|
@ -366,8 +356,7 @@ where
|
|||
}
|
||||
|
||||
pub fn from_loaned(
|
||||
msg: *mut T::CStruct,
|
||||
deallocator: Box<dyn FnOnce(*mut <T as WrappedTypesupport>::CStruct)>,
|
||||
msg: *mut T::CStruct, deallocator: Box<dyn FnOnce(*mut <T as WrappedTypesupport>::CStruct)>,
|
||||
) -> Self {
|
||||
WrappedNativeMsg {
|
||||
msg,
|
||||
|
|
|
|||
|
|
@ -207,10 +207,8 @@ impl Node {
|
|||
/// its new value.
|
||||
pub fn make_parameter_handler(
|
||||
&mut self,
|
||||
) -> Result<(
|
||||
impl Future<Output = ()> + Send,
|
||||
impl Stream<Item = (String, ParameterValue)>,
|
||||
)> {
|
||||
) -> Result<(impl Future<Output = ()> + Send, impl Stream<Item = (String, ParameterValue)>)>
|
||||
{
|
||||
let mut handlers: Vec<std::pin::Pin<Box<dyn Future<Output = ()> + Send>>> = Vec::new();
|
||||
let (mut event_tx, event_rx) = mpsc::channel::<(String, ParameterValue)>(10);
|
||||
|
||||
|
|
@ -292,9 +290,7 @@ impl Node {
|
|||
///
|
||||
/// This function returns a `Stream` of ros messages.
|
||||
pub fn subscribe<T: 'static>(
|
||||
&mut self,
|
||||
topic: &str,
|
||||
qos_profile: QosProfile,
|
||||
&mut self, topic: &str, qos_profile: QosProfile,
|
||||
) -> Result<impl Stream<Item = T> + Unpin>
|
||||
where
|
||||
T: WrappedTypesupport,
|
||||
|
|
@ -315,9 +311,7 @@ impl Node {
|
|||
///
|
||||
/// This function returns a `Stream` of ros messages without the rust convenience types.
|
||||
pub fn subscribe_native<T: 'static>(
|
||||
&mut self,
|
||||
topic: &str,
|
||||
qos_profile: QosProfile,
|
||||
&mut self, topic: &str, qos_profile: QosProfile,
|
||||
) -> Result<impl Stream<Item = WrappedNativeMsg<T>> + Unpin>
|
||||
where
|
||||
T: WrappedTypesupport,
|
||||
|
|
@ -339,10 +333,7 @@ impl Node {
|
|||
/// This function returns a `Stream` of ros messages as `serde_json::Value`:s.
|
||||
/// Useful when you cannot know the type of the message at compile time.
|
||||
pub fn subscribe_untyped(
|
||||
&mut self,
|
||||
topic: &str,
|
||||
topic_type: &str,
|
||||
qos_profile: QosProfile,
|
||||
&mut self, topic: &str, topic_type: &str, qos_profile: QosProfile,
|
||||
) -> Result<impl Stream<Item = Result<serde_json::Value>> + Unpin> {
|
||||
let msg = WrappedNativeMsgUntyped::new_from(topic_type)?;
|
||||
let subscription_handle =
|
||||
|
|
@ -363,8 +354,7 @@ impl Node {
|
|||
/// This function returns a `Stream` of `ServiceRequest`:s. Call
|
||||
/// `respond` on the Service Request to send the reply.
|
||||
pub fn create_service<T: 'static>(
|
||||
&mut self,
|
||||
service_name: &str,
|
||||
&mut self, service_name: &str,
|
||||
) -> Result<impl Stream<Item = ServiceRequest<T>> + Unpin>
|
||||
where
|
||||
T: WrappedServiceTypeSupport,
|
||||
|
|
@ -411,9 +401,7 @@ impl Node {
|
|||
/// with `serde_json::Value`s instead of concrete types. Useful
|
||||
/// when you cannot know the type of the message at compile time.
|
||||
pub fn create_client_untyped(
|
||||
&mut self,
|
||||
service_name: &str,
|
||||
service_type: &str,
|
||||
&mut self, service_name: &str, service_type: &str,
|
||||
) -> Result<ClientUntyped> {
|
||||
let service_type = UntypedServiceSupport::new_from(service_type)?;
|
||||
let client_handle =
|
||||
|
|
@ -439,8 +427,7 @@ impl Node {
|
|||
/// `spin_once` until available, so spin_once must be called
|
||||
/// repeatedly in order to get the wakeup.
|
||||
pub fn is_available(
|
||||
&mut self,
|
||||
client: &dyn IsAvailablePollable,
|
||||
&mut self, client: &dyn IsAvailablePollable,
|
||||
) -> Result<impl Future<Output = Result<()>>> {
|
||||
let (sender, receiver) = oneshot::channel();
|
||||
client.register_poll_available(sender)?;
|
||||
|
|
@ -480,9 +467,7 @@ impl Node {
|
|||
/// with `serde_json::Value`s instead of concrete types. Useful
|
||||
/// when you cannot know the type of the message at compile time.
|
||||
pub fn create_action_client_untyped(
|
||||
&mut self,
|
||||
action_name: &str,
|
||||
action_type: &str,
|
||||
&mut self, action_name: &str, action_type: &str,
|
||||
) -> Result<ActionClientUntyped> {
|
||||
let action_type_support = UntypedActionSupport::new_from(action_type)?;
|
||||
let client_handle = create_action_client_helper(
|
||||
|
|
@ -513,8 +498,7 @@ impl Node {
|
|||
/// This function returns a stream of `GoalRequest`s, which needs
|
||||
/// to be either accepted or rejected.
|
||||
pub fn create_action_server<T: 'static>(
|
||||
&mut self,
|
||||
action_name: &str,
|
||||
&mut self, action_name: &str,
|
||||
) -> Result<impl Stream<Item = ActionServerGoalRequest<T>> + Unpin>
|
||||
where
|
||||
T: WrappedActionTypeSupport,
|
||||
|
|
@ -522,10 +506,7 @@ impl Node {
|
|||
// for now automatically create a ros clock...
|
||||
let mut clock_handle = MaybeUninit::<rcl_clock_t>::uninit();
|
||||
let ret = unsafe {
|
||||
rcl_ros_clock_init(
|
||||
clock_handle.as_mut_ptr(),
|
||||
&mut rcutils_get_default_allocator(),
|
||||
)
|
||||
rcl_ros_clock_init(clock_handle.as_mut_ptr(), &mut rcutils_get_default_allocator())
|
||||
};
|
||||
if ret != RCL_RET_OK as i32 {
|
||||
log::error!("could not create steady clock: {}", ret);
|
||||
|
|
@ -560,9 +541,7 @@ impl Node {
|
|||
|
||||
/// Create a ROS publisher.
|
||||
pub fn create_publisher<T>(
|
||||
&mut self,
|
||||
topic: &str,
|
||||
qos_profile: QosProfile,
|
||||
&mut self, topic: &str, qos_profile: QosProfile,
|
||||
) -> Result<Publisher<T>>
|
||||
where
|
||||
T: WrappedTypesupport,
|
||||
|
|
@ -577,10 +556,7 @@ impl Node {
|
|||
|
||||
/// Create a ROS publisher with a type given at runtime.
|
||||
pub fn create_publisher_untyped(
|
||||
&mut self,
|
||||
topic: &str,
|
||||
topic_type: &str,
|
||||
qos_profile: QosProfile,
|
||||
&mut self, topic: &str, topic_type: &str, qos_profile: QosProfile,
|
||||
) -> Result<PublisherUntyped> {
|
||||
let dummy = WrappedNativeMsgUntyped::new_from(topic_type)?;
|
||||
let publisher_handle =
|
||||
|
|
|
|||
|
|
@ -77,9 +77,7 @@ pub fn make_publisher_untyped(handle: Weak<rcl_publisher_t>, type_: String) -> P
|
|||
}
|
||||
|
||||
pub fn create_publisher_helper(
|
||||
node: &mut rcl_node_t,
|
||||
topic: &str,
|
||||
typesupport: *const rosidl_message_type_support_t,
|
||||
node: &mut rcl_node_t, topic: &str, typesupport: *const rosidl_message_type_support_t,
|
||||
qos_profile: QosProfile,
|
||||
) -> Result<rcl_publisher_t> {
|
||||
let mut publisher_handle = unsafe { rcl_get_zero_initialized_publisher() };
|
||||
|
|
@ -117,13 +115,8 @@ impl PublisherUntyped {
|
|||
let native_msg = WrappedNativeMsgUntyped::new_from(&self.type_)?;
|
||||
native_msg.from_json(msg)?;
|
||||
|
||||
let result = unsafe {
|
||||
rcl_publish(
|
||||
publisher.as_ref(),
|
||||
native_msg.void_ptr(),
|
||||
std::ptr::null_mut(),
|
||||
)
|
||||
};
|
||||
let result =
|
||||
unsafe { rcl_publish(publisher.as_ref(), native_msg.void_ptr(), std::ptr::null_mut()) };
|
||||
|
||||
if result == RCL_RET_OK as i32 {
|
||||
Ok(())
|
||||
|
|
@ -149,13 +142,8 @@ where
|
|||
.upgrade()
|
||||
.ok_or(Error::RCL_RET_PUBLISHER_INVALID)?;
|
||||
let native_msg: WrappedNativeMsg<T> = WrappedNativeMsg::<T>::from(msg);
|
||||
let result = unsafe {
|
||||
rcl_publish(
|
||||
publisher.as_ref(),
|
||||
native_msg.void_ptr(),
|
||||
std::ptr::null_mut(),
|
||||
)
|
||||
};
|
||||
let result =
|
||||
unsafe { rcl_publish(publisher.as_ref(), native_msg.void_ptr(), std::ptr::null_mut()) };
|
||||
|
||||
if result == RCL_RET_OK as i32 {
|
||||
Ok(())
|
||||
|
|
@ -208,7 +196,9 @@ where
|
|||
} else {
|
||||
static LOG_LOANED_ERROR: Once = Once::new();
|
||||
LOG_LOANED_ERROR.call_once(|| {
|
||||
log::error!("Currently used middleware can't loan messages. Local allocator will be used.");
|
||||
log::error!(
|
||||
"Currently used middleware can't loan messages. Local allocator will be used."
|
||||
);
|
||||
});
|
||||
|
||||
Ok(WrappedNativeMsg::<T>::new())
|
||||
|
|
|
|||
|
|
@ -695,8 +695,7 @@ impl QosProfile {
|
|||
/// let qos = QosProfile::default().avoid_ros_namespace_conventions(true);
|
||||
/// ```
|
||||
pub const fn avoid_ros_namespace_conventions(
|
||||
self,
|
||||
avoid_ros_namespace_conventions: bool,
|
||||
self, avoid_ros_namespace_conventions: bool,
|
||||
) -> Self {
|
||||
Self {
|
||||
avoid_ros_namespace_conventions,
|
||||
|
|
|
|||
|
|
@ -68,9 +68,7 @@ where
|
|||
}
|
||||
|
||||
fn send_response(
|
||||
&mut self,
|
||||
mut request_id: rmw_request_id_t,
|
||||
mut msg: Box<dyn VoidPtr>,
|
||||
&mut self, mut request_id: rmw_request_id_t, mut msg: Box<dyn VoidPtr>,
|
||||
) -> Result<()> {
|
||||
let res =
|
||||
unsafe { rcl_send_response(&self.rcl_handle, &mut request_id, msg.void_ptr_mut()) };
|
||||
|
|
@ -86,11 +84,7 @@ where
|
|||
let mut request_msg = WrappedNativeMsg::<T::Request>::new();
|
||||
|
||||
let ret = unsafe {
|
||||
rcl_take_request(
|
||||
&self.rcl_handle,
|
||||
request_id.as_mut_ptr(),
|
||||
request_msg.void_ptr_mut(),
|
||||
)
|
||||
rcl_take_request(&self.rcl_handle, request_id.as_mut_ptr(), request_msg.void_ptr_mut())
|
||||
};
|
||||
if ret == RCL_RET_OK as i32 {
|
||||
let request_id = unsafe { request_id.assume_init() };
|
||||
|
|
@ -118,9 +112,7 @@ where
|
|||
}
|
||||
|
||||
pub fn create_service_helper(
|
||||
node: &mut rcl_node_t,
|
||||
service_name: &str,
|
||||
service_ts: *const rosidl_service_type_support_t,
|
||||
node: &mut rcl_node_t, service_name: &str, service_ts: *const rosidl_service_type_support_t,
|
||||
) -> Result<rcl_service_t> {
|
||||
let mut service_handle = unsafe { rcl_get_zero_initialized_service() };
|
||||
let service_name_c_string =
|
||||
|
|
|
|||
|
|
@ -49,12 +49,7 @@ where
|
|||
let mut msg_info = rmw_message_info_t::default(); // we dont care for now
|
||||
let mut msg = WrappedNativeMsg::<T>::new();
|
||||
let ret = unsafe {
|
||||
rcl_take(
|
||||
&self.rcl_handle,
|
||||
msg.void_ptr_mut(),
|
||||
&mut msg_info,
|
||||
std::ptr::null_mut(),
|
||||
)
|
||||
rcl_take(&self.rcl_handle, msg.void_ptr_mut(), &mut msg_info, std::ptr::null_mut())
|
||||
};
|
||||
if ret == RCL_RET_OK as i32 {
|
||||
let msg = T::from_native(&msg);
|
||||
|
|
@ -162,12 +157,7 @@ impl Subscriber_ for UntypedSubscriber {
|
|||
let mut msg = WrappedNativeMsgUntyped::new_from(&self.topic_type)
|
||||
.unwrap_or_else(|_| panic!("no typesupport for {}", self.topic_type));
|
||||
let ret = unsafe {
|
||||
rcl_take(
|
||||
&self.rcl_handle,
|
||||
msg.void_ptr_mut(),
|
||||
&mut msg_info,
|
||||
std::ptr::null_mut(),
|
||||
)
|
||||
rcl_take(&self.rcl_handle, msg.void_ptr_mut(), &mut msg_info, std::ptr::null_mut())
|
||||
};
|
||||
if ret == RCL_RET_OK as i32 {
|
||||
let json = msg.to_json();
|
||||
|
|
@ -190,9 +180,7 @@ impl Subscriber_ for UntypedSubscriber {
|
|||
}
|
||||
|
||||
pub fn create_subscription_helper(
|
||||
node: &mut rcl_node_t,
|
||||
topic: &str,
|
||||
ts: *const rosidl_message_type_support_t,
|
||||
node: &mut rcl_node_t, topic: &str, ts: *const rosidl_message_type_support_t,
|
||||
qos_profile: QosProfile,
|
||||
) -> Result<rcl_subscription_t> {
|
||||
let mut subscription_handle = unsafe { rcl_get_zero_initialized_subscription() };
|
||||
|
|
|
|||
|
|
@ -77,13 +77,7 @@ impl LogSeverity {
|
|||
#[macro_export]
|
||||
macro_rules! __impl_log {
|
||||
($logger_name:expr, $msg:expr, $file:expr, $line:expr, $severity:expr) => {{
|
||||
$crate::log(
|
||||
&std::fmt::format($msg),
|
||||
$logger_name,
|
||||
$file,
|
||||
$line,
|
||||
$severity,
|
||||
);
|
||||
$crate::log(&std::fmt::format($msg), $logger_name, $file, $line, $severity);
|
||||
}};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,11 +25,7 @@ fn run_bindgen() {
|
|||
|
||||
if cfg!(feature = "doc-only") {
|
||||
// If "doc-only" feature is present, copy from $crate/bindings/* to OUT_DIR
|
||||
eprintln!(
|
||||
"Copy from '{}' to '{}'",
|
||||
saved_file.display(),
|
||||
target_file.display()
|
||||
);
|
||||
eprintln!("Copy from '{}' to '{}'", saved_file.display(), target_file.display());
|
||||
fs::copy(&saved_file, &target_file).unwrap();
|
||||
} else {
|
||||
// If bindgen was done before, use cached files.
|
||||
|
|
|
|||
|
|
@ -409,9 +409,6 @@ std_msgs/msg/String
|
|||
let map = as_map(&parsed);
|
||||
|
||||
assert_eq!(map.get("std_msgs").unwrap().get("msg").unwrap()[0], "Bool");
|
||||
assert_eq!(
|
||||
map.get("std_msgs").unwrap().get("msg").unwrap()[1],
|
||||
"String"
|
||||
);
|
||||
assert_eq!(map.get("std_msgs").unwrap().get("msg").unwrap()[1], "String");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,11 +50,7 @@ fn run_bindgen(msg_list: &[RosMsg]) {
|
|||
|
||||
if cfg!(feature = "doc-only") {
|
||||
// If "doc-only" feature is present, copy from $crate/bindings/* to OUT_DIR
|
||||
eprintln!(
|
||||
"Copy files from '{}' to '{}'",
|
||||
save_dir.display(),
|
||||
out_dir.display()
|
||||
);
|
||||
eprintln!("Copy files from '{}' to '{}'", save_dir.display(), out_dir.display());
|
||||
|
||||
for filename in GENERATED_FILES {
|
||||
let src = save_dir.join(filename);
|
||||
|
|
@ -549,14 +545,8 @@ fn run_dynlink(msg_list: &[RosMsg]) {
|
|||
|
||||
let msg_map = r2r_common::as_map(msg_list);
|
||||
for module in msg_map.keys() {
|
||||
println!(
|
||||
"cargo:rustc-link-lib=dylib={}__rosidl_typesupport_c",
|
||||
module
|
||||
);
|
||||
println!(
|
||||
"cargo:rustc-link-lib=dylib={}__rosidl_typesupport_introspection_c",
|
||||
module
|
||||
);
|
||||
println!("cargo:rustc-link-lib=dylib={}__rosidl_typesupport_c", module);
|
||||
println!("cargo:rustc-link-lib=dylib={}__rosidl_typesupport_introspection_c", module);
|
||||
println!("cargo:rustc-link-lib=dylib={}__rosidl_generator_c", module);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,20 +149,12 @@ unsafe fn introspection<'a>(
|
|||
msgname = name
|
||||
);
|
||||
let memberslice = slice::from_raw_parts((*members).members_, (*members).member_count_ as usize);
|
||||
(
|
||||
module.to_owned(),
|
||||
prefix.to_owned(),
|
||||
name.to_owned(),
|
||||
c_struct,
|
||||
memberslice,
|
||||
)
|
||||
(module.to_owned(), prefix.to_owned(), name.to_owned(), c_struct, memberslice)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "doc-only"))]
|
||||
pub fn generate_rust_service(
|
||||
module_: &str,
|
||||
prefix_: &str,
|
||||
name_: &str,
|
||||
module_: &str, prefix_: &str, name_: &str,
|
||||
) -> proc_macro2::TokenStream {
|
||||
let ident = format_ident!(
|
||||
"rosidl_typesupport_c__\
|
||||
|
|
|
|||
|
|
@ -48,11 +48,7 @@ fn run_bindgen() {
|
|||
};
|
||||
|
||||
fs::copy(src_file, &target_file).unwrap_or_else(|_| {
|
||||
panic!(
|
||||
"Unable to copy from '{}' to '{}'",
|
||||
src_file.display(),
|
||||
target_file.display()
|
||||
)
|
||||
panic!("Unable to copy from '{}' to '{}'", src_file.display(), target_file.display())
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,3 +2,5 @@ hard_tabs = false
|
|||
tab_spaces = 4
|
||||
reorder_imports = true
|
||||
newline_style = "Unix"
|
||||
fn_call_width = 80
|
||||
fn_params_layout = "Compressed"
|
||||
|
|
|
|||
Loading…
Reference in New Issue