-
Notifications
You must be signed in to change notification settings - Fork 59
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
Split irobot_create_toolbox
#153
Conversation
Signed-off-by: Alberto Soragna <[email protected]>
Signed-off-by: Alberto Soragna <[email protected]>
Signed-off-by: Alberto Soragna <[email protected]>
Signed-off-by: Alberto Soragna <[email protected]>
Signed-off-by: Alberto Soragna <[email protected]>
Signed-off-by: Alberto Soragna <[email protected]>
${dependencies} | ||
) | ||
|
||
rclcpp_components_register_node(motion_control_lib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This CMake macro register the node as a component.
Essentially it does 2 things:
- automatically generate a main executable with the provided name
- allow to use dynamic composition, i.e. load multiple nodes in the same process through launch files (not using this feature yet)
}; | ||
|
||
// Data structure to hold the definitions related to bumper zones | ||
const std::map<BumperZoneType, BumperZone> BUMPER_ZONES_MAP = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are examples of constants that previously were duplicated between the classic and ignition plugins.
eventually we should move all of them to files like this and also create common, reusable utilities that implement the sensor processing logic.
|
||
/// \brief Wrap angle between (-pi, pi] | ||
template<typename T> | ||
inline T WrapAngle(T angle) {return atan2(sin(angle), cos(angle));} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use angles::normalize_angle for this
template<typename T> | ||
bool IsAngleBetween(T target, T angle1, T angle2) | ||
{ | ||
T t = WrapAngle(target); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could probably use angles::shortest_angular_distance for this method
|
||
/// \brief Convert radians to degrees | ||
template<typename T> | ||
inline int Rad2Deg(T radians) {return radians / M_PI * 180;} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use angles::to_degrees instead (we already have an angles dependency elsewhere in the code). All the angles library suggestions for this file are just suggestions, not sure if this was code added for this review or just moved, in which case, don't worry about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I copied these math operations from the existing code.
I created a ticket to eventually use the angles
library #157
Description
Huge, but relatively simple PR that reworks the
irobot_create_toolbox
package.Relevant changes:
irobot_create_nodes
, with theirobot_create_toolbox
becoming the place where to define utilities and tools.irobot_create_nodes
libraries as rclcpp components. This will allow eventually to dynamically load the nodes into systems and also allows to remove all the boilerplatemain.cpp
files replacing them with automatically generated ones.declare_and_get_parameter
utility and replace it with standarddeclare_parameter
function. Moreover add a default argument to avoid crashes if a parameter is not provided in the yaml files.irobot_create_toolbox
package with stuff that was previously duplicated between ignition and classic code.Type of change
How Has This Been Tested?
Smoke run using Gazebo classic and Gazebo ignition
Checklist