Skip to content

Commit ed0b506

Browse files
author
plnegre
committed
Minnor changes
1 parent 8d81c28 commit ed0b506

File tree

7 files changed

+78
-24
lines changed

7 files changed

+78
-24
lines changed

bag_tools/launch/extract_images.launch

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- launch file for image extraction from a bagfile
2-
2+
33
this launch does a playback of a bagfile,
44
runs image processing to get coloured rectified images
55
from raw images, and saves the images to harddrive.
@@ -15,14 +15,25 @@
1515
-->
1616

1717
<launch>
18-
<arg name="bagfile" />
19-
<arg name="camera" default="camera_flex_wide/left" />
18+
<param name="/use_sim_time" value="true"/>
19+
<arg name="camera" default="/stereo_down/left" />
2020
<arg name="image" default="image_rect_color" />
2121
<arg name="format" default="frame%06i.png" />
22-
<arg name="rate" default="1.0" />
22+
<arg name="rate" default="50.0" />
23+
24+
<arg name="bagfile" default="/home/plnegre/workspace/ros/data/bagfiles/2015_Valldemossa/06/2015-06-08-20-28-51_0.bag
25+
/home/plnegre/workspace/ros/data/bagfiles/2015_Valldemossa/06/2015-06-08-20-30-18_1.bag
26+
/home/plnegre/workspace/ros/data/bagfiles/2015_Valldemossa/06/2015-06-08-20-31-46_2.bag
27+
/home/plnegre/workspace/ros/data/bagfiles/2015_Valldemossa/06/2015-06-08-20-33-14_3.bag
28+
/home/plnegre/workspace/ros/data/bagfiles/2015_Valldemossa/06/2015-06-08-20-34-41_4.bag
29+
/home/plnegre/workspace/ros/data/bagfiles/2015_Valldemossa/06/2015-06-08-20-36-09_5.bag
30+
/home/plnegre/workspace/ros/data/bagfiles/2015_Valldemossa/06/2015-06-08-20-37-36_6.bag
31+
/home/plnegre/workspace/ros/data/bagfiles/2015_Valldemossa/06/2015-06-08-20-39-04_7.bag
32+
/home/plnegre/workspace/ros/data/bagfiles/2015_Valldemossa/06/2015-06-08-20-40-31_8.bag
33+
/home/plnegre/workspace/ros/data/bagfiles/2015_Valldemossa/06/2015-06-08-20-41-59_9.bag"/>
2334

2435
<!-- playback the data -->
25-
<node pkg="rosbag" type="play" name="player" args="-d 1 -r $(arg rate) $(arg bagfile)" output="screen" required="true" />
36+
<node pkg="rosbag" type="play" name="player" args="-d 1 -r $(arg rate) $(arg bagfile)" required="true" />
2637

2738
<!-- run the image processing (de-bayering, undistortion, rectification) -->
2839
<node pkg="image_proc" type="image_proc" name="image_proc" ns="$(arg camera)" />

bag_tools/scripts/change_camera_info.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ def replacement(replace_string):
7575
cam_info.R = calib_data['rectification_matrix']['data']
7676
cam_info.P = calib_data['projection_matrix']['data']
7777
cam_info.distortion_model = calib_data['distortion_model']
78-
cam_info.binning_x = 1;
79-
cam_info.binning_y = 1;
80-
cam_info.roi.width = calib_data['image_width']
81-
cam_info.roi.height = calib_data['image_height']
78+
cam_info.binning_x = calib_data['binning_x']
79+
cam_info.binning_y = calib_data['binning_y']
80+
cam_info.roi.width = calib_data['roi_image_width']
81+
cam_info.roi.height = calib_data['roi_image_height']
82+
cam_info.roi.x_offset = calib_data['roi_x_offset']
83+
cam_info.roi.y_offset = calib_data['roi_y_offset']
8284
return pair[0], cam_info
8385

8486
if __name__ == "__main__":

bag_tools/scripts/check_delay.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
* Redistributions in binary form must reproduce the above copyright
1313
notice, this list of conditions and the following disclaimer in the
1414
documentation and/or other materials provided with the distribution.
15-
* Neither the name of Systems, Robotics and Vision Group, University of
16-
the Balearican Islands nor the names of its contributors may be used to
17-
endorse or promote products derived from this software without specific
15+
* Neither the name of Systems, Robotics and Vision Group, University of
16+
the Balearican Islands nor the names of its contributors may be used to
17+
endorse or promote products derived from this software without specific
1818
prior written permission.
1919
2020
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND

bag_tools/scripts/stereo_sequence_publisher.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
* Redistributions in binary form must reproduce the above copyright
1616
notice, this list of conditions and the following disclaimer in the
1717
documentation and/or other materials provided with the distribution.
18-
* Neither the name of Systems, Robotics and Vision Group, University of
19-
the Balearican Islands nor the names of its contributors may be used to
20-
endorse or promote products derived from this software without specific
18+
* Neither the name of Systems, Robotics and Vision Group, University of
19+
the Balearican Islands nor the names of its contributors may be used to
20+
endorse or promote products derived from this software without specific
2121
prior written permission.
2222
2323
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
@@ -45,13 +45,13 @@
4545
import numpy as np
4646
import re
4747

