Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Robomaster_pi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Emil Harlan
Robomaster_pi
Commits
aaa5d3c9
Commit
aaa5d3c9
authored
1 year ago
by
Emil Harlan
Browse files
Options
Downloads
Patches
Plain Diff
a
parent
97357134
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
robomaster_pi/map_update.py
+45
-0
45 additions, 0 deletions
robomaster_pi/map_update.py
setup.py
+1
-0
1 addition, 0 deletions
setup.py
with
46 additions
and
0 deletions
robomaster_pi/map_update.py
0 → 100644
+
45
−
0
View file @
aaa5d3c9
import
rclpy
from
rclpy.node
import
Node
from
std_msgs.msg
import
String
import
yaml
class
MapFileUpdater
(
Node
):
def
__init__
(
self
):
super
().
__init__
(
'
map_file_updater
'
)
self
.
subscription
=
self
.
create_subscription
(
String
,
'
/current_map
'
,
self
.
map_file_callback
,
10
)
self
.
subscription
def
map_file_callback
(
self
,
msg
):
# Pfad zur YAML-Datei
file_path
=
'
/home/pi/robot_ws/src/robot_loc/config/localisation_params.yaml
'
# Neuen Wert für map_file_name aus der empfangenen Nachricht erhalten
new_value
=
msg
.
data
# YAML-Datei lesen
with
open
(
file_path
,
'
r
'
)
as
file
:
yaml_data
=
yaml
.
safe_load
(
file
)
# Wert von map_file_name ändern
yaml_data
[
'
slam_toolbox
'
][
'
ros__parameters
'
][
'
map_file_name
'
]
=
new_value
# YAML-Datei mit dem neuen Wert aktualisieren
with
open
(
file_path
,
'
w
'
)
as
file
:
yaml
.
safe_dump
(
yaml_data
,
file
)
self
.
get_logger
().
info
(
'
Der Wert von map_file_name wurde erfolgreich aktualisiert.
'
)
def
main
(
args
=
None
):
rclpy
.
init
(
args
=
args
)
map_file_updater
=
MapFileUpdater
()
rclpy
.
spin
(
map_file_updater
)
map_file_updater
.
destroy_node
()
rclpy
.
shutdown
()
if
__name__
==
'
__main__
'
:
main
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
0
View file @
aaa5d3c9
...
...
@@ -20,6 +20,7 @@ setup(
tests_require
=
[
'
pytest
'
],
entry_points
=
{
'
console_scripts
'
:
[
"
map_update = robomaster_pi.map_update:main
"
,
"
command_executer = robomaster_pi.command_executer:main
"
,
"
IMU = robomaster_pi.IMU:main
"
,
"
Odom = robomaster_pi.Odom:main
"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment