-
Notifications
You must be signed in to change notification settings - Fork 31
/
robot_command_helpers.h
161 lines (145 loc) · 7.79 KB
/
robot_command_helpers.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/**
* Copyright (c) 2023 Boston Dynamics, Inc. All rights reserved.
*
* Downloading, reproducing, distributing or otherwise using the SDK Software
* is subject to the terms and conditions of the Boston Dynamics Software
* Development Kit License (20191101-BDSDK-SL).
*/
#pragma once
// A set of free helper functions to be used with a robot command client.
#include "robot_command_client.h"
namespace bosdyn {
namespace client {
// Possible error codes related to issuing a RobotCommand and waiting until the command completes
// before doing anything else.
enum class BlockingRobotCommandErrorCode {
Success = 0, // The issued RobotCommand finished successfully.
CommandFeedbackError = 1, // The issued RobotCommand finished with an error.
CommandTimeoutError = 2, // The issued RobotCommand didn't complete.
};
std::error_code make_error_code(BlockingRobotCommandErrorCode);
/**
* Blocks until the arm achieves a finishing state for the specific arm command. This helper will
* block and check the feedback for ArmCartesianCommand, GazeCommand, ArmJointMoveCommand,
* NamedArmPositionsCommand, and ArmImpedanceCommand.
*
* @param robot_command_client (bosdyn.client.RobotCommandClient): The robot command client, used to
* request command feedback.
* @param cmd_id (int): The command ID returned by the robot when the arm movement command was sent.
* @param timeout_sec (int): The number of seconds after which we'll return no matter what the
* robot's state is. If unset, 0, or negative, this function will never time out and only return
* when there is finished command feedback.
* @param poll_period_msec (int): The number of milliseconds to wait between requesting feedback
* updates. Default is 100 ms.
*
* @return True if successfully got to the end of the trajectory, False if the arm stalled or the
* move was canceled (the arm failed to reach the goal). See the proto definitions in
* arm_command.proto for more information about why a trajectory would succeed or fail.
*/
[[deprecated]] RobotCommandFeedbackResultType BlockUntilArmArrives(
::bosdyn::client::RobotCommandClient& robot_command_client, int cmd_id, int timeout_sec = 0,
int poll_period_msec = 100);
/**
* Blocks until the arm achieves a finishing state for the specific arm command. This helper will
* block and check the feedback for ArmCartesianCommand, GazeCommand, ArmJointMoveCommand,
* NamedArmPositionsCommand, and ArmImpedanceCommand.
*
* @param robot_command_client (bosdyn.client.RobotCommandClient): The robot command client, used to
* request command feedback.
* @param cmd_id (int): The command ID returned by the robot when the arm movement command was sent.
* @param timeout (Duration): Duration after which we'll return no matter what the
* robot's state is. If unset, 0, or negative, this function will never time out and only return
* when there is finished command feedback.
* @param poll_period (Duration): Duration to wait between requesting feedback updates. Default is
* 100 ms.
*
* @return True if successfully got to the end of the trajectory, False if the arm stalled or the
* move was canceled (the arm failed to reach the goal). See the proto definitions in
* arm_command.proto for more information about why a trajectory would succeed or fail.
*/
RobotCommandFeedbackResultType BlockUntilArmArrives(
::bosdyn::client::RobotCommandClient& robot_command_client, int cmd_id,
::bosdyn::common::Duration timeout = std::chrono::seconds(0),
::bosdyn::common::Duration poll_period = std::chrono::milliseconds(100));
/**
* Blocks until the gripper achieves a finishing state for a ClawGripperCommand.
*
* @param robot_command_client (bosdyn.client.RobotCommandClient): The robot command client, used to
* request command feedback.
* @param cmd_id (int): The command ID returned by the robot when the gripper movement command was
* sent.
* @param timeout_sec (int): The number of seconds after which we'll return no matter what the
* robot's state is. If unset, 0, or negative, this function will never time out and only return
* when there is finished command feedback.
* @param poll_period_msec (int): The number of milliseconds to wait between requesting feedback
* updates. Default is 100 ms.
*
* @return True if the gripper successfully reached the goal or is applying force on something,
* False if the gripper failed to reach the goal.
*/
[[deprecated]] RobotCommandFeedbackResultType BlockUntilGripperArrives(
::bosdyn::client::RobotCommandClient& robot_command_client, int cmd_id, int timeout_sec = 0,
int poll_period_msec = 100);
/**
* Blocks until the gripper achieves a finishing state for a ClawGripperCommand.
*
* @param robot_command_client (bosdyn.client.RobotCommandClient): The robot command client, used to
* request command feedback.
* @param cmd_id (int): The command ID returned by the robot when the arm movement command was sent.
* @param timeout (Duration): Duration after which we'll return no matter what the
* robot's state is. If unset, 0, or negative, this function will never time out and only return
* when there is finished command feedback.
* @param poll_period (Duration): Duration to wait between requesting feedback updates. Default is
* 100 ms.
*
* @return True if the gripper successfully reached the goal or is applying force on something,
* False if the gripper failed to reach the goal.
*/
RobotCommandFeedbackResultType BlockUntilGripperArrives(
::bosdyn::client::RobotCommandClient& robot_command_client, int cmd_id,
::bosdyn::common::Duration timeout = std::chrono::seconds(0),
::bosdyn::common::Duration poll_period = std::chrono::milliseconds(100));
/**
* Blocks until the Robot complete StandCommand
*
* @param robot_command_client (bosdyn.client.RobotCommandClient): The robot command client, used to
* request command feedback.
* @param cmd_id (int): The command ID returned by the robot when the arm movement command was sent.
* @param timeout (Duration): Duration after which we'll return no matter what the
* robot's state is. If unset, 0, or negative, this function will never time out and only return
* when there is finished command feedback.
* @param poll_period (Duration): Duration to wait between requesting feedback updates. Default is
* 100 ms.
*
* @return True if the robot successfully completed stand.
* False if the robot failed to reach the stand pose.
*/
RobotCommandFeedbackResultType BlockUntilStandComplete(
::bosdyn::client::RobotCommandClient& robot_command_client, int cmd_id,
::bosdyn::common::Duration timeout = std::chrono::seconds(10),
::bosdyn::common::Duration poll_period = std::chrono::milliseconds(100));
/**
* Blocks until the Robot completes TrajectoryCommand
*
* @param robot_command_client (bosdyn.client.RobotCommandClient): The robot command client, used to
* request command feedback.
* @param cmd_id (int): The command ID returned by the robot when the Trajectory command was sent.
* @param timeout (Duration): Duration after which we'll return no matter what the
* robot's state is. If unset, 0, or negative, this function will never time out and only return
* when there is finished command feedback.
* @param poll_period (Duration): Duration to wait between requesting feedback updates. Default is
* 100 ms.
*
* @return True if the robot successfully completed trajectory.
* False if the robot failed to complete trajectory.
*/
RobotCommandFeedbackResultType BlockUntilSE2TrajectoryComplete(
::bosdyn::client::RobotCommandClient& robot_command_client, int cmd_id,
::bosdyn::common::Duration timeout = std::chrono::seconds(10),
::bosdyn::common::Duration poll_period = std::chrono::milliseconds(100));
} // namespace client
} // namespace bosdyn
namespace std {
template <>
struct is_error_code_enum<::bosdyn::client::BlockingRobotCommandErrorCode> : true_type {};
} // namespace std