Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/ros queues #5

Merged
merged 24 commits into from
Nov 16, 2023
Merged

Feat/ros queues #5

merged 24 commits into from
Nov 16, 2023

Conversation

etienn8
Copy link
Owner

@etienn8 etienn8 commented Nov 16, 2023

Creation of ros_queue which is a wrapper of the lib_queue with ROS interfaces.

Other modifications:

  • Added move semantics in the liq_queue
  • Added an input argument to the predictions

Etienne added 24 commits October 25, 2023 10:59
- Added an extra template parameter to the the IDynamicQueue and its children classes (except the virtual queues, which will be done in a future commit). That parameter is the input type of the evaluation function and which is passed to the arrival and transmission prediction methods. This will allow the application program and the user to give an extra input on which they can give data to their predictions.
- Added a template specialization to the IDynamicQueue and its derived class for the case of a void type for TStates. It's also the default template for IDynamicQueue with only the type parameter.
- Moved the definition of DynamicConvertedQueue to its own header file because of its size.
- Change from a copy to a reference to have list copy and made it constant since the input data should not be affected in the process.
- Added an extra template parameter to the the InConVirtualQueue and the EqConvVirtualQueue. That parameter is the input type of the evaluation function and which is passed to the arrival and transmission prediction methods. This will allow the application program and the user to give an extra input on which they can give data to their predictions.
- Added a template specialization to the InConVirtualQueue and EqConVirtualQueue  for the case of a void type for TStates. It's also the default template for IDynamicQueue with only the type parameter.
- Corrected a bad code copy where EqConVirtualQueue::update() had the same core as its evaluate(). So its core code has been reverted.
- It was moved in order to contain the test files inside the package thus preventing catkin from sharing those header files.
- Added the ROS Queue class to overload the predictions functions so it can be computed from a service or a custom function. The argument type chosen for the prediction functions and evaluate() is a Ros service struct.
- Added some services to test the ROS Queue prediction calls.
- Added dependencies in package.xml and CMakeLists.txt to generate the services and rostests.
- Added some tests for the ROS Queues to test different combination of constructors
- Added ROS Queue Info to add meta information about the queue later.
- Added Doxygen documentation to ROSQueue except for its constructors since they are still in progress.
- Changed the name of the template parameter name to follow a more standard naming.
- Added a ROS_ERROR log if a prediction service is unavailable since all prediction would be bad and, if used for decision making, it could lead to bad decisions.
…d of pointer

- The generateConvertedQueue function pointer of the class DynamicConvertedQueue has been replaced with a method to be overiden. There is tow main reasons: 1) To be more consistent with how the predictions functions are methods that need to be overriden for the custom behavior and 2) to prevent the ROSQueue class to have a specialization of its template since the function pointer needed an extra argument in the constructor compare to all other derived classes of IDynamicQueue.
Since a template specialization for each Dynamic Queue except the virtual queues, a template for them is created and classes will be created for others. This commit is for the ROSVirtualQueue class.
- Added the ROSVirtualQueue class.
- Added Doxygen documentation to the constructors of the class.
- Added bad initialization test (null function pointers).
- Refactored the tests so it matches the new ROSVirtualQueue class.
- Added transmission pointer function to ROSQueue so a user can specified a transmission behavior
- Added initialization tests in ros_queue_test to see if it throws an exception when the pointer is null
- Moved the delay to wait for a service to be available inside the classes to remove name colisions.
- Added a function pointer or a ROS topic name to the constructor of ROS Queue.
- Overrode the transmit() method to call the user-defined transmit function if defined or to publish the transmitting queue from the update().
- Changed the template parameters of the ROSQueue class to know the message definition for the ROS publisher. Since there is a relation between what is sent and what is stored in the queue, the type of the queue is defined from a type of a vector in the transmitting message. So, the ROSQueue internal deque, is based on the type of an array name "queue_elements" in the transmitting msg. Getting the type from a .msg will also help to provide system wide message definition.
- Added two test ROS msg to serve as an example and for tests.
- Refactored the ROS queue tests to support the new template definitions
- Added tests to verify if the user defined functions can transmit. However, the transmitting topic was not implemented and was test separately since it added more significant work to test it with rostest.
…le and fixed a namespace resolution.

