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