Changes have been pushed for the repository "fawkesrobotics/fawkes".

Clone:  https://github.com/fawkesrobotics/fawkes.git
Gitweb: https://github.com/fawkesrobotics/fawkes

The branch, neltester/realsense2_save_image has been updated
        to  d4d6ae6ea0f0bb6d53b42e58b7581bcb7e3477c5 (commit)
       via  5fb3519ff88210e6a5f5accd0213cfbe37fbbbcf (commit)
      from  06acc5b95bc9d6b3161ce5145da706e14e3396ed (commit)

https://github.com/fawkesrobotics/fawkes/tree/neltester/realsense2_save_image

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- *Log* ---------------------------------------------------------------
commit 5fb3519ff88210e6a5f5accd0213cfbe37fbbbcf
Author:     Niklas Sebastian Eltester <[email protected]>
AuthorDate: Thu Jun 3 13:23:11 2021 +0200
Commit:     Niklas Sebastian Eltester <[email protected]>
CommitDate: Thu Jun 3 13:23:11 2021 +0200

    interfaces: add msgid to CameraControlInterface

https://github.com/fawkesrobotics/fawkes/commit/5fb3519ff

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
commit d4d6ae6ea0f0bb6d53b42e58b7581bcb7e3477c5
Author:     Niklas Sebastian Eltester <[email protected]>
AuthorDate: Thu Jun 3 13:24:52 2021 +0200
Commit:     Niklas Sebastian Eltester <[email protected]>
CommitDate: Thu Jun 3 13:24:52 2021 +0200

    realsense2: Improve If comms, bug fixes
    
    This improves the communication via the interfaces by including the last
    processed msgid whenever a job is finished
    Fixes potential division by 0
    Fixes bug where reading the image name from the message deletes the
    image name

https://github.com/fawkesrobotics/fawkes/commit/d4d6ae6ea

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


- *Summary* -----------------------------------------------------------
 src/libs/interfaces/CameraControlInterface.xml |  1 +
 src/plugins/realsense2/realsense2_thread.cpp   | 28 +++++++++++++++-----------
 src/plugins/realsense2/realsense2_thread.h     |  8 +++++---
 3 files changed, 22 insertions(+), 15 deletions(-)


- *Diffs* -------------------------------------------------------------

- *commit* 5fb3519ff88210e6a5f5accd0213cfbe37fbbbcf - - - - - - - - - -
Author:  Niklas Sebastian Eltester <[email protected]>
Date:    Thu Jun 3 13:23:11 2021 +0200
Subject: interfaces: add msgid to CameraControlInterface

 src/libs/interfaces/CameraControlInterface.xml | 1 +
 1 file changed, 1 insertion(+)

_Diff for modified files_:
diff --git a/src/libs/interfaces/CameraControlInterface.xml 
b/src/libs/interfaces/CameraControlInterface.xml
index 9149fe102..fe9d77957 100644
--- a/src/libs/interfaces/CameraControlInterface.xml
+++ b/src/libs/interfaces/CameraControlInterface.xml
@@ -18,6 +18,7 @@
   <data>
     <comment>
     </comment>
+    <field type="uint32" name="msgid">Last processed message.</field>
     <field type="Effect" name="effect">Currently active effect.</field>
     <field type="bool"   name="effect_supported">Are effects supported?</field>
     <field type="uint32" name="zoom">Current zoom setting.</field>

- *commit* d4d6ae6ea0f0bb6d53b42e58b7581bcb7e3477c5 - - - - - - - - - -
Author:  Niklas Sebastian Eltester <[email protected]>
Date:    Thu Jun 3 13:24:52 2021 +0200
Subject: realsense2: Improve If comms, bug fixes

 src/plugins/realsense2/realsense2_thread.cpp | 28 ++++++++++++++++------------
 src/plugins/realsense2/realsense2_thread.h   |  8 +++++---
 2 files changed, 21 insertions(+), 15 deletions(-)

_Diff for modified files_:
diff --git a/src/plugins/realsense2/realsense2_thread.cpp 
b/src/plugins/realsense2/realsense2_thread.cpp
index 399d52990..bfaadf5d7 100644
--- a/src/plugins/realsense2/realsense2_thread.cpp
+++ b/src/plugins/realsense2/realsense2_thread.cpp
@@ -110,17 +110,17 @@ Realsense2Thread::loop()
        }
 
        // take picture