- Created a service that could be used for the ROSConvertedQueue class (future commit). It serves as a template since the name of the arguments and return are the ones expected by ROSConvertedQueue. Only the type of the queue_to_convert should be change in a different implementation.
- Moved the type trait used for the type resolution of the queue elements in a more general header file since ROSConvertedQueue will also use it.
-  Specified the usage of the namespace std in dynamic_converted_queue since it caused some compilation errors.
Warning: This commit doesn't compile, its just to save an idea of a simplified constructor that could be used for ROSQueueConverted and also ROSQueue.

- Added ROSConvertedQueue which is a ROS wrapper of the DynamicConvertedQueue. Compared to ROSQueue, an additionnal service ou function pointer for the conversion needs is added. Also another template parameter was added to specify the service type used.

- Its not compiling because I thought that named parameter existed in C++. I saw that it could be implemented but I assumed it with a native feature of C++.
- Missing feature: Overiding the conversion function. Right now, only the initialization is done in the constructor.
…tion.

- Changed the constructor of ROSConvertedQueue to remove the combination of 16 overloaded constructors in one constructor that takes its user-defined function arguments from another object (ROSConvertedQueue::InterfacesArgs). This structure enables the use of a name-argument-like initialization.
- Overrode the behavior of generateConvertedQueue so it calls either the conversion pointer if its defined or the conversion service.
- Added exception to indicate if the service did a bad conversion.
- Added some move semantics when moving data from a data from queue or vector to another.
- Added the conversion test from the user-defined function and the service.
- Replace all overloaded constructors of ROSVirtualQueue with one constructor that takes a structure as an argument to  represent all the constructor combinations.
- Changed the name of a template parameter to be more specific and consistent.
- Changed the test file accordingly.
- Replace all overloaded constructors of ROSQueue with one constructor that takes a structure as an argument to  represent all the constructor combinations.
- Changed the name of a template parameter to be more specific and consistent.
- Changed the test file accordingly.
Since ros_queue mainly takes input data and move it around in other queues, there is no need for copying the data wich could be expansive depending on the queue element.

- Changed the argument type of the update() method of IDynamicQueue and all its children class to use an rvalue of an arriving queue. This is used whenever the use doesn't need to keep the arriving queue intact.
- Adpated all transfer of data from one method to another and for each push in a deque or vector so they are cast as rvalue with std::move. Only the getInternalQueue() method that requires a deep copy, doesn't use std::move().
- Added an overloaded update() method in IDynamicQueue to support the use of copying the arriving queue. The method takes an const lvalue(reference) of the arriving data, then copies it, casts it as an rvalue and calls the overriden update() method that takes an rvalue. It that way, we don't need to duplicate the code of the update for lvalue and rvalue.
- Decalared the overloaded updated() that takes an lvalue from the IDynamicQueue in all its children class, so its not hidden by the name resolution of children classes.
- Changed the constructor of the ElementWithConvertedSize so its initialized with rvalue instead of of a copy.
- Changed the concatenate_queue() method to also move data from one queue to another.
- Added some missing override tags in the dynamic_queue tests.
- Added a new move_optimization_tests file that verify that non copy constructor is called whenever we move in a DynamicQueue or a DynamicConvertedQueue. It has not been tested with the ROSQueues since it's more complicated with the msg definition it expects.

- Refactored the TState parameter name of dynamic_virtual_queue to make it consistent with all other templates.
@etienn8 etienn8 merged commit 64fa85c into main Nov 16, 2023
@etienn8 etienn8 deleted the feat/ros_queues branch November 16, 2023 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant