Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/zed_wrapper_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <limits>
#include <thread>
#include <chrono>
#include <memory>

//ROS includes
#include <ros/ros.h>
Expand Down Expand Up @@ -298,7 +299,7 @@ int main(int argc, char **argv) {
nh_ns.getParam("cloud_frame_id", cloud_frame_id);

// Create the ZED object
sl::zed::Camera *zed;
std::unique_ptr<sl::zed::Camera> zed;
if (argc == 2) {
zed = new sl::zed::Camera(argv[1]); // Argument "svo_file" in launch file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line doesn't pass the compilation process.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What error does it give? I'm afraid I don't have access to a suitable compiler on my platform, and access to my embedded target is intermittent. Thanks for testing this for me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's 21:40pm for me, so I don't have the error log with me, but I'll tell you tomorrow! However, I'm not used to std::unique_ptr, but don't we need to use std::move() to set the pointed object?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks! I won't be able to try things myself till then anyway.

I misread which line your comment was on. I think I see the fix.

ROS_INFO_STREAM("Reading SVO file : " << argv[1]);
Expand Down Expand Up @@ -370,14 +371,14 @@ int main(int argc, char **argv) {
sensor_msgs::CameraInfoPtr left_cam_info_msg(new sensor_msgs::CameraInfo());
sensor_msgs::CameraInfoPtr right_cam_info_msg(new sensor_msgs::CameraInfo());
sensor_msgs::CameraInfoPtr depth_cam_info_msg(new sensor_msgs::CameraInfo());
fillCamInfo(zed, left_cam_info_msg, right_cam_info_msg, left_frame_id, right_frame_id);
fillCamInfo(zed.get(), left_cam_info_msg, right_cam_info_msg, left_frame_id, right_frame_id);
rgb_cam_info_msg = depth_cam_info_msg = left_cam_info_msg; // the reference camera is the Left one (next to the ZED logo)

ros::Rate loop_rate(rate);
ros::Time old_t = ros::Time::now();
bool old_image = false;
pointCloudThreadRunning = false;
std::thread* pointCloudThread = NULL;
std::unique_ptr<std::thread> pointCloudThread = nullptr;

try {
// Main loop
Expand Down Expand Up @@ -408,8 +409,8 @@ int main(int argc, char **argv) {
ROS_WARN("Wait for a new image to proceed");
std::this_thread::sleep_for(std::chrono::milliseconds(2));
if ((t - old_t).toSec() > 5) {
sl::zed::Camera* corruptedObject = zed;
delete corruptedObject;
// delete the old object before constructing a new one
zed.reset();
if (argc == 2) {
zed = new sl::zed::Camera(argv[1]); // Argument "svo_file" in launch file
ROS_INFO_STREAM("Reading SVO file : " << argv[1]);
Expand Down Expand Up @@ -481,7 +482,5 @@ int main(int argc, char **argv) {
}
ROS_INFO("Quitting zed_depth_stereo_wrapper_node ...\n");

delete zed;

return 0;
}