Run rustfmt
This commit is contained in:
parent
a042dc8c55
commit
e8dd2bf9ab
|
|
@ -250,10 +250,24 @@ where
|
||||||
.map_err(|_| Error::RCL_RET_CLIENT_INVALID)
|
.map_err(|_| Error::RCL_RET_CLIENT_INVALID)
|
||||||
.map(|r| match r {
|
.map(|r| match r {
|
||||||
Ok(r) => match r.return_code {
|
Ok(r) => match r.return_code {
|
||||||
e if e == action_msgs::srv::CancelGoal::Response::ERROR_NONE as i8 => Ok(()),
|
e if e == action_msgs::srv::CancelGoal::Response::ERROR_NONE as i8 => {
|
||||||
e if e == action_msgs::srv::CancelGoal::Response::ERROR_REJECTED as i8 => Err(Error::GoalCancelRejected),
|
Ok(())
|
||||||
e if e == action_msgs::srv::CancelGoal::Response::ERROR_UNKNOWN_GOAL_ID as i8 => Err(Error::GoalCancelUnknownGoalID),
|
}
|
||||||
e if e == action_msgs::srv::CancelGoal::Response::ERROR_GOAL_TERMINATED as i8 => Err(Error::GoalCancelAlreadyTerminated),
|
e if e == action_msgs::srv::CancelGoal::Response::ERROR_REJECTED as i8 => {
|
||||||
|
Err(Error::GoalCancelRejected)
|
||||||
|
}
|
||||||
|
e if e
|
||||||
|
== action_msgs::srv::CancelGoal::Response::ERROR_UNKNOWN_GOAL_ID
|
||||||
|
as i8 =>
|
||||||
|
{
|
||||||
|
Err(Error::GoalCancelUnknownGoalID)
|
||||||
|
}
|
||||||
|
e if e
|
||||||
|
== action_msgs::srv::CancelGoal::Response::ERROR_GOAL_TERMINATED
|
||||||
|
as i8 =>
|
||||||
|
{
|
||||||
|
Err(Error::GoalCancelAlreadyTerminated)
|
||||||
|
}
|
||||||
x => panic!("unknown error code return from action server: {}", x),
|
x => panic!("unknown error code return from action server: {}", x),
|
||||||
},
|
},
|
||||||
Err(e) => Err(e),
|
Err(e) => Err(e),
|
||||||
|
|
|
||||||
|
|
@ -217,10 +217,24 @@ impl WrappedActionClientUntyped {
|
||||||
.map_err(|_| Error::RCL_RET_CLIENT_INVALID)
|
.map_err(|_| Error::RCL_RET_CLIENT_INVALID)
|
||||||
.map(|r| match r {
|
.map(|r| match r {
|
||||||
Ok(r) => match r.return_code {
|
Ok(r) => match r.return_code {
|
||||||
e if e == action_msgs::srv::CancelGoal::Response::ERROR_NONE as i8 => Ok(()),
|
e if e == action_msgs::srv::CancelGoal::Response::ERROR_NONE as i8 => {
|
||||||
e if e == action_msgs::srv::CancelGoal::Response::ERROR_REJECTED as i8 => Err(Error::GoalCancelRejected),
|
Ok(())
|
||||||
e if e == action_msgs::srv::CancelGoal::Response::ERROR_UNKNOWN_GOAL_ID as i8 => Err(Error::GoalCancelUnknownGoalID),
|
}
|
||||||
e if e == action_msgs::srv::CancelGoal::Response::ERROR_GOAL_TERMINATED as i8 => Err(Error::GoalCancelAlreadyTerminated),
|
e if e == action_msgs::srv::CancelGoal::Response::ERROR_REJECTED as i8 => {
|
||||||
|
Err(Error::GoalCancelRejected)
|
||||||
|
}
|
||||||
|
e if e
|
||||||
|
== action_msgs::srv::CancelGoal::Response::ERROR_UNKNOWN_GOAL_ID
|
||||||
|
as i8 =>
|
||||||
|
{
|
||||||
|
Err(Error::GoalCancelUnknownGoalID)
|
||||||
|
}
|
||||||
|
e if e
|
||||||
|
== action_msgs::srv::CancelGoal::Response::ERROR_GOAL_TERMINATED
|
||||||
|
as i8 =>
|
||||||
|
{
|
||||||
|
Err(Error::GoalCancelAlreadyTerminated)
|
||||||
|
}
|
||||||
x => panic!("unknown error code return from action server: {}", x),
|
x => panic!("unknown error code return from action server: {}", x),
|
||||||
},
|
},
|
||||||
Err(e) => Err(e),
|
Err(e) => Err(e),
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,27 @@ impl GoalStatus {
|
||||||
|
|
||||||
pub fn from_rcl(s: i8) -> Self {
|
pub fn from_rcl(s: i8) -> Self {
|
||||||
match s {
|
match s {
|
||||||
s if s == crate::action_msgs::msg::GoalStatus::STATUS_UNKNOWN as i8 => GoalStatus::Unknown,
|
s if s == crate::action_msgs::msg::GoalStatus::STATUS_UNKNOWN as i8 => {
|
||||||
s if s == crate::action_msgs::msg::GoalStatus::STATUS_ACCEPTED as i8 => GoalStatus::Accepted,
|
GoalStatus::Unknown
|
||||||
s if s == crate::action_msgs::msg::GoalStatus::STATUS_EXECUTING as i8 => GoalStatus::Executing,
|
}
|
||||||
s if s == crate::action_msgs::msg::GoalStatus::STATUS_CANCELING as i8 => GoalStatus::Canceling,
|
s if s == crate::action_msgs::msg::GoalStatus::STATUS_ACCEPTED as i8 => {
|
||||||
s if s == crate::action_msgs::msg::GoalStatus::STATUS_SUCCEEDED as i8 => GoalStatus::Succeeded,
|
GoalStatus::Accepted
|
||||||
s if s == crate::action_msgs::msg::GoalStatus::STATUS_CANCELED as i8 => GoalStatus::Canceled,
|
}
|
||||||
s if s == crate::action_msgs::msg::GoalStatus::STATUS_ABORTED as i8 => GoalStatus::Aborted,
|
s if s == crate::action_msgs::msg::GoalStatus::STATUS_EXECUTING as i8 => {
|
||||||
|
GoalStatus::Executing
|
||||||
|
}
|
||||||
|
s if s == crate::action_msgs::msg::GoalStatus::STATUS_CANCELING as i8 => {
|
||||||
|
GoalStatus::Canceling
|
||||||
|
}
|
||||||
|
s if s == crate::action_msgs::msg::GoalStatus::STATUS_SUCCEEDED as i8 => {
|
||||||
|
GoalStatus::Succeeded
|
||||||
|
}
|
||||||
|
s if s == crate::action_msgs::msg::GoalStatus::STATUS_CANCELED as i8 => {
|
||||||
|
GoalStatus::Canceled
|
||||||
|
}
|
||||||
|
s if s == crate::action_msgs::msg::GoalStatus::STATUS_ABORTED as i8 => {
|
||||||
|
GoalStatus::Aborted
|
||||||
|
}
|
||||||
_ => panic!("unknown action status: {}", s),
|
_ => panic!("unknown action status: {}", s),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -294,7 +294,8 @@ where
|
||||||
|
|
||||||
// check if all cancels were rejected.
|
// check if all cancels were rejected.
|
||||||
if requested_cancels >= 1 && response_msg.goals_canceling.is_empty() {
|
if requested_cancels >= 1 && response_msg.goals_canceling.is_empty() {
|
||||||
response_msg.return_code = action_msgs::srv::CancelGoal::Response::ERROR_REJECTED as i8;
|
response_msg.return_code =
|
||||||
|
action_msgs::srv::CancelGoal::Response::ERROR_REJECTED as i8;
|
||||||
}
|
}
|
||||||
|
|
||||||
responses.push((*request_id, response_msg));
|
responses.push((*request_id, response_msg));
|
||||||
|
|
@ -533,7 +534,10 @@ where
|
||||||
|
|
||||||
let response_msg = if !goal_exists {
|
let response_msg = if !goal_exists {
|
||||||
// Goal does not exists
|
// Goal does not exists
|
||||||
let msg = T::make_result_response_msg(action_msgs::msg::GoalStatus::STATUS_UNKNOWN as i8, T::Result::default());
|
let msg = T::make_result_response_msg(
|
||||||
|
action_msgs::msg::GoalStatus::STATUS_UNKNOWN as i8,
|
||||||
|
T::Result::default(),
|
||||||
|
);
|
||||||
let mut response_msg = WrappedNativeMsg::<
|
let mut response_msg = WrappedNativeMsg::<
|
||||||
<<T as WrappedActionTypeSupport>::GetResult as WrappedServiceTypeSupport>::Response,
|
<<T as WrappedActionTypeSupport>::GetResult as WrappedServiceTypeSupport>::Response,
|
||||||
>::from(&msg);
|
>::from(&msg);
|
||||||
|
|
@ -664,7 +668,8 @@ where
|
||||||
action_server.publish_status();
|
action_server.publish_status();
|
||||||
|
|
||||||
// create result message
|
// create result message
|
||||||
let result_msg = T::make_result_response_msg(action_msgs::msg::GoalStatus::STATUS_CANCELED as i8, msg);
|
let result_msg =
|
||||||
|
T::make_result_response_msg(action_msgs::msg::GoalStatus::STATUS_CANCELED as i8, msg);
|
||||||
let native_msg = WrappedNativeMsg::<
|
let native_msg = WrappedNativeMsg::<
|
||||||
<<T as WrappedActionTypeSupport>::GetResult as WrappedServiceTypeSupport>::Response,
|
<<T as WrappedActionTypeSupport>::GetResult as WrappedServiceTypeSupport>::Response,
|
||||||
>::from(&result_msg);
|
>::from(&result_msg);
|
||||||
|
|
@ -684,7 +689,8 @@ where
|
||||||
action_server.set_goal_state(&self.uuid, rcl_action_goal_event_t::GOAL_EVENT_ABORT)?;
|
action_server.set_goal_state(&self.uuid, rcl_action_goal_event_t::GOAL_EVENT_ABORT)?;
|
||||||
|
|
||||||
// create result message
|
// create result message
|
||||||
let result_msg = T::make_result_response_msg(action_msgs::msg::GoalStatus::STATUS_ABORTED as i8, msg);
|
let result_msg =
|
||||||
|
T::make_result_response_msg(action_msgs::msg::GoalStatus::STATUS_ABORTED as i8, msg);
|
||||||
let native_msg = WrappedNativeMsg::<
|
let native_msg = WrappedNativeMsg::<
|
||||||
<<T as WrappedActionTypeSupport>::GetResult as WrappedServiceTypeSupport>::Response,
|
<<T as WrappedActionTypeSupport>::GetResult as WrappedServiceTypeSupport>::Response,
|
||||||
>::from(&result_msg);
|
>::from(&result_msg);
|
||||||
|
|
@ -707,7 +713,8 @@ where
|
||||||
action_server.set_goal_state(&self.uuid, rcl_action_goal_event_t::GOAL_EVENT_SUCCEED)?;
|
action_server.set_goal_state(&self.uuid, rcl_action_goal_event_t::GOAL_EVENT_SUCCEED)?;
|
||||||
|
|
||||||
// create result message
|
// create result message
|
||||||
let result_msg = T::make_result_response_msg(action_msgs::msg::GoalStatus::STATUS_SUCCEEDED as i8, msg);
|
let result_msg =
|
||||||
|
T::make_result_response_msg(action_msgs::msg::GoalStatus::STATUS_SUCCEEDED as i8, msg);
|
||||||
let native_msg = WrappedNativeMsg::<
|
let native_msg = WrappedNativeMsg::<
|
||||||
<<T as WrappedActionTypeSupport>::GetResult as WrappedServiceTypeSupport>::Response,
|
<<T as WrappedActionTypeSupport>::GetResult as WrappedServiceTypeSupport>::Response,
|
||||||
>::from(&result_msg);
|
>::from(&result_msg);
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,10 @@ pub const ROS_DISTRO: &str = "galactic";
|
||||||
pub const ROS_DISTRO: &str = "humble";
|
pub const ROS_DISTRO: &str = "humble";
|
||||||
#[cfg(r2r__ros__distro__rolling)]
|
#[cfg(r2r__ros__distro__rolling)]
|
||||||
pub const ROS_DISTRO: &str = "rolling";
|
pub const ROS_DISTRO: &str = "rolling";
|
||||||
#[cfg(not(any(r2r__ros__distro__foxy, r2r__ros__distro__galactic,
|
#[cfg(not(any(
|
||||||
r2r__ros__distro__humble, r2r__ros__distro__rolling)))]
|
r2r__ros__distro__foxy,
|
||||||
|
r2r__ros__distro__galactic,
|
||||||
|
r2r__ros__distro__humble,
|
||||||
|
r2r__ros__distro__rolling
|
||||||
|
)))]
|
||||||
pub const ROS_DISTRO: &str = "unknown";
|
pub const ROS_DISTRO: &str = "unknown";
|
||||||
|
|
|
||||||
|
|
@ -771,7 +771,6 @@ mod tests {
|
||||||
assert!(!json_request.to_string().is_empty());
|
assert!(!json_request.to_string().is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[cfg(r2r__action_msgs__msg__GoalStatus)]
|
#[cfg(r2r__action_msgs__msg__GoalStatus)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_msg_constants() {
|
fn test_msg_constants() {
|
||||||
|
|
@ -795,6 +794,5 @@ mod tests {
|
||||||
assert_eq!(1, CancelGoal::Response::ERROR_REJECTED as i8);
|
assert_eq!(1, CancelGoal::Response::ERROR_REJECTED as i8);
|
||||||
assert_eq!(2, CancelGoal::Response::ERROR_UNKNOWN_GOAL_ID as i8);
|
assert_eq!(2, CancelGoal::Response::ERROR_UNKNOWN_GOAL_ID as i8);
|
||||||
assert_eq!(3, CancelGoal::Response::ERROR_GOAL_TERMINATED as i8);
|
assert_eq!(3, CancelGoal::Response::ERROR_GOAL_TERMINATED as i8);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ use std::ffi::c_void;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::sync::Weak;
|
|
||||||
use std::sync::Once;
|
use std::sync::Once;
|
||||||
|
use std::sync::Weak;
|
||||||
|
|
||||||
use crate::error::*;
|
use crate::error::*;
|
||||||
use crate::msg_types::*;
|
use crate::msg_types::*;
|
||||||
|
|
@ -181,9 +181,8 @@ where
|
||||||
rcl_borrow_loaned_message(publisher.as_ref(), T::get_ts(), &mut loaned_msg)
|
rcl_borrow_loaned_message(publisher.as_ref(), T::get_ts(), &mut loaned_msg)
|
||||||
};
|
};
|
||||||
if ret != RCL_RET_OK as i32 {
|
if ret != RCL_RET_OK as i32 {
|
||||||
// TODO: Switch to logging library
|
|
||||||
log::error!("Failed getting loaned message");
|
log::error!("Failed getting loaned message");
|
||||||
return Err(Error::from_rcl_error(ret))
|
return Err(Error::from_rcl_error(ret));
|
||||||
}
|
}
|
||||||
|
|
||||||
let handle_box = Box::new(*publisher.as_ref());
|
let handle_box = Box::new(*publisher.as_ref());
|
||||||
|
|
@ -209,7 +208,6 @@ 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(|| {
|
||||||
// TODO: Switch to logging library
|
|
||||||
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.");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue