Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
larm-astro
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Inès EL HADRI
larm-astro
Commits
7ccfe07f
Commit
7ccfe07f
authored
Jan 22, 2024
by
Inès EL HADRI
💤
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix marker pos in map instead of odom
parent
5484b314
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
14 deletions
+28
-14
bottle_mapping
grp_astro/src/bottle_mapping
+28
-14
No files found.
grp_astro/src/bottle_mapping
View file @
7ccfe07f
...
@@ -70,16 +70,30 @@ class BottleMapping(Node):
...
@@ -70,16 +70,30 @@ class BottleMapping(Node):
bottleOffsetToRobot
.
x
+=
camOffset
bottleOffsetToRobot
.
x
+=
camOffset
# Get bottle coordinates relative to map
# Get bottle coordinates relative to Odom
newPose
=
Pose
()
newPoseInOdom
=
Pose
()
newPose
.
position
=
self
.
_robotPose
.
position
newPoseInOdom
.
position
=
self
.
_robotPose
.
position
a
=
Odometry
()
yaw
=
self
.
getRobotRotation
(
)
yaw
=
self
.
quaternionToYaw
(
self
.
_robotPose
.
orientation
)
newPose
.
position
.
x
+=
bottleOffsetToRobot
.
x
*
m
.
cos
(
yaw
)
-
bottleOffsetToRobot
.
y
*
m
.
sin
(
yaw
)
newPose
InOdom
.
position
.
x
+=
bottleOffsetToRobot
.
x
*
m
.
cos
(
yaw
)
-
bottleOffsetToRobot
.
y
*
m
.
sin
(
yaw
)
newPose
.
position
.
y
+=
bottleOffsetToRobot
.
x
*
m
.
sin
(
yaw
)
+
bottleOffsetToRobot
.
y
*
m
.
cos
(
yaw
)
newPose
InOdom
.
position
.
y
+=
bottleOffsetToRobot
.
x
*
m
.
sin
(
yaw
)
+
bottleOffsetToRobot
.
y
*
m
.
cos
(
yaw
)
newPosition
=
newPose
.
position
# Add offset to map
trans
=
self
.
_tf_buffer
.
lookup_transform
(
"map"
,
"odom"
,
rclpy
.
time
.
Time
())
newPoseInMap
=
Pose
()
newPoseInMap
.
position
.
x
=
trans
.
transform
.
translation
.
x
newPoseInMap
.
position
.
y
=
trans
.
transform
.
translation
.
y
newPoseInMap
.
position
.
z
=
trans
.
transform
.
translation
.
z
yaw
=
self
.
quaternionToYaw
(
trans
.
transform
.
rotation
)
newPoseInMap
.
position
.
x
+=
newPoseInOdom
.
position
.
x
*
m
.
cos
(
yaw
)
-
newPoseInOdom
.
position
.
y
*
m
.
sin
(
yaw
)
newPoseInMap
.
position
.
y
+=
newPoseInOdom
.
position
.
x
*
m
.
sin
(
yaw
)
+
newPoseInOdom
.
position
.
y
*
m
.
cos
(
yaw
)
newPosition
=
newPoseInMap
.
position
# Compare it with other markers
# Compare it with other markers
isNewPoint
=
True
isNewPoint
=
True
...
@@ -95,7 +109,7 @@ class BottleMapping(Node):
...
@@ -95,7 +109,7 @@ class BottleMapping(Node):
# Create Marker
# Create Marker
marker
=
self
.
createMarker
(
newPose
)
marker
=
self
.
createMarker
(
newPose
InMap
)
# Add marker to list
# Add marker to list
self
.
_markers
.
append
(
marker
)
self
.
_markers
.
append
(
marker
)
# Publish marker
# Publish marker
...
@@ -139,12 +153,12 @@ class BottleMapping(Node):
...
@@ -139,12 +153,12 @@ class BottleMapping(Node):
"""
"""
self
.
_marker_publisher
.
publish
(
marker
)
self
.
_marker_publisher
.
publish
(
marker
)
def
getRobotRotation
(
self
):
def
quaternionToYaw
(
self
,
q
):
# Convert
robot quaternion to roll
# Convert
quaternion to yaw
x
=
self
.
_robotPose
.
orientation
.
x
x
=
q
.
x
y
=
self
.
_robotPose
.
orientation
.
y
y
=
q
.
y
z
=
self
.
_robotPose
.
orientation
.
z
z
=
q
.
z
w
=
self
.
_robotPose
.
orientation
.
w
w
=
q
.
w
siny_cosp
=
2
*
(
w
*
z
+
x
*
y
)
siny_cosp
=
2
*
(
w
*
z
+
x
*
y
)
cosy_cosp
=
1
-
2
*
(
y
*
y
+
z
*
z
)
cosy_cosp
=
1
-
2
*
(
y
*
y
+
z
*
z
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment