mirror of
https://github.com/bjoernellens1/cps_loki.git
synced 2024-11-22 23:33:50 +00:00
update
This commit is contained in:
parent
3333da4737
commit
f5185df422
48
README.md
48
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!
|
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:
|
## Useful commands:
|
||||||
```
|
```
|
||||||
rosdep install --from-paths src --ignore-src -r -y
|
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
|
|
47
build.py
47
build.py
@ -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()
|
|
@ -1,3 +0,0 @@
|
|||||||
import subprocess
|
|
||||||
|
|
||||||
subprocess.check_output(['rm', '-rf', 'src', 'log', 'build', 'install'])
|
|
@ -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()
|
|
||||||
|
|
10
repos.yaml
10
repos.yaml
@ -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
|
|
@ -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()
|
|
@ -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()
|
|
@ -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()
|
|
Loading…
Reference in New Issue
Block a user