ros2_client/action_msgs.rs
1use serde::{Deserialize, Serialize};
2use serde_repr::{Deserialize_repr, Serialize_repr};
3
4use crate::message::Message;
5
6/// A handle used to identify action goals.
7pub type GoalId = crate::unique_identifier_msgs::UUID;
8
9/// From [GoalInfo](https://docs.ros2.org/foxy/api/action_msgs/msg/GoalInfo.html)
10#[derive(Clone, Serialize, Deserialize, Debug)]
11pub struct GoalInfo {
12 pub goal_id: GoalId,
13 pub stamp: crate::builtin_interfaces::Time, // Time when the goal was accepted
14}
15impl Message for GoalInfo {}
16
17/// Named goal statuses from [GoalStatus](https://docs.ros2.org/foxy/api/action_msgs/msg/GoalStatus.html)
18#[derive(Clone, Copy, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
19#[repr(i8)]
20pub enum GoalStatusEnum {
21 /// Let's use "Unknown" also for "New"
22 Unknown = 0,
23 Accepted = 1,
24 Executing = 2,
25 Canceling = 3,
26 Succeeded = 4,
27 Canceled = 5,
28 Aborted = 6,
29}
30
31/// From [GoalStatus](https://docs.ros2.org/foxy/api/action_msgs/msg/GoalStatus.html)
32#[derive(Clone, Serialize, Deserialize, Debug)]
33pub struct GoalStatus {
34 pub goal_info: GoalInfo,
35 pub status: GoalStatusEnum,
36}
37impl Message for GoalStatus {}
38
39/// From [GoalStatusArray](https://docs.ros2.org/foxy/api/action_msgs/msg/GoalStatusArray.html)
40#[derive(Clone, Serialize, Deserialize, Debug)]
41pub struct GoalStatusArray {
42 pub status_list: Vec<GoalStatus>,
43}
44impl Message for GoalStatusArray {}
45
46/// From [CancelGoal](https://docs.ros2.org/foxy/api/action_msgs/srv/CancelGoal.html)
47// Cancel one or more goals with the following policy:
48//
49// - If the goal ID is zero and timestamp is zero, cancel all goals.
50// - If the goal ID is zero and timestamp is not zero, cancel all goals accepted at or before the
51// timestamp.
52// - If the goal ID is not zero and timestamp is zero, cancel the goal with the given ID regardless
53// of the time it was accepted.
54// - If the goal ID is not zero and timestamp is not zero, cancel the goal with the given ID and all
55// goals accepted at or before the timestamp.
56#[derive(Clone, Serialize, Deserialize, Debug)]
57pub struct CancelGoalRequest {
58 pub(crate) goal_info: GoalInfo,
59}
60impl Message for CancelGoalRequest {}
61
62/// From [CancelGoal](https://docs.ros2.org/foxy/api/action_msgs/srv/CancelGoal.html)
63#[derive(Clone, Copy, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
64#[repr(i8)]
65pub enum CancelGoalResponseEnum {
66 // Doc comments here copied from ROS2 message definition.
67 /// Indicates the request was accepted without any errors.
68 /// One or more goals have transitioned to the CANCELING state.
69 /// The goals_canceling list is not empty.
70 None = 0,
71
72 /// Indicates the request was rejected.
73 /// No goals have transitioned to the CANCELING state. The goals_canceling
74 /// list is empty.
75 Rejected = 1,
76
77 /// Indicates the requested goal ID does not exist.
78 /// No goals have transitioned to the CANCELING state. The goals_canceling
79 /// list is empty.
80 UnknownGoal = 2,
81
82 /// Indicates the goal is not cancelable because it is already in a terminal
83 /// state. No goals have transitioned to the CANCELING state. The
84 /// goals_canceling list is empty.
85 GoalTerminated = 3,
86}
87
88/// From [CancelGoal](https://docs.ros2.org/foxy/api/action_msgs/srv/CancelGoal.html)
89#[derive(Clone, Serialize, Deserialize, Debug)]
90pub struct CancelGoalResponse {
91 pub return_code: CancelGoalResponseEnum,
92 pub goals_canceling: Vec<GoalInfo>,
93}
94impl Message for CancelGoalResponse {}