From f5185df422f7c0221338b663dbfde501a5561816 Mon Sep 17 00:00:00 2001 From: bjoernellens1 <64093272+bjoernellens1@users.noreply.github.com> Date: Mon, 20 Nov 2023 10:24:55 +0100 Subject: [PATCH] update --- README.md | 48 +---------------------- build.py | 47 ----------------------- cleanup.py | 3 -- initialize.py | 85 ----------------------------------------- repos.yaml | 10 ----- run_localization.py | 71 ---------------------------------- run_localization.py.bak | 64 ------------------------------- run_mapping.py | 61 ----------------------------- 8 files changed, 1 insertion(+), 388 deletions(-) delete mode 100644 build.py delete mode 100644 cleanup.py delete mode 100644 initialize.py delete mode 100644 repos.yaml delete mode 100644 run_localization.py delete mode 100644 run_localization.py.bak delete mode 100644 run_mapping.py diff --git a/README.md b/README.md index 312f631..ec859db 100644 --- a/README.md +++ b/README.md @@ -36,53 +36,7 @@ I would advise to fork the repository and start working in your own one. ``` This will allow you to modify the images to your needs. Enjoy! - -## Old-fashioned way: - -temporary ws for developing ros2 control on robot mini with odrive - -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 -- https://github.com/bjoernellens1/bot_mini_bringup.git - -For initialization, just call "python3 initialize.py" - -TODO: extend bot_mini_bringup, python scripts for simplyfiyng startup process. - ## Useful commands: ``` rosdep install --from-paths src --ignore-src -r -y -``` - - -### 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 - - -### Real-Time priority -Process real-time settings - -These are the options that allows to configure the process real-time settings: - - priority: changes the process priority and set a real-time FIFO priority. This will set the priority of the thread where the ROS 2 executor is running. - cpu-affinity: binds the application to a specific CPU core by setting a CPU mask. For example, to bind the process or thread to CPU 3 (or 2 starting from 0) we set the CPU mask to 4 (100 in binary). - lock-memory: pre-faults memory until no more page faults are seen. This usually allocated a high amount of memory so make sure there is enough memory in the system. - lock-memory-size: specifies the amount of memory we want to pre-allocate. For example lock-memory-size 100 pre-allocates 100 MB. - config-child-threads: specifies if the RMW middleware child threads will inherit the main process settings. This applies for priority and cpu-affinity options.. For example, if config-child-threads False is set, only the main thread where the ROS executor is set with the priority and cpu-affinity options. If, config-child-threads True is set, the DDS threads will also inherit the same priority and CPU affinity configuration than the main thread. - -Example using ros2 launch: - -``` -ros2 launch pendulum_bringup pendulum_bringup.launch.py priority:=80 cpu-affinity:=4 lock-memory-size:=100 config-child-threads:=True -``` - -Example using the executable command line arguments: - -``` -ros2 run pendulum_demo pendulum_demo --priority 80 --cpu-affinity:=4 --lock-memory-size 100 --config-child-threads True -``` -Source: https://github.com/ros2-realtime-demo/pendulum/blob/rolling/docs/real_time_tutorial.md +``` \ No newline at end of file diff --git a/build.py b/build.py deleted file mode 100644 index 6ca3cfb..0000000 --- a/build.py +++ /dev/null @@ -1,47 +0,0 @@ -import subprocess -import signal -import os -import time - -processes = [] - -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) - -# Add your commands here -commands = [ - "colcon build" -] - -# Register the signal handler -signal.signal(signal.SIGINT, handle_interrupt) - -# Source the setup files -source_setup_files() - -# Start the remaining 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/cleanup.py b/cleanup.py deleted file mode 100644 index fa38be6..0000000 --- a/cleanup.py +++ /dev/null @@ -1,3 +0,0 @@ -import subprocess - -subprocess.check_output(['rm', '-rf', 'src', 'log', 'build', 'install']) \ No newline at end of file diff --git a/initialize.py b/initialize.py deleted file mode 100644 index a175f27..0000000 --- a/initialize.py +++ /dev/null @@ -1,85 +0,0 @@ -import os -import subprocess -import yaml - -class GitCloner: - def __init__(self, directory, repos_file): - self.directory = directory - self.maindir = os.path.dirname(os.path.abspath(__file__)) # should be equal to the current directory where the script is called from - self.repos_file = repos_file - - def clone_or_update_repos(self): - # Load repository URLs from YAML file - with open(self.repos_file, 'r') as file: - repos_data = yaml.safe_load(file) - - # Clone or update repositories - for repo_data in repos_data['repositories']: - repo_url = repo_data['url'] - branch = repo_data.get('branch', 'main') - self.clone_or_update_repo(repo_url, branch) - - def clone_or_update_repo(self, repo_url, branch='main'): - repo_name = repo_url.split('/')[-1].split('.')[0] - repo_path = os.path.join(self.directory, repo_name) - - if os.path.exists(repo_path): - print(f"Repository '{repo_name}' already exists. Updating...") - try: - # Change working directory to the repository path - os.chdir(repo_path) - - # Pull the latest changes from the repository - subprocess.check_output(['git', 'pull']) - - #Go back one level - os.chdir(os.path.join(self.maindir, 'src')) - - print(f"Successfully updated repository '{repo_name}'.") - except subprocess.CalledProcessError as e: - print(f"Failed to update repository '{repo_name}': {e}") - return - else: - try: - # Clone the repository - subprocess.check_output(['git', 'clone', '--branch', branch, repo_url, repo_path]) - - print(f"Successfully cloned repository '{repo_name}' on branch '{branch}'.") - except subprocess.CalledProcessError as e: - print(f"Failed to clone repository '{repo_name}' on branch '{branch}': {e}") - return - - def build_repos(self): - try: - # Change working directory to the base directory - main_dir = os.path.join(self.maindir) - os.chdir(main_dir) - - # Execute colcon build - subprocess.check_output(['colcon', 'build']) - - print("Build completed successfully.") - except subprocess.CalledProcessError as e: - print(f"Failed to build repositories: {e}") - - def source_setup(self): - try: - # Change working directory to the base directory - main_dir = os.path.join(self.maindir) - os.chdir(main_dir) - - # Execute "source install/setup.bash" from the parent directory - #subprocess.check_call(['source', os.path.join('install', 'setup.bash')], shell=True) - subprocess.check_output(['source', 'install/setup.bash']) - - print("Setup file sourced successfully.") - except subprocess.CalledProcessError as e: - print(f"Failed to source setup file: {e}") - - -# Usage example -cloner = GitCloner('./src', 'repos.yaml') -cloner.clone_or_update_repos() -#cloner.build_repos() -#cloner.source_setup() - diff --git a/repos.yaml b/repos.yaml deleted file mode 100644 index 0fe4e39..0000000 --- a/repos.yaml +++ /dev/null @@ -1,10 +0,0 @@ -repositories: - - url: https://github.com/bjoernellens1/odrive_ros2_control - branch: humble-fw-v0.5.1 - - url: https://github.com/bjoernellens1/rmp220_teleop - branch: bot_mini - - url: https://github.com/bjoernellens1/ros2_cam_openCV - - url: https://github.com/bjoernellens1/bot_mini_bringup - - url: https://github.com/bjoernellens1/Lslidar_ROS2_driver - branch: N10_V1.0 - - url: https://github.com/bjoernellens1/bot_mini_description diff --git a/run_localization.py b/run_localization.py deleted file mode 100644 index 0dc9117..0000000 --- a/run_localization.py +++ /dev/null @@ -1,71 +0,0 @@ -import subprocess -import signal -import os -import time -import threading - -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" -] - -# Create the commands by joining the base command with each launch command -commands = [f"{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() - -# Create and start threads for each command -threads = [] -for command in commands: - thread = threading.Thread(target=start_process, args=(command,)) - thread.start() - threads.append(thread) - -# Wait for user input to stop the processes -input("Press Enter to stop all processes...") - -# Stop all processes -stop_processes() - -# Wait for all threads to complete -for thread in threads: - thread.join() diff --git a/run_localization.py.bak b/run_localization.py.bak deleted file mode 100644 index 9449a83..0000000 --- a/run_localization.py.bak +++ /dev/null @@ -1,64 +0,0 @@ -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", - #"robot_cam.launch.py" -] - -# Create the commands by joining the base command with each launch command -commands = [f"{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_map_save.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 deleted file mode 100644 index f882dca..0000000 --- a/run_mapping.py +++ /dev/null @@ -1,61 +0,0 @@ -import subprocess -import signal -import os -import time - -processes = [] - -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) - -# Add your commands here -commands = [ - #"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 -signal.signal(signal.SIGINT, handle_interrupt) - -# Source the setup files -source_setup_files() - -# Start rsp.launch.py -start_process(commands[0]) - -# Start controller -start_process(commands[1]) -# Wait for 20 seconds because the ros2 control needs some time to initialize. -print("Waiting for 20 seconds...") -time.sleep(20) - -# Start the remaining processes -for command in commands[1:]: - start_process(command) - -# Wait for user input to stop the processes -input("Press Enter to stop all processes...") - -# Stop all processes -stop_processes()