diff --git a/README.md b/README.md index bdef3d4..6d5367d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # cps_bot_mini_ws -temporary ws for developming ros2 control on robot mini with odrive +temporary ws for developing ros2 control on robot mini with odrive -nedded repos are: +needed repos are: - https://github.com/bjoernellens1/odrive_ros2_control on branch humble-fw-v0.5.1 - https://github.com/bjoernellens1/rmp220_teleop on branch bot_mini - https://github.com/bjoernellens1/ros2_cam_openCV @@ -9,4 +9,12 @@ nedded repos are: For initialization, just call "python3 initialize.py" -TODO: extend bot_mini_bringup +TODO: extend bot_mini_bringup, python scripts for simplyfiyng startup process. + +## Useful commands: + +### Localization using predefined map and navigation +don't forget to set transient_local in rviz to see the map +ros2 launch bot_mini_bringup nav2.launch.py map_subscribe_transient_local:=true +ros2 launch nav2_bringup localization_launch.py map:=/home/bjorn/Documents/ros_projects/cps_bot_mini_ws/src/bot_mini_bringup/maps/cps_save_map.yaml + diff --git a/office1_map_save.pgm b/office1_map_save.pgm new file mode 100644 index 0000000..e699d50 Binary files /dev/null and b/office1_map_save.pgm differ diff --git a/office1_map_save.yaml b/office1_map_save.yaml new file mode 100644 index 0000000..233f8b9 --- /dev/null +++ b/office1_map_save.yaml @@ -0,0 +1,7 @@ +image: office1_map_save.pgm +mode: trinary +resolution: 0.05 +origin: [1.87, -8.61, 0] +negate: 0 +occupied_thresh: 0.65 +free_thresh: 0.25 \ No newline at end of file diff --git a/office1_map_serial.data b/office1_map_serial.data new file mode 100644 index 0000000..c0a1b21 Binary files /dev/null and b/office1_map_serial.data differ diff --git a/office1_map_serial.posegraph b/office1_map_serial.posegraph new file mode 100644 index 0000000..9a5953c Binary files /dev/null and b/office1_map_serial.posegraph differ diff --git a/run_localization.py b/run_localization.py new file mode 100644 index 0000000..5c6b6d7 --- /dev/null +++ b/run_localization.py @@ -0,0 +1,63 @@ +import subprocess +import signal +import os +import time + +processes = [] +current_directory = os.getcwd() + +def source_setup_files(): + subprocess.Popen("source /opt/ros/humble/setup.bash", shell=True, executable="/bin/bash") + subprocess.Popen("source ./install/setup.bash", shell=True, executable="/bin/bash") + print("Setup files sourced") + +def start_process(command): + process = subprocess.Popen(command, shell=True, executable="/bin/bash", preexec_fn=os.setsid) + processes.append(process) + print(f"Started process with command: {command}") + +def stop_processes(): + for process in processes: + os.killpg(os.getpgid(process.pid), signal.SIGTERM) + print("Stopped all processes") + +def handle_interrupt(signal, frame): + print("Keyboard interrupt detected") + stop_processes() + exit(0) + +# Define the base command +base_command = "ros2 launch bot_mini_bringup" + +# Define the commands to launch +launch_commands = [ + "rsp.launch.py", + "robot_controller.launch.py", + "robot_joy_teleop.launch.py", + "robot_twist_mux.launch.py", + "robot_lidar.launch.py" +] + +# Add the base directory to the commands +commands = [os.path.join(base_command, command) for command in launch_commands] + +# Add the path to the map file +map_file = os.path.join(current_directory, "src", "bot_mini_bringup", "maps", "default_save_map.yaml") +map_command = f"ros2 launch nav2_bringup localization_launch.py map:={map_file}" +commands.append(map_command) + +# Register the signal handler +signal.signal(signal.SIGINT, handle_interrupt) + +# Source the setup files +source_setup_files() + +# Start the processes +for command in commands: + start_process(command) + +# Wait for user input to stop the processes +input("Press Enter to stop all processes...") + +# Stop all processes +stop_processes() diff --git a/run_mapping.py b/run_mapping.py index 9208ef8..f882dca 100644 --- a/run_mapping.py +++ b/run_mapping.py @@ -27,11 +27,12 @@ def handle_interrupt(signal, frame): # Add your commands here commands = [ - "ros2 launch bot_mini_bringup rsp.launch.py", - "ros2 launch bot_mini_bringup controller.launch.py", - "ros2 launch bot_mini_bringup joy_teleop.launch.py", - "ros2 launch bot_mini_bringup lidar.launch.py", - "ros2 launch bot_mini_bringup mapper.launch.py" + #"ros2 launch bot_mini_bringup rsp.launch.py", + "ros2 launch bot_mini_bringup robot_controller.launch.py", + "ros2 launch bot_mini_bringup robot_joy_teleop.launch.py", + "ros2 launch bot_mini_bringup robot_twist_mux.launch.py", + "ros2 launch bot_mini_bringup robot_lidar.launch.py", + "ros2 launch bot_mini_bringup robot_mapper.launch.py" ] # Register the signal handler