Skip to content

Commit 5f3d1e4

Browse files
committed
Fix SLAM
1 parent 3a96873 commit 5f3d1e4

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

src/localizers/orb_slam3/orb_slam3.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ IMU.GyroWalk: 3.6009359675890065e-05
4242
#--------------------------------------------------------------------------------------------
4343

4444
# ORB Extractor: Number of features per image
45-
ORBextractor.nFeatures: 1000 # 1000
45+
ORBextractor.nFeatures: 1200 # 1000
4646

4747
# ORB Extractor: Scale factor between levels in the scale pyramid
4848
ORBextractor.scaleFactor: 1.3

src/localizers/orb_slam3/script/slam_absolute.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
# init data
2929
yaw_offs_init = 0
30-
yaw_offs_inits = []
3130

3231
# ransac variables
3332
ransac_pairs = []
@@ -69,21 +68,19 @@ def height_callback(height):
6968
global lsy, ransac_complete
7069
if ransac_complete is False and lsy is not None and last_yaw is not None:
7170
ransac_pairs.append((height.data, lsy))
72-
# yaw_offs_inits.append(last_yaw - lsyaw)
73-
yaw_offs_inits.append(last_yaw)
7471

7572
if len(ransac_pairs) < 50:
7673
print("Collecting data for ransac. Frames: %d" % len(ransac_pairs))
7774
else:
78-
perform_ransac(0.3, 5000)
75+
perform_ransac(0.2, 5000)
7976
print("SLAM RANSAC error: %f" % ransac_err)
8077

81-
if ransac_err <= 0.2:
78+
if ransac_err <= 0.3:
8279
global yaw_offs_init
8380
print("RANSAC scale: %f su/m" % ransac_m_k)
8481

8582
# determine yaw offset
86-
yaw_offs_init = sum(yaw_offs_inits) / len(yaw_offs_inits)
83+
yaw_offs_init = lsyaw
8784
print("Yaw offset: %f deg" % ((yaw_offs_init * 180) / np.pi))
8885

8986
ransac_complete = True
@@ -92,7 +89,7 @@ def height_callback(height):
9289

9390

9491
def pose_callback(pose):
95-
global ransac_pairs, lsyaw, yaw_offs_init, yaw_offs_inits, p_off_x, p_off_y, \
92+
global ransac_pairs, lsyaw, yaw_offs_init, p_off_x, p_off_y, \
9693
ransac_complete, ransac_err, ransac_m_k, lsx, lsz, lst, lsy
9794

9895
# reset estimator if invalid data
@@ -105,7 +102,6 @@ def pose_callback(pose):
105102
p_off_x = None
106103
p_off_y = None
107104
yaw_offs_init = 0
108-
yaw_offs_inits = []
109105
ransac_pairs = []
110106
ransac_complete = False
111107
ransac_err = 1

src/localizers/orb_slam3/src/orb_slam3.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ void grabImage(const sensor_msgs::ImageConstPtr &msg) {
3939
pose.pose.pose.position.y = Twc.at<float>(1, 3);
4040
pose.pose.pose.position.z = Twc.at<float>(2, 3);
4141

42-
tf2::Matrix3x3 tf2_rot(Twc.at<double>(0, 0), Twc.at<double>(0, 1), Twc.at<double>(0, 2),
43-
Twc.at<double>(1, 0), Twc.at<double>(1, 1), Twc.at<double>(1, 2),
44-
Twc.at<double>(2, 0), Twc.at<double>(2, 1), Twc.at<double>(2, 2));
42+
tf2::Matrix3x3 tf2_rot(Twc.at<float>(0, 0), Twc.at<float>(0, 1), Twc.at<float>(0, 2),
43+
Twc.at<float>(1, 0), Twc.at<float>(1, 1), Twc.at<float>(1, 2),
44+
Twc.at<float>(2, 0), Twc.at<float>(2, 1), Twc.at<float>(2, 2));
4545
tf2::Quaternion tf2_quat_rot;
4646
tf2_rot.getRotation(tf2_quat_rot);
4747
pose.pose.pose.orientation = tf2::toMsg(tf2_quat_rot);

0 commit comments

Comments
 (0)