Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
fed6f70
Add internal IMU data publisher by ros::Timer
tongtybj Jun 5, 2018
291ccf5
Modification for a correct merge
Myzhar Jun 25, 2018
c218cd2
Merge branch 'tongtybj-imu_pub' into devel
Myzhar Jun 25, 2018
4378c2e
Merge pull request #217 from stereolabs/master
Myzhar Jun 25, 2018
e1c80d9
Merge pull request #218 from stereolabs/master
Myzhar Jun 25, 2018
90fe983
Corrected issue with IMU reference frame
Myzhar Jun 26, 2018
845e96b
Code reformatting
Myzhar Jun 26, 2018
c893e79
Removed unuseful parameters from publisher functions that were using …
Myzhar Jun 26, 2018
1a7857c
Merged PR #189 : Add publisher for disparity
Myzhar Jun 26, 2018
f2bbd93
Added launch example to run ZED as a nodelet with ROS nodelet manager
Myzhar Jun 27, 2018
9571146
Code refactoring
Myzhar Jun 27, 2018
7c45753
Code refactoring
Myzhar Jun 27, 2018
19e1f0c
Added coordinate system conversion to ROS according to ZED SDK version
Myzhar Jun 27, 2018
633b848
Improved performances using OpenMP
Myzhar Jun 28, 2018
4870071
Modify resolution by launch file
Myzhar Jun 28, 2018
1157cfe
Coordinate changes for Z_UP-X_FWD removed
Myzhar Jun 28, 2018
68d472d
Added ROS service to request resetTracking to ZED SDK
Myzhar Jun 29, 2018
5d0d7fe
Reorganized ZED TF Tree according to ROS conventions
Myzhar Jun 29, 2018
027aabc
Minor changes to file names and code order
Myzhar Jul 2, 2018
f44f0e3
Fixed compilation error with SDK minor than v2.5.x
Myzhar Jul 2, 2018
7f939a5
Fixed issue #212 : zed-wrapper-node running on TX2 freezes when no
Myzhar Jul 2, 2018
a5eec02
Publishing odometry when depth_map topic is subscribed (same as for
Myzhar Jul 2, 2018
2563432
Added publishers for Confidence Image (8 bit) and Confidence Map (float)
Myzhar Jul 2, 2018
d9e88e9
Exposed enable_pose_smoothing and enable_spatial_memory params for
Myzhar Jul 3, 2018
8fa4b52
Exposed "initial_pose" to initialize tracking position
Myzhar Jul 3, 2018
f664f87
Modified "reset_tracking" to reset to "initial_pose" from Param Server
Myzhar Jul 3, 2018
452aaa8
Added service to set pose
Myzhar Jul 4, 2018
29c681b
Fixed issue with "Camera info" when setting new "mat_resize_factor"
Myzhar Jul 5, 2018
9f44001
Added missing set_pose.srv
Myzhar Jul 5, 2018
8c279bd
Removed odometry and replaced with "map pose"
Myzhar Jul 5, 2018
ae74d6c
Fixes the "unchecking/checking" depth cloud problem
Myzhar Jul 5, 2018
9178296
Added tool function slTime2Ros to fix timestamp
Myzhar Jul 5, 2018
195fd68
Coordinate changing code cleaned
Myzhar Jul 6, 2018
95bdebd
Added "imu/data_raw" topic according to ROS REP145
Myzhar Jul 6, 2018
f0be773
Update to publish IMU TF and topics at about 500 Hz
Myzhar Jul 6, 2018
d7ccb07
Added IMU R,t transform to zed_camera_center [TO BE CHECKED]
Myzhar Jul 6, 2018
a6f4136
Fixed issue with IMU link timestamp
Myzhar Jul 9, 2018
c226489
Added back odometry frame (together with map)
Myzhar Jul 9, 2018
b9b9659
Fixed IMU reference frame
Myzhar Jul 10, 2018
5087218
Fixed odometry transformation. Delta movements that are in camera frame
Myzhar Jul 11, 2018
ffc7ad3
Fixed IMU frame publishing
Myzhar Jul 12, 2018
22014ee
Added "verbose" parameter as for zendesk request
Myzhar Jul 12, 2018
668911d
Removed unuseful `include`
Myzhar Jul 13, 2018
e627f2c
Uniformed member variable names to camel case
Myzhar Jul 13, 2018
9c5c346
Modified logger level automatically to "Debug" if node is compiled with
Myzhar Jul 13, 2018
832be65
Added debug info about working thread duration in case it does not
Myzhar Jul 13, 2018
0c38c3a
Exposed "frame_rate" to "zed.launch" file
Myzhar Jul 13, 2018
6f04504
Added option "init_odom_with_imu" to initialize odometry with first pose
Myzhar Jul 16, 2018
8d7220b
Added check on the couple "resolution/framerate".
Myzhar Jul 16, 2018
544f74d
Updated all launch files to latest modifications
Myzhar Jul 16, 2018
3a98446
Fixed bug when the couple "resolution/framerate" was valid
Myzhar Jul 16, 2018
edc4e0f
Added service to reset odometry and clear drift errors.
Myzhar Jul 16, 2018
88bffb2
Exposed the SVO and Odometry Frame parameters to "zed.launch"
Myzhar Jul 16, 2018
7f8d8cf
Reduced the number of warning messages in the case that elaboration time
Myzhar Jul 16, 2018
775a963
Fixed "SIGTERM if no ZED was open" using the Serial Number
Myzhar Jul 16, 2018
1f0d41d
Code cleaning
Myzhar Jul 16, 2018
9c7c434
Fix for IMU TF not propagating in Rviz
Myzhar Jul 16, 2018
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
Prev Previous commit
Next Next commit
Fixed issue with IMU link timestamp
  • Loading branch information
Myzhar committed Jul 9, 2018
commit a6f4136a07631b44af649d39b2c1f9d086dde0a2
12 changes: 8 additions & 4 deletions launch/zed_camera.launch
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

<!-- Publish urdf zed -->
<arg name="publish_urdf" default="true" />

<arg name="rgb_topic" default="rgb/image_rect_color" />
<arg name="rgb_info_topic" default="rgb/camera_info" />
<arg name="depth_topic" default="depth/depth_registered" />

<node name="zed_wrapper_node" pkg="zed_wrapper" type="zed_wrapper_node" output="screen" required="true"><!-- launch-prefix="valgrind" -->
<node name="zed_wrapper_node" pkg="zed_wrapper" type="zed_wrapper_node" output="screen" required="true"><!-- launch-prefix="valgrind" -->

<param name="camera_model" value="$(arg camera_model)" />

Expand Down Expand Up @@ -83,9 +87,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<rosparam param="initial_tracking_pose" subst_value="True">$(arg initial_pose)</rosparam>

<!-- ROS topic names -->
<param name="rgb_topic" value="rgb/image_rect_color" />
<param name="rgb_topic" value="$(arg rgb_topic)" />
<param name="rgb_raw_topic" value="rgb/image_raw_color" />
<param name="rgb_cam_info_topic" value="rgb/camera_info" />
<param name="rgb_cam_info_topic" value="$(arg rgb_info_topic)" />
<param name="rgb_cam_info_raw_topic" value="rgb/camera_info_raw" />

<param name="left_topic" value="left/image_rect_color" />
Expand All @@ -98,7 +102,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<param name="right_cam_info_topic" value="right/camera_info" />
<param name="right_cam_info_raw_topic" value="right/camera_info_raw" />

<param name="depth_topic" value="depth/depth_registered" />
<param name="depth_topic" value="$(arg depth_topic)" />
<param name="depth_cam_info_topic" value="depth/camera_info" />

<param name="point_cloud_topic" value="point_cloud/cloud_registered" />
Expand Down
46 changes: 25 additions & 21 deletions launch/zed_camera_nodelet.launch
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

<!-- Publish urdf zed -->
<arg name="publish_urdf" default="true" />

<node pkg="nodelet" type="nodelet" name="ZED_nodelet" args="load zed_wrapper/ZEDWrapperNodelet nodelet_manager" output="screen">

<arg name="rgb_topic" default="rgb/image_rect_color" />
<arg name="rgb_info_topic" default="rgb/camera_info" />
<arg name="depth_topic" default="depth/depth_registered" />

<node pkg="nodelet" type="nodelet" name="ZED_nodelet" args="load zed_wrapper/ZEDWrapperNodelet nodelet_manager" output="screen">

<param name="camera_model" value="$(arg camera_model)" />

Expand Down Expand Up @@ -83,37 +87,37 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<rosparam param="initial_tracking_pose" subst_value="True">$(arg initial_pose)</rosparam>

<!-- ROS topic names -->
<param name="rgb_topic" value="rgb/image_rect_color" />
<param name="rgb_raw_topic" value="rgb/image_raw_color" />
<param name="rgb_cam_info_topic" value="rgb/camera_info" />
<param name="rgb_topic" value="$(arg rgb_topic)" />
<param name="rgb_raw_topic" value="rgb/image_raw_color" />
<param name="rgb_cam_info_topic" value="$(arg rgb_info_topic)" />
<param name="rgb_cam_info_raw_topic" value="rgb/camera_info_raw" />

<param name="left_topic" value="left/image_rect_color" />
<param name="left_raw_topic" value="left/image_raw_color" />
<param name="left_cam_info_topic" value="left/camera_info" />
<param name="left_topic" value="left/image_rect_color" />
<param name="left_raw_topic" value="left/image_raw_color" />
<param name="left_cam_info_topic" value="left/camera_info" />
<param name="left_cam_info_raw_topic" value="left/camera_info_raw" />

<param name="right_topic" value="right/image_rect_color" />
<param name="right_raw_topic" value="right/image_raw_color" />
<param name="right_cam_info_topic" value="right/camera_info" />
<param name="right_topic" value="right/image_rect_color" />
<param name="right_raw_topic" value="right/image_raw_color" />
<param name="right_cam_info_topic" value="right/camera_info" />
<param name="right_cam_info_raw_topic" value="right/camera_info_raw" />

<param name="depth_topic" value="depth/depth_registered" />
<param name="depth_cam_info_topic" value="depth/camera_info" />
<param name="depth_topic" value="$(arg depth_topic)" />
<param name="depth_cam_info_topic" value="depth/camera_info" />

<param name="point_cloud_topic" value="point_cloud/cloud_registered" />
<param name="point_cloud_topic" value="point_cloud/cloud_registered" />

<param name="disparity_topic" value="disparity/disparity_image" />
<param name="confidence_img_topic" value="confidence/confidence_image" />
<param name="confidence_map_topic" value="confidence/confidence_map" />
<param name="disparity_topic" value="disparity/disparity_image" />
<param name="confidence_img_topic" value="confidence/confidence_image" />
<param name="confidence_map_topic" value="confidence/confidence_map" />


<param name="pose_topic" value="map" />
<param name="pose_topic" value="map" />

<param name="imu_topic" value="imu/data" />
<param name="imu_topic_raw" value="imu/data_raw" />
<param name="imu_topic" value="imu/data" />
<param name="imu_topic_raw" value="imu/data_raw" />

<param name="imu_pub_rate" value="100.0" />
<param name="imu_pub_rate" value="500.0" />

</node>

Expand Down
6 changes: 5 additions & 1 deletion src/nodelet/include/zed_wrapper_nodelet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ namespace zed_wrapper {
* \param base_transform : Transformation representing the imu pose from camera frame
* \param t : the ros::Time to stamp the image
*/
void publishImuFrame(tf2::Transform base_transform, ros::Time t);
void publishImuFrame(tf2::Transform base_transform);

/* \brief Publish a cv::Mat image with a ros Publisher
* \param img : the image to publish
Expand Down Expand Up @@ -282,6 +282,9 @@ namespace zed_wrapper {
std::string svo_filepath;
double imu_pub_rate;

// IMU time
ros::Time imu_time;

bool pose_smoothing;
bool spatial_memory;

Expand All @@ -291,6 +294,7 @@ namespace zed_wrapper {
std::vector<float> initial_track_pose;
tf2::Transform pose_base_transform;
//tf2::Transform odom_base_transform;
tf2::Transform imu_base_transform;
sl::Transform initial_pose_sl;

// zed object
Expand Down
47 changes: 22 additions & 25 deletions src/nodelet/src/zed_wrapper_nodelet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ void ZEDWrapperNodelet::onInit() {
set_pose( initial_track_pose[0], initial_track_pose[1], initial_track_pose[2],
initial_track_pose[3], initial_track_pose[4], initial_track_pose[5]);


// Initialization transformation listener
tfBuffer.reset(new tf2_ros::Buffer);
tf_listener.reset(new tf2_ros::TransformListener(*tfBuffer));
Expand Down Expand Up @@ -438,12 +437,13 @@ void ZEDWrapperNodelet::onInit() {

// Imu publisher
if(imu_pub_rate > 0 && realCamModel == sl::MODEL_ZED_M) {
pub_imu = nh.advertise<sensor_msgs::Imu>(imu_topic, 1);
pub_imu = nh.advertise<sensor_msgs::Imu>(imu_topic, 500);
NODELET_INFO_STREAM("Advertized on topic " << imu_topic << " @ " << imu_pub_rate << " Hz");

pub_imu_raw = nh.advertise<sensor_msgs::Imu>(imu_topic_raw, 1);
pub_imu_raw = nh.advertise<sensor_msgs::Imu>(imu_topic_raw, 500);
NODELET_INFO_STREAM("Advertized on topic " << imu_topic_raw << " @ " << imu_pub_rate << " Hz");

imu_time = ros::Time::now();
pub_imu_timer = nh_ns.createTimer(ros::Duration(1.0 / imu_pub_rate), &ZEDWrapperNodelet::imuPubCallback,this);
} else if(imu_pub_rate > 0 && realCamModel == sl::MODEL_ZED) {
NODELET_WARN_STREAM( "'imu_pub_rate' set to " << imu_pub_rate << " Hz" << " but ZED camera model does not support IMU data publishing.");
Expand Down Expand Up @@ -660,9 +660,9 @@ void ZEDWrapperNodelet::publishPoseFrame(tf2::Transform base_transform, ros::Tim
// transform_odom_broadcaster.sendTransform(transformStamped);
//}

void ZEDWrapperNodelet::publishImuFrame(tf2::Transform base_transform, ros::Time t) {
void ZEDWrapperNodelet::publishImuFrame(tf2::Transform base_transform) {
geometry_msgs::TransformStamped transformStamped;
transformStamped.header.stamp = t;
transformStamped.header.stamp = imu_time;
transformStamped.header.frame_id = base_frame_id;
transformStamped.child_frame_id = imu_frame_id;
// conversion from Tranform to message
Expand Down Expand Up @@ -891,8 +891,7 @@ void ZEDWrapperNodelet::dynamicReconfCallback(zed_wrapper::ZedConfig &config, ui
}
}

void ZEDWrapperNodelet::imuPubCallback(const ros::TimerEvent & e)
{
void ZEDWrapperNodelet::imuPubCallback(const ros::TimerEvent & e) {
int imu_SubNumber = pub_imu.getNumSubscribers();
int imu_RawSubNumber = pub_imu_raw.getNumSubscribers();

Expand All @@ -901,14 +900,14 @@ void ZEDWrapperNodelet::imuPubCallback(const ros::TimerEvent & e)
return;
}

ros::Time t = sl_tools::slTime2Ros(zed.getTimestamp(sl::TIME_REFERENCE_CURRENT));
ros::Time t = sl_tools::slTime2Ros(zed.getTimestamp(sl::TIME_REFERENCE_IMAGE));

sl::IMUData imu_data;
zed.getIMUData(imu_data, sl::TIME_REFERENCE_CURRENT);

if (imu_SubNumber > 0) {
sensor_msgs::Imu imu_msg;
imu_msg.header.stamp = t;
imu_msg.header.stamp = imu_time; //t;
imu_msg.header.frame_id = imu_frame_id;

imu_msg.orientation.x = x_sign * imu_data.getOrientation()[x_idx];
Expand Down Expand Up @@ -944,7 +943,7 @@ void ZEDWrapperNodelet::imuPubCallback(const ros::TimerEvent & e)

if (imu_RawSubNumber > 0) {
sensor_msgs::Imu imu_raw_msg;
imu_raw_msg.header.stamp = t;
imu_raw_msg.header.stamp = imu_time; //t;
imu_raw_msg.header.frame_id = imu_frame_id;

imu_raw_msg.angular_velocity.x = x_sign * imu_data.angular_velocity[x_idx];
Expand Down Expand Up @@ -1024,24 +1023,18 @@ void ZEDWrapperNodelet::imuPubCallback(const ros::TimerEvent & e)
base_to_sensor.setIdentity();
}

// IMU to base
tf2::Transform imu_transform;

imu_transform = base_to_sensor * imu_sensor * imu_sensor.inverse();


//Note, the frame is published, but its values will only change if someone has subscribed to odom
publishImuFrame(imu_transform, t); //publish the tracked Frame

imu_base_transform = base_to_sensor * imu_sensor * imu_sensor.inverse();

//Note, the frame is published, but its values will only change if someone has subscribed to IMU
publishImuFrame(imu_base_transform); //publish the imu Frame
}
}

void ZEDWrapperNodelet::device_poll() {
ros::Rate loop_rate(rate);

//ros::Time old_t = ros::Time::now();
ros::Time old_t = sl_tools::slTime2Ros(zed.getTimestamp(sl::TIME_REFERENCE_CURRENT));
imu_time = old_t;

sl::ERROR_CODE grab_status;
tracking_activated = false;
Expand Down Expand Up @@ -1105,7 +1098,7 @@ void ZEDWrapperNodelet::device_poll() {
//ros::Time t = ros::Time::now(); // Get current time

// Timestamp
ros::Time t = sl_tools::slTime2Ros(zed.getTimestamp(sl::TIME_REFERENCE_IMAGE));
ros::Time t = sl_tools::slTime2Ros(zed.getTimestamp(sl::TIME_REFERENCE_IMAGE));

grabbing = true;
if (computeDepth) {
Expand Down Expand Up @@ -1160,7 +1153,7 @@ void ZEDWrapperNodelet::device_poll() {
}

// Time update
old_t = sl_tools::slTime2Ros(zed.getTimestamp(sl::TIME_REFERENCE_CURRENT));
old_t = sl_tools::slTime2Ros(zed.getTimestamp(sl::TIME_REFERENCE_CURRENT));

if (autoExposure) {
// getCameraSettings() can't check status of auto exposure
Expand Down Expand Up @@ -1370,20 +1363,24 @@ void ZEDWrapperNodelet::device_poll() {
// publishOdom(odom_base_transform, t);
// }

// Publish odometry tf only if enabled
// Publish pose tf only if enabled
if (publish_tf) {
//Note, the frame is published, but its values will only change if someone has subscribed to map
publishPoseFrame(pose_base_transform, t);
//Note, the frame is published, but its values will only change if someone has subscribed to odom
//publishOdomFrame(odom_base_transform, t); //publish the tracked Frame
//publishImuFrame(imu_base_transform, t); //publish the imu Frame
imu_time = t;
}

loop_rate.sleep();
} else {
// Publish odometry tf only if enabled
if (publish_tf) {
publishPoseFrame(pose_base_transform, sl_tools::slTime2Ros(zed.getTimestamp(sl::TIME_REFERENCE_CURRENT)));
//publishOdomFrame(odom_base_transform, ros::Time::now()); //publish the tracked Frame before the sleep
ros::Time t = sl_tools::slTime2Ros(zed.getTimestamp(sl::TIME_REFERENCE_CURRENT));
publishPoseFrame(pose_base_transform, t);
//publishOdomFrame(odom_base_transform, t); //publish the tracked Frame before the sleep
//publishImuFrame(imu_base_transform, t); //publish the imu Frame
}
std::this_thread::sleep_for(std::chrono::milliseconds(10)); // No subscribers, we just wait
}
Expand Down
5 changes: 3 additions & 2 deletions src/zed_wrapper_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
int main(int argc, char** argv) {
ros::init(argc, argv, "zed_wrapper_node");

// ZED Nodelet
nodelet::Loader nodelet;
nodelet::M_string remap(ros::names::getRemappings());
nodelet::V_string nargv;
nodelet.load(ros::this_node::getName(),
"zed_wrapper/ZEDWrapperNodelet",
remap, nargv);
"zed_wrapper/ZEDWrapperNodelet",
remap, nargv);

ros::spin();

Expand Down