-       if (enable_camera_ && read_camera_control() != "") {
+       if (enable_camera_ && read_camera_control()) {
                if (rs_rgb_pipe_->poll_for_frames(&rs_rgb_data_)) {
                        error_counter_               = 0;
                        rs2::video_frame color_frame = 
rs_rgb_data_.first(RS2_STREAM_COLOR, RS2_FORMAT_RGB8);
-                       image_name_ =
-                         rgb_path_ + read_camera_control() + 
color_frame.get_profile().stream_name() + ".png";
+                       image_name_ = rgb_path_ + obj_name_ + 
color_frame.get_profile().stream_name() + ".png";
                        png_writer_.set_filename(image_name_.c_str());
                        png_writer_.set_dimensions(color_frame.get_width(), 
color_frame.get_height());
                        png_writer_.set_buffer(firevision::RGB, (unsigned char 
*)color_frame.get_data());
                        png_writer_.write();
                        camera_if_->set_image_name(image_name_.c_str());
+                       camera_if_->set_msgid(camera_if_last_msgid_);
                        camera_if_->write();
                        logger->log_info(name(), "Saving image to %s", 
image_name_.c_str());
                } else {
@@ -423,10 +423,10 @@ Realsense2Thread::pixel_to_xyz()
        float            xyz1[3];
        float            xyz2[3];
        float            xyz3[3];
-       float            x = 0;
-       float            y = 0;
-       float            z = 0;
-       int              counter;
+       float            x       = 0;
+       float            y       = 0;
+       float            z       = 0;
+       int              counter = 0;
 
        // get average xyz from (bounding box/2), throw away xyz = 0,0,0
        int qwidth  = int(bb[2] / 4);
@@ -469,6 +469,8 @@ Realsense2Thread::pixel_to_xyz()
                        }
                }
        }
+       if (counter == 0)
+               counter++;
        x = x / counter;
        y = y / counter;
        z = z / counter;
@@ -502,23 +504,25 @@ Realsense2Thread::read_switch()
 
 /**
  * Read the CameraControl interface to take a picture.
- * @return object name.
+ * @return new msg recevied
  */
-std::string
+bool
 Realsense2Thread::read_camera_control()
 {
-       std::string object_name_ = "";
+       bool save = false;
        while (!camera_if_->msgq_empty()) {
                if 
(camera_if_->msgq_first_is<CameraControlInterface::SaveImageMessage>()) {
                        CameraControlInterface::SaveImageMessage *msg =
                          
camera_if_->msgq_first<CameraControlInterface::SaveImageMessage>();
-                       std::string object_name_(msg->image_name());
+                       obj_name_             = std::string(msg->image_name());
+                       camera_if_last_msgid_ = msg->id();
+                       save                  = true;
                } else {
                        logger->log_warn(name(), "Unknown message received");
                }
                camera_if_->msgq_pop();
        }
-       return object_name_;
+       return save;
 }
 
 /**
diff --git a/src/plugins/realsense2/realsense2_thread.h 
b/src/plugins/realsense2/realsense2_thread.h
index b37ed4c03..28fbf55d5 100644
--- a/src/plugins/realsense2/realsense2_thread.h
+++ b/src/plugins/realsense2/realsense2_thread.h
@@ -65,7 +65,6 @@ public:
 private:
        bool             start_camera();
        bool             get_camera(rs2::device &dev);
-       bool             read_bounding_box(std::vector<int> &bb);
        void             enable_depth_stream();
        void             disable_depth_stream();
        void             stop_camera();
@@ -81,8 +80,9 @@ protected:
        }
 
 protected:
-       bool        read_switch();
-       std::string read_camera_control();
+       bool read_switch();
+       bool read_camera_control();
+       bool read_bounding_box(std::vector<int> &bb);
 
 private:
        fawkes::SwitchInterface *       switch_if_;
@@ -117,10 +117,12 @@ private:
        std::string rgb_path_;
        std::string image_name_;
        std::string camera_if_name_;
+       std::string obj_name_;
        uint        frame_rate_;
        int         rgb_frame_rate_;
        int         rgb_width_;
        int         rgb_height_;
+       int         camera_if_last_msgid_;
        float       laser_power_;
        bool        camera_running_ = false;
        bool        enable_camera_  = true;



_______________________________________________
fawkes-commits mailing list
[email protected]
https://lists.kbsg.rwth-aachen.de/listinfo/fawkes-commits

Reply via email to