1+ // -- BEGIN LICENSE BLOCK ----------------------------------------------
2+ // Copyright 2025 Universal Robots A/S
3+ //
4+ // Redistribution and use in source and binary forms, with or without
5+ // modification, are permitted provided that the following conditions are met:
6+ //
7+ // * Redistributions of source code must retain the above copyright
8+ // notice, this list of conditions and the following disclaimer.
9+ //
10+ // * Redistributions in binary form must reproduce the above copyright
11+ // notice, this list of conditions and the following disclaimer in the
12+ // documentation and/or other materials provided with the distribution.
13+ //
14+ // * Neither the name of the {copyright_holder} nor the names of its
15+ // contributors may be used to endorse or promote products derived from
16+ // this software without specific prior written permission.
17+ //
18+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+ // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+ // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+ // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22+ // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+ // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+ // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25+ // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26+ // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28+ // POSSIBILITY OF SUCH DAMAGE.
29+ // -- END LICENSE BLOCK ------------------------------------------------
30+
31+ #include < ur_client_library/control/motion_primitives.h>
32+ #include < ur_client_library/log.h>
33+
34+ namespace urcl ::control
35+ {
36+
37+ bool MotionPrimitive::validate () const
38+ {
39+ if (acceleration < 0 )
40+ {
41+ URCL_LOG_ERROR (" Negative acceleration passed to motion primitive. This is not allowed." );
42+ return false ;
43+ }
44+ if (velocity < 0 )
45+ {
46+ URCL_LOG_ERROR (" Negative velocity passed to motion primitive. This is not allowed." );
47+ return false ;
48+ }
49+ if (blend_radius < 0 )
50+ {
51+ URCL_LOG_ERROR (" Negative blend radius passed to motion primitive. This is not allowed." );
52+ return false ;
53+ }
54+ return true ;
55+ }
56+
57+ bool OptimoveJPrimitive::validate () const
58+ {
59+ if (!MotionPrimitive::validate ())
60+ {
61+ return false ;
62+ }
63+ if (acceleration <= 0 || acceleration > 1.0 )
64+ {
65+ URCL_LOG_ERROR (" Acceleration fraction must be in range (0, 1]." );
66+ return false ;
67+ }
68+ if (velocity <= 0 || velocity > 1.0 )
69+ {
70+ URCL_LOG_ERROR (" Velocity fraction must be in range (0, 1]." );
71+ return false ;
72+ }
73+ return true ;
74+ }
75+
76+ bool OptimoveLPrimitive::validate () const
77+ {
78+ if (!MotionPrimitive::validate ())
79+ {
80+ return false ;
81+ }
82+ if (acceleration <= 0 || acceleration > 1.0 )
83+ {
84+ URCL_LOG_ERROR (" Acceleration fraction must be in range (0, 1]." );
85+ return false ;
86+ }
87+ if (velocity <= 0 || velocity > 1.0 )
88+ {
89+ URCL_LOG_ERROR (" Velocity fraction must be in range (0, 1]." );
90+ return false ;
91+ }
92+ return true ;
93+ }
94+ } // namespace urcl::control
0 commit comments