48-
def natural_sort(l):
49-
convert = lambda text: int(text) if text.isdigit() else text.lower()
50-
alphanum_key = lambda key: [ convert(c) for c in re.split('([0-9]+)', key) ]
48+
def natural_sort(l):
49+
convert = lambda text: int(text) if text.isdigit() else text.lower()
50+
alphanum_key = lambda key: [ convert(c) for c in re.split('([0-9]+)', key) ]
5151
return sorted(l, key = alphanum_key)
5252

5353
def collect_image_files(image_dir,file_pattern):
54-
images = glob.glob(image_dir + '/' + file_pattern)
54+
images = glob.glob(image_dir + '/' + str(file_pattern))
5555
images = natural_sort(images)
5656
return images
5757

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
# Set your camera calibration files
4+
L_CALIB="/data/HD3/bagfiles/turbot/2016_06_13_sant_feliu/l_calibration_water_bags.yaml"
5+
R_CALIB="/data/HD3/bagfiles/turbot/2016_06_13_sant_feliu/r_calibration_water_bags.yaml"
6+
7+
# Set the directories where the bagfiles are
8+
DIRS="13 14 15 16 17"
9+
10+
11+
12+
for d in $DIRS
13+
do
14+
echo "---- DIRECTORY $d ----"
15+
16+
mkdir corrected
17+
FILES=*.bag
18+
for f in $FILES
19+
do
20+
echo "Changing bag: $f"
21+
rosrun bag_tools change_camera_info.py $f corrected/$f /stereo_down/left/camera_info=$L_CALIB /stereo_down/right/camera_info=$R_CALIB
22+
done
23+
24+
done

pointcloud_tools/src/pointcloud_viewer.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include <pcl/visualization/pcl_visualizer.h>
4949
#include <pcl/features/feature.h>
5050
#include <pcl/io/pcd_io.h>
51+
#include <pcl/filters/statistical_outlier_removal.h>
5152

5253
using pcl::visualization::PointCloudColorHandlerGenericField;
5354

@@ -185,7 +186,15 @@ void saveCallback(const ros::WallTimerEvent&)
185186

186187
if (cloud_xyz_rgb_.size() > 0)
187188
{
188-
if (pcl::io::savePCDFile(pcd_filename_, cloud_xyz_rgb_) == 0)
189+
// Remove outliers
190+
pcl::PointCloud<PointRGB>::Ptr cloud_filtered (new pcl::PointCloud<PointRGB>);
191+
pcl::StatisticalOutlierRemoval<PointRGB> sor;
192+
sor.setInputCloud (cloud_xyz_rgb_.makeShared());
193+
sor.setMeanK (50);
194+
sor.setStddevMulThresh (1.0);
195+
sor.filter (*cloud_filtered);
196+
197+
if (pcl::io::savePCDFile(pcd_filename_, *cloud_filtered) == 0)
189198
ROS_INFO_STREAM("[PointCloudViewer:] Pointcloud saved into: " << pcd_filename_);
190199
else
191200
ROS_ERROR_STREAM("[PointCloudViewer:] Problem saving " << pcd_filename_.c_str());
@@ -194,7 +203,15 @@ void saveCallback(const ros::WallTimerEvent&)
194203

195204
if (cloud_xyz_.size() > 0)
196205
{
197-
if (pcl::io::savePCDFile(pcd_filename_, cloud_xyz_) == 0)
206+
// Remove outliers
207+
pcl::PointCloud<Point>::Ptr cloud_filtered (new pcl::PointCloud<Point>);
208+
pcl::StatisticalOutlierRemoval<Point> sor;
209+
sor.setInputCloud (cloud_xyz_.makeShared());
210+
sor.setMeanK (50);
211+
sor.setStddevMulThresh (1.0);
212+
sor.filter (*cloud_filtered);
213+
214+
if (pcl::io::savePCDFile(pcd_filename_, *cloud_filtered) == 0)
198215
ROS_INFO_STREAM("[PointCloudViewer:] Pointcloud saved into: " << pcd_filename_);
199216
else
200217
ROS_ERROR_STREAM("[PointCloudViewer:] Problem saving " << pcd_filename_.c_str());

tf_tools/src/apply_tf_to_odom_msg.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ApplyTF2Odom
2525
nh_private_.param("qx", qx, 0.0);
2626
nh_private_.param("qy", qy, 0.0);
2727
nh_private_.param("qz", qz, 0.0);
28-
nh_private_.param("qw", qw, 0.0);
28+
nh_private_.param("qw", qw, 1.0);
2929

3030
// Build tf
3131
tf::Vector3 t(x, y, z);
@@ -52,11 +52,11 @@ class ApplyTF2Odom
5252

5353
// Build the odometry pose
5454
tf::Vector3 t(x, y, z);
55-
tf::Quaternion q(qx, qy, qz, qw);
55+
tf::Quaternion q(qx, qy, qz, 1.0);
5656
tf::Transform pose(q, t);
5757

5858
// Transform
59-
tf::Transform new_pose = pose * trans_;
59+
tf::Transform new_pose = trans_ * pose;
6060

6161
// Publish
6262
nav_msgs::Odometry new_odom_msg = *odom_msg;

0 commit comments

Comments
 (0)