lucasw / screen_grab

Capture the screen and publish it on a ROS sensor_msgs/Image topic
18 stars 12 forks source link

ros2 version #10

Open lucasw opened 6 years ago

lucasw commented 6 years ago

Make two directories side by side, CATKIN_IGNORE in the ros2 one and AMENT_IGNORE in the ros1 one, and perhaps a middle directory with common code?

lucasw commented 6 years ago

But there is no ros2 dynamic reconfigure yet, so will need to use topics instead.

lucasw commented 6 years ago

Show image

https://github.com/ros2/demos.git has image_tools showimage

But to use with older repo versions in tutorials it needs the clock.hpp disabled (is it safe to use latest git versions of everything or do random packages fall behind and it would be a huge pain?)

Or just use 75c150b5faad48701d58dd4feeb0a00fad3df670

+++ b/dummy_robot/dummy_sensors/src/dummy_joint_states.cpp
@@ -17,9 +17,9 @@
 #include <iostream>
 #include <memory>

-#include "rclcpp/clock.hpp"
+// #include "rclcpp/clock.hpp"
 #include "rclcpp/rclcpp.hpp"
-#include "rclcpp/time_source.hpp"
+// #include "rclcpp/time_source.hpp"

 #include "sensor_msgs/msg/joint_state.hpp"

@@ -50,10 +50,14 @@ int main(int argc, char * argv[])
       msg->position[i] = joint_value;
     }

+#if 0
     rclcpp::TimeSource ts(node);
     rclcpp::Clock::SharedPtr clock = std::make_shared<rclcpp::Clock>(RCL_ROS_TIME);
     ts.attachClock(clock);
     msg->header.stamp = clock->now();
+#endif
+    msg->header.stamp = rclcpp::Time::now();  // clock->now();
+

The image from screen_grab is a bgra8, which showimage doesn't support - need to update it.

lucasw commented 6 years ago

Use latest ros2

Try latest instead of last release.

mkdir -p ~/ros2_latest_ws/src
cd ~/ros2_latest_ws
wget https://raw.githubusercontent.com/ros2/ros2/master/ros2.repos
vcs-import src < ros2.repos
sudo apt-get install python3-pytest
lucasw commented 6 years ago

ros2 demos showimage shows the frame grab is working, frame rate isn't that great.