Bioscara
DALSA's DIY SCARA Robot Arm.
Loading...
Searching...
No Matches
uErr.h
Go to the documentation of this file.
1
11#ifndef UERR_H
12#define UERR_H
13
14#include <string>
15
17{
22 enum class err_type_t
23 {
24 OK = 0,
25 ERROR = -1,
26 NOT_HOMED = -2,
27 NOT_ENABLED = -3,
28 STALLED = -4,
29 NOT_INIT = -5,
30 COMM_ERROR = -6,
31 INVALID_ARGUMENT = -101,
32 INCORRECT_STATE = -109,
33
34 };
35
42 std::string error_to_string(err_type_t err);
43}
44
52#define RETURN_ON_ERROR(x) \
53 do \
54 { \
55 bioscara_hardware_drivers::err_type_t err_rc_ = (x); \
56 if (err_rc_ != bioscara_hardware_drivers::err_type_t::OK) \
57 { \
58 return err_rc_; \
59 } \
60 } while (0);
61
69#define RETURN_ON_FALSE(a, err_code) \
70 do \
71 { \
72 if (!(a)) \
73 { \
74 return err_code; \
75 } \
76 } while (0);
77
85#define RETURN_ON_NEGATIVE(a, err_code) \
86 do \
87 { \
88 if ((a) < 0) \
89 { \
90 return err_code; \
91 } \
92 } while (0);
93
94#endif // UERR_H
Definition mBaseJoint.h:19
err_type_t
Enum defining common error types.
Definition uErr.h:23
@ INCORRECT_STATE
Joint is busy executing another blocking command.
@ NOT_HOMED
Joint not homed or failed to home.
@ NOT_ENABLED
Joint not enabled or failed to enable.
@ NOT_INIT
Joint not initialized.
@ INVALID_ARGUMENT
Argument violates conditions.
std::string error_to_string(err_type_t err)
Converts an error code to a string and returns it.
Definition uErr.cpp:5