Skip to content

Commit

Permalink
migrate to image_rotate, make lazy
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeferguson committed Dec 6, 2024
1 parent bca58a4 commit c5787d9
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 342 deletions.
32 changes: 0 additions & 32 deletions image_flip/CMakeLists.txt

This file was deleted.

83 changes: 0 additions & 83 deletions image_flip/include/image_flip/visibility.h

This file was deleted.

30 changes: 0 additions & 30 deletions image_flip/mainpage.dox

This file was deleted.

54 changes: 0 additions & 54 deletions image_flip/package.xml

This file was deleted.

7 changes: 7 additions & 0 deletions image_rotate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ ament_auto_add_executable(image_rotate_bin src/image_rotate.cpp)
set_target_properties(image_rotate_bin PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
target_link_libraries(image_rotate_bin ${OpenCV_LIBRARIES} ${PROJECT_NAME})

ament_auto_add_library(image_flip SHARED src/image_flip.cpp)
target_link_libraries(image_flip ${OpenCV_LIBRARIES})
rclcpp_components_register_node(image_flip
PLUGIN "${PROJECT_NAME}::ImageFlipNode"
EXECUTABLE image_flip_node
)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#ifndef IMAGE_FLIP__IMAGE_FLIP_NODE_HPP_
#define IMAGE_FLIP__IMAGE_FLIP_NODE_HPP_

#ifndef IMAGE_ROTATE__IMAGE_FLIP_HPP_
#define IMAGE_ROTATE__IMAGE_FLIP_HPP_

#include <math.h>

Expand All @@ -47,24 +48,22 @@
#include <rclcpp/rclcpp.hpp>
#include <tf2_geometry_msgs/tf2_geometry_msgs.hpp>

#include "image_flip/visibility.h"
#include "image_rotate/visibility.h"

namespace image_flip
namespace image_rotate
{

struct ImageFlipConfig
{
std::string output_frame_id;
int rotation_steps;
bool use_camera_info;
rmw_qos_profile_t input_qos; // "default", "sensor_data", etc ..
rmw_qos_profile_t output_qos;
};

class ImageFlipNode : public rclcpp::Node
{
public:
IMAGE_FLIP_PUBLIC ImageFlipNode(rclcpp::NodeOptions options);
IMAGE_ROTATE_PUBLIC ImageFlipNode(rclcpp::NodeOptions options);

private:
const std::string frameWithDefault(const std::string & frame, const std::string & image_frame);
Expand All @@ -76,10 +75,6 @@ class ImageFlipNode : public rclcpp::Node
const sensor_msgs::msg::Image::ConstSharedPtr & msg,
const sensor_msgs::msg::CameraInfo::ConstSharedPtr & cam_info,
const std::string input_frame_from_msg);
void subscribe();
void unsubscribe();
void connectCb();
void disconnectCb();
void onInit();

rclcpp::Node::OnSetParametersCallbackHandle::SharedPtr on_set_parameters_callback_handle_;
Expand All @@ -89,18 +84,20 @@ class ImageFlipNode : public rclcpp::Node
std::shared_ptr<tf2_ros::StaticTransformBroadcaster> tf_pub_;
bool tf_unpublished_;

image_flip::ImageFlipConfig config_;
ImageFlipConfig config_;

image_transport::Publisher img_pub_;
// Subscriber - only one is used at a time - depends on use_camera_info
image_transport::Subscriber img_sub_;
image_transport::CameraSubscriber cam_sub_;

// Publisher - only one is used at a time - depends on use_camera_info
image_transport::Publisher img_pub_;
image_transport::CameraPublisher cam_pub_;

int subscriber_count_;
double angle_;
tf2::TimePoint prev_stamp_;
geometry_msgs::msg::TransformStamped transform_;
};
} // namespace image_flip
} // namespace image_rotate

#endif // IMAGE_FLIP__IMAGE_FLIP_NODE_HPP_
#endif // IMAGE_ROTATE__IMAGE_FLIP_HPP_
3 changes: 2 additions & 1 deletion image_rotate/include/image_rotate/image_rotate_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,14 @@ class ImageRotateNode : public rclcpp::Node
image_rotate::ImageRotateConfig config_;

image_transport::Publisher img_pub_;

// Subscriber - only one is used at a time - depends on use_camera_info
image_transport::Subscriber img_sub_;
image_transport::CameraSubscriber cam_sub_;

geometry_msgs::msg::Vector3Stamped target_vector_;
geometry_msgs::msg::Vector3Stamped source_vector_;

int subscriber_count_;
double angle_;
tf2::TimePoint prev_stamp_;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,19 @@

"""Demonstration of basic launch of the image_flip_node with remappings."""

import launch_ros.actions
from launch import LaunchDescription
import launch_ros.actions


def generate_launch_description():
"""
Launch description for basic launch of the image_flip_node.
Launch description for basic launch of the image_flip_node,
which includes parameters and topic remappings.
"""
"""Launch description for basic launch of the image_flip."""
return LaunchDescription([
launch_ros.actions.Node(
package='image_flip', executable='image_flip_node',
package='image_rotate', executable='image_flip',
output='screen', name='camera_flip',
remappings=[("image", 'camera/rgb/image_raw'),
('camera_info', 'camera/rgb/camera_info'),
('rotated/image', 'camera_rotated/image_rotated'),
('rotated/camera_info', 'camera_rotated/camera_info'),
('rotated/image/compressed',
'camera_rotated/image_rotated/compressed'),
('rotated/image/compressedDepth',
'camera_rotated/image_rotated/compressedDepth'),
('rotated/image/theora',
'camera_rotated/image_rotated/theora')],
parameters=[{'output_frame_id': "camera_rotated",
remappings=[('image', 'camera/rgb/image_raw'),
('rotated/image', 'camera_rotated/image_rotated')],
parameters=[{'output_frame_id': 'camera_rotated',
'rotation_steps': 2,
'use_camera_info': True,
'input_qos': 'best_effort',
Expand Down
1 change: 1 addition & 0 deletions image_rotate/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<url type="bugtracker">https://github.com/ros-perception/image_pipeline/issues</url>
<url type="repository">https://github.com/ros-perception/image_pipeline</url>
<author>Blaise Gassend</author>
<author email="[email protected]">David Conner</author>

<buildtool_depend>ament_cmake_auto</buildtool_depend>

Expand Down
Loading

0 comments on commit c5787d9

Please sign in to comment.