Explore chapters and articles related to this topic
Messages, Classes and Servers
Published in Wyatt S. Newman, A Systematic Approach to Learning Robot Programming with ROS, 2017
In practice, when using variable-length messages, one must be careful of two issues:Make sure your variable-length vectors do not get overly large. It is all too easy to forget that the vector continues to grow, and thus you could consume all of your memory and all of your communications bandwidth as the message grows too large.As with conventional arrays, if you try to access memory that has not been allocated, you will get errors (typically a segmentation fault). For example, if your received message copied to vecofdoubles is three elements long, trying to access vecofdoubles[3] (the fourth element) will result in run-time errors (but no compiler warnings).This concludes the introduction to defining message types. As will be shown, the same process is used for defining additional message types used for ROS services and ROS action servers.
Mathematically rigorous global optimization in floating-point arithmetic
Published in Optimization Methods and Software, 2018
Montanher's and Csendes' program fail to compute an inclusion for an unbounded search box even for the univariate Griewank function; C-XSC produces a segmentation fault for the search box , but also for the finite search box .
Algorithmic differentiation of the Open CASCADE Technology CAD kernel and its coupling with an adjoint CFD solver
Published in Optimization Methods and Software, 2018
Mladen Banović, Orest Mykhaskiv, Salvatore Auriemma, Andrea Walther, Herve Legrand, Jens-Dominik Müller
Furthermore, some of the run-time issues were related to: The left and right shift operators (<< and >>) are overloaded in the adouble class. Since they are also used in the OCCT output system, the files were corrupted by adoubles, because the derivative information is also printed to the output. There is no need that files like STEP contain such an additional information. Hence, the solution was just to extract the primal values of adoubles using the getValue method wherever necessary.C dynamic memory allocation is used in the OCCT kernel. This causes errors once the adoubles are present. An adouble object has to be initialized using its constructor, such that the correct memory amount is allocated. The C-function malloc does not achieve that, triggering ‘segmentation fault’ errors upon program execution. For this reason, we replaced the functions malloc/free with the C++ operators new/delete. Moreover, the C-functions memset and memcpy were replaced by for loops in order to manually assign or copy the values from one pointer to another. Otherwise, the memory exceptions would occur. Even more complex low-level memory management is used in one specific package of OCCT that we could not differentiate, as described in Section 4.In many places of the OCCT code, we had to use explicit conversion from real numbers to adoubles, if these numbers are passed as arguments to the specific overloaded methods. For example, consider the SetCoord method which is overloaded in OCCT in two different ways: SetCoord(Standard_Integer, Standard_Real), which sets a coordinates value by its index, and SetCoord(Standard_Real, Standard_Real), which specifies each coordinate value independently. A case in the code where developer uses the second method with real numbers, e.g. SetCoord(6., 8.), is not correctly identified in the differentiated sources because the compiler calls the method with primitive types as arguments, which is the first method. Without any interaction this may not produce a run-time error, but certainly the values are wrong. The correct way in such cases is to add an explicit conversion, i.e. SetCoord((Standard_Real) 6., (Standard_Real) 8.).