Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
8127a41
updated readme
Jun 18, 2024
04a134b
added traffic_lights.launch
Jun 18, 2024
87dc5ed
position changes
Jun 18, 2024
d7c4bae
added gif to README.md
Jun 18, 2024
90aee4a
basic mistake fixed
Jun 18, 2024
c232d68
basic mistake fixed
Jun 18, 2024
7e1360e
Merge branch 'main' of https://github.com/KOU-Mekatronom/Simulator in…
Jun 18, 2024
4a1362d
updated readme
Jun 18, 2024
72d17cc
Initial commit
Renbago Jun 20, 2024
4a0fae8
KOU-Mekatronom
Jul 1, 2024
8fe6905
readme update
Jul 1, 2024
f745a2b
updating helper functions
Jul 22, 2024
ea1ccbe
Update helper functions
Jul 28, 2024
dba2bc2
Refactor MpcNode.hpp to improve code organization and readability
Jul 28, 2024
11ed2ed
stable version for djikstra calculation
Jul 30, 2024
b276950
chore: Add new message and service files for keypoint and bounding bo…
Aug 9, 2024
8389003
removed zed-files and added casadi
Renbago Aug 16, 2024
e00829a
chore: Remove debug print statements and optimize bounds assignment i…
Renbago Aug 16, 2024
48c8e40
removed casadi it will clone on home
Renbago Aug 17, 2024
97dc73d
few changes for docker setup
Renbago Aug 17, 2024
c53631f
Update README.md
Renbago Aug 17, 2024
04f107a
Update README.md
Renbago Aug 17, 2024
6656632
Update README.md
Renbago Aug 17, 2024
bc90d2a
Update README.md
Renbago Aug 17, 2024
a8c2012
Update README.md
Renbago Aug 17, 2024
42a6700
Update README.md
Renbago Aug 17, 2024
8bc7547
Update README.md
Renbago Aug 17, 2024
0360974
Update README.md
Renbago Aug 17, 2024
11465cd
Merge pull request #1 from Renbago/devel
Renbago Aug 17, 2024
27dfecc
rewrited for docker file
Renbago Aug 17, 2024
cad32aa
Merge branch 'devel' of https://github.com/Renbago/autonomus_vehicle …
Renbago Aug 17, 2024
ff0b632
chore: Make C++ and Python files executable in Dockerfile
Renbago Aug 18, 2024
def1bda
added control outputs for debugging
Renbago Aug 20, 2024
7cf638d
added behaviour_state_ and created car control states
Renbago Aug 20, 2024
75a7db8
the cars predicted new positions has been added
Renbago Aug 20, 2024
bc1a0a5
chore: Added finding the next waypoint which is closest to your posit…
Renbago Aug 20, 2024
bf70d86
chore: Refactor MpcNode.hpp to include additional control outputs and…
Renbago Aug 20, 2024
6ffd9a2
chore: Added solution for the positional calculations X0 and the cont…
Renbago Aug 20, 2024
91d256f
added few debug parameters
Renbago Aug 20, 2024
b6f542d
chore:
Renbago Aug 21, 2024
b44ca8d
chore: Update djikstra_outputs struct and path calculations
Renbago Aug 21, 2024
29a5f9a
chore: Refactor MpcNode.cpp to use updated djikstra_outputs struct
Renbago Aug 21, 2024
6f2a181
Refactor MPC class to improve code readability and remove debug print…
Renbago Aug 21, 2024
b474858
chore: replaced some static definitions to initial_settings_ this wi…
Renbago Aug 22, 2024
d2b04eb
Refactor djikstra.h to use djikstra_outputs struct for storing obstac…
Renbago Aug 22, 2024
14dbec8
added some functions for calculating the x step ahead in path for is …
Renbago Aug 22, 2024
0738621
chore: replaced some values , added counter and traffic_sign_manager
Renbago Aug 30, 2024
6cb5819
chaned obs_dontuse_ with excluded_nodes
Renbago Aug 30, 2024
430bd2b
added new functions about obstacle_detection part. Those are include:
Renbago Aug 30, 2024
85b8013
With YOLO data we will change the car_behaviour_state_ ,
Renbago Aug 30, 2024
ba1dc0e
Merge pull request #2 from Renbago/devel
Renbago Aug 30, 2024
03fe619
chore: Refactor MpcNode.hpp to use Timers struct for last update time
Renbago Aug 31, 2024
95e9316
Refactor djikstra.h to use djikstra_outputs struct for obstacle node …
Renbago Aug 31, 2024
e9fc056
Refactor code to update and process nearest waypoint in MPC running
Renbago Aug 31, 2024
d442c21
Refactor MpcNode.hpp to fix include typo and add watchdog timer and w…
Renbago Sep 2, 2024
a17836c
just added node_dict at dirty way
Renbago Sep 2, 2024
e99abb8
added updatenexttarget node and few changes.
Renbago Sep 2, 2024
ae90399
some of the cleanings later add will as debug parameters.
Renbago Sep 2, 2024
a51d107
For now other sections of parking motorway endofmotorway settings wi…
Renbago Sep 2, 2024
16af30e
obstacle_detecorworking
Renbago Sep 2, 2024
90bf821
Update README.md
Renbago Sep 2, 2024
8500bae
a few parameters change:
Renbago Sep 4, 2024
273ffee
renamed some values and cleaned,
Renbago Sep 4, 2024
a391b15
renamed Djikstra class with processAndPublishPath
Renbago Sep 4, 2024
5e3e2af
few changes and cleaning for launch folder and map.
Renbago Sep 4, 2024
674b35b
Update README.md
Renbago Sep 8, 2024
fe0891c
Update README.md
Renbago Sep 8, 2024
30c03e4
Update README.md
Renbago Sep 8, 2024
5cb873d
Update README.md
Renbago Sep 8, 2024
2706681
Update README.md
Renbago Sep 8, 2024
814cd01
Update README.md
Renbago Sep 8, 2024
d5dc3e6
parametre rename
Renbago Sep 9, 2024
3ade21d
Merge branch 'devel' of https://github.com/Renbago/autonomus_vehicle …
Renbago Sep 9, 2024
3ec30f9
fixed error
Renbago Oct 20, 2024
1569f18
Merge pull request #3 from Renbago/devel
Renbago Oct 23, 2024
0f8d205
thesis added
Renbago Nov 8, 2024
5250f2e
Merge pull request #4 from Renbago/main
Renbago Nov 8, 2024
ed54ee8
Merge remote-tracking branch 'Renbago/devel'
Renbago Nov 15, 2024
334851f
Merge remote-tracking branch 'Renbago/docker' into docker_version
Renbago Nov 15, 2024
cf76588
Merge remote-tracking branch 'Renbago/devel'
Renbago Nov 15, 2024
6f63818
docker_version update
Renbago Nov 15, 2024
ab80c62
fixed some bugs, added png to rviz, updated readme
Renbago Nov 16, 2024
86ba9a4
docker_version update
Renbago Nov 16, 2024
a46c5b0
Merge remote-tracking branch 'Renbago/devel' into merged_version
Renbago Nov 16, 2024
a097deb
Merge remote-tracking branch 'Renbago/merged_version' into KOU-Mekatr…
Renbago Nov 16, 2024
22e9124
Merge branch 'main' into merged_version
Renbago Nov 16, 2024
b3f556f
Merge pull request #1 from Renbago/merged_version
Renbago Nov 16, 2024
d1343e9
Merge remote-tracking branch 'Renbago/docker_version' into docker
Renbago Nov 16, 2024
be9a049
deleted folder
Renbago Nov 16, 2024
8670f01
Update README.md
Renbago Nov 16, 2024
aa69cb6
added missed lib
Renbago Nov 16, 2024
ede960a
added map-server
Renbago Nov 30, 2024
5bce6c7
Merge branch 'docker' into docker_version
Renbago Nov 30, 2024
d46511e
Merge pull request #4 from Renbago/docker_version
Renbago Nov 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Empty file modified .gitignore
100644 → 100755
Empty file.
10 changes: 4 additions & 6 deletions .vscode/settings.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,11 @@
"xloctime": "cpp"
},
"python.autoComplete.extraPaths": [
"/home/mekatronom/Simulator/devel/lib/python3/dist-packages",
"/home/mekatronom/boschmekatronom_ws/BoschMekatronom/devel/lib/python3/dist-packages",
"/opt/ros/noetic/lib/python3/dist-packages"
"/opt/ros/humble/lib/python3.10/site-packages",
"/opt/ros/humble/local/lib/python3.10/dist-packages"
],
"python.analysis.extraPaths": [
"/home/mekatronom/Simulator/devel/lib/python3/dist-packages",
"/home/mekatronom/boschmekatronom_ws/BoschMekatronom/devel/lib/python3/dist-packages",
"/opt/ros/noetic/lib/python3/dist-packages"
"/opt/ros/humble/lib/python3.10/site-packages",
"/opt/ros/humble/local/lib/python3.10/dist-packages"
]
}
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified Picture1.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
129 changes: 125 additions & 4 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,122 @@
**You can easily run this project buy using docker branch instead of creating locally.**

# From leader of KOU-Mekatronom
Hi,

Attached are the codes I developed for the KOU-Mekatronom team, which I was a part of from 2021 to 2024, and where I served as the team captain since 2022. Last year, we were accepted into the BOSCH Future Mobility Challenge competition, held in Romania. Our team was the only one from Turkey to reach the finals (top 24) among 160 international teams.

This project includes everything I have developed since May 2023. While working on this project, I was also employed at [Saha Robotic](https://www.linkedin.com/company/saha-robotik/mycompany/), so I could only develop it during the evenings after work and on weekends. Because of this, I am aware that some parts of the project are hard-coded for specific competition scenarios and are not fully complete. However, I believe I did everything I could within the time I had, and I have no regrets.

Currently, the project is written in Python, but I have started porting it to C++ with cleaner code. Soon, I will stop contributing to this project without further updates. The reason is that I have graduated and would like to move on to new challenges, passing this project on to new team members.

This project works in both real-world applications and simulation. In the real system, we used ZED 2i, an encoder, and an IMU for localization, and we plan to add UWB for global reference. Additionally, instead of LiDAR, we used point cloud data from the ZED for obstacle detection, but all other codes remain the same.

**Thanks for reading**

# Project explanation

The autonomous driving and connectivity algorithms on 1/10 scale vehicles, provided by the company, to navigate in a designated environment simulating a miniature smart city. This project designed for the competation named as BOSCH FUTURE MOBILITY CHALLANGE.

# How the algorithms are work ?

We have [node graph list](https://github.com/Renbago/autonomus_vehicle/blob/main/src/example/config/fixed2.graphml) (also you can create your node base graph system)
we are selecting the [start and targetnode](https://github.com/Renbago/autonomus_vehicle/blob/ba1dc0e1d733606ee26514bc1f55c89231d02a76/src/example/include/mekatronom/MpcNode.hpp#L94-L95) (It will define from launch file later currently we are changing in python code and header file as i mentioned that.) and [djikstra](https://github.com/Renbago/autonomus_vehicle/blob/main/src/example/include/mekatronom/utilities/djikstra.h) is solving the closest path. You can add [excluded nodes](https://github.com/Renbago/autonomus_vehicle/blob/ba1dc0e1d733606ee26514bc1f55c89231d02a76/src/example/include/mekatronom/MpcNode.hpp#L97C1-L97C55). If there is a [obstacle](https://github.com/Renbago/autonomus_vehicle/tree/main/src/obstacle_detector) we are detecting this center_x, center_y and velocity then giving this input to [mpc_running](https://github.com/Renbago/autonomus_vehicle/blob/ba1dc0e1d733606ee26514bc1f55c89231d02a76/src/example/include/mekatronom/utilities/mpc_running.h#L181) if the obstacles position matches with the node graph system we are detecting it as obstacle and calling djikstra again. If the node has pass_through, we are crossing the left lane but if its set **false** we are waiting the until [obstacle moved](https://github.com/Renbago/autonomus_vehicle/blob/5e3e2af504190099f591417b3469074eb4eb44af/src/example/include/mekatronom/utilities/traffic_sign_manager.h#L41C1-L41C59) if obstacles moved we are triggering djikstra again and the path will get update. Non linear mpc will be follow the next node_id.

There is a few behaviour states and will be updated coming data's from yolo and obstacles else the state will be ```keep_lane``` we have different parametrs for different states those parameters has been [tuned](https://github.com/Renbago/autonomus_vehicle/blob/ba1dc0e1d733606ee26514bc1f55c89231d02a76/src/example/include/mekatronom/utilities/mpc_start_setting.h#L54-L84) for real time system. And also there is a **behaviour_timer** section. This working same logic with **watchdog_timer** if something went wrong or some behaviours should be executed, by **behaviour_callback** we are able to execute those scenerios.

# Whats included ?
I also wanted to share The foundation of this code was inspired by and further developed upon the work in the following GitHub repositories:

This project using [Non-linear MPC with CasADi](https://github.com/MMehrez/MPC-and-MHE-implementation-in-MATLAB-using-Casadi/tree/master/workshop_github), [Dynamic/static obstacle detection](https://github.com/jk-ethz/obstacle_detector), [robot_localization](https://github.com/cra-ros-pkg/robot_localization), Rviz visualization, djikstra and [yolo](https://github.com/ultralytics/ultralytics).

The all of the implementation's which i mentioned are currently work on [mpc.py](https://github.com/Renbago/autonomus_vehicle/blob/devel/src/example/src/mpc.py),
but the all of the python codes has not been cleaned and a bit dirty code. But while preparing the competation I was not care of the clean writing. Mostly settings are inside of ```mpc.py``` you can just execute it.

**The cpp part is not fully finished. Currently we are supporting those futures;**
Dynamic Static obstacle detection, Non linear MPC with waypoint base system, robot_localization path regeneration by obstacles. Soon traffic_sign_scenerios will be wroted so selected nodes or the table data's from yolo we will be change the mpc parameters.

## The simulation and real life outputs from project

[![KOU-Mekatronom Youtube Channel](https://youtube.com/playlist?list=PLDE_vDxu0Gkk-s3ndTqIScKTHSvL8dt0m&si=bbp9Qc9xVI-1Tctj)](https://youtube.com/playlist?list=PLDE_vDxu0Gkk-s3ndTqIScKTHSvL8dt0m&si=bbp9Qc9xVI-1Tctj)

## Prerequisites

Before you begin, ensure you have met the following requirements:

- **Docker**: You need to have Docker installed on your system. Follow the official [Docker installation guide for Ubuntu](https://docs.docker.com/engine/install/ubuntu/).
- **Visual Studio Code**: Install Visual Studio Code, if you haven't already.
- **Docker Extension for Visual Studio Code**: Install the Docker extension from the Visual Studio Code marketplace.

# Getting Started

Follow these steps to get your project up and running in a Docker environment.

### 1. Clone the Repository
```git clone -b docker https://github.com/Renbago/autonomus_vehicle.git```

### 2. Build Docker Images

1.You can use this command if you suspect that a cached layer is causing issues (e.g., dependencies not updating properly), or if you made changes that Docker’s layer cache might not recognize (such as updates to apt-get or similar commands inside the Dockerfile);

```docker-compose build --no-cache```

2.If you've just made changes to your application code or Dockerfile and want to rebuild the image and start the containers is sufficient and faster;

```docker-compose up -d --build```

### 3. Start Docker Containers:
```docker-compose up```,

if you want access from terminal run this command ```docker exec -it autonomous_ws /bin/bash```

### 4. Attach Visual Studio Code to Docker Container

1.Open Visual Studio Code.

2.Open the Docker extension panel (usually on the left sidebar).

3.Find the running container for your project.

4.Right-click on the container and select **Attach Visual Studio Code**.

This will open a new instance of Visual Studio Code that is connected to the file system within the Docker container, allowing you to develop and debug your application directly inside the container.

# For running the project:
at one terminal:
```roslaunch sim_pkg map_with_car.launch```

the second terminal:
```rosrun example mpc_node```

or

```rosrun example mpc.py```

# IMPORTANT
The ```mpc_node.cpp``` version has not been fully finished, you can run ```rosrun example mpc.py``` when launched ```map_with_car.launch``` also obstacle_detector will be executed.

#

# Outputs from Gazebo

<img src="https://github.com/ECC-BFMC/Simulator/blob/main/Picture1.png" width=30% height=30%>

From new parkour:
# From new parkour:

<img src="https://github.com/KOU-Mekatronom/Simulator/blob/main/parkour.png" width=30% height=30%>

From added RVIZ:

# From added RVIZ:

<img src="https://github.com/KOU-Mekatronom/Simulator/blob/main/rviz.png" width=30% height=30%>

# Obstacle detection

<img src="https://github.com/KOU-Mekatronom/Simulator/blob/main/obstacle_detection.png" width=30% height=30%>

# Traffic lights plugin:

<img src="https://github.com/KOU-Mekatronom/Simulator/blob/main/traffic_lights_pkg.gif" width=30% height =30%>

# BFMC Simulator Project

The project contains the entire Gazebo simulator.
Expand All @@ -25,10 +133,23 @@ From KOU-Mekatronom team:
- Added urdf and lidar.sdf
- It has laser_scan now topic name is ```/automobile/scan``` for bostacle_detection.
- Added TF2 package the tf tree visualization ```frames.pdf```
- Added traffic lights publisher, ```src/sim_pkg/launch/sublaunchers/traffic_lights.launch```
- In your main code you need to subscribe ``` automobile/trafficlight/master,slave,start topics```


Tips on how to install and work on it, can be found in the


## The documentation is available in details here:
[Documentation](https://bosch-future-mobility-challenge-documentation.readthedocs-hosted.com/data/simulator.html)

This project includes the algorithms has been made from KOU-Mekatronom::
- It has robot_localization package, you can fuse the gps and IMU data easily.
- Robot_localization package config path is ```src/example/config/ekf_localization.yaml```
- Added urdf and lidar.sdf
- It has laser_scan now topic name is ```/automobile/scan``` for bostacle_detection.
- Added TF2 package the tf tree visualization ```frames.pdf```
- Added traffic lights publisher, ```src/sim_pkg/launch/sublaunchers/traffic_lights.launch```
- In your main code you need to subscribe ``` automobile/trafficlight/master,slave,start topics```

# Contributors
[Mehmet Baha Dursun](https://github.com/Renbago)
Binary file added autonomus_vehicle.docx.pdf
Binary file not shown.
75 changes: 75 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
FROM osrf/ros:noetic-desktop-full

SHELL ["bash", "-c"]

ARG USERNAME=Renbago
RUN useradd -m -s /bin/bash $USERNAME && \
echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \
chown -R $USERNAME:$USERNAME /home/$USERNAME

USER root

RUN apt-get update && apt-get install -y \
curl \
gnupg2 \
lsb-release \
coinor-libipopt-dev \
gfortran \
python3-rosdep \
apt-transport-https \
ca-certificates \
sudo \
git \
python3-pip \
nlohmann-json3-dev \
ros-noetic-geometry-msgs \
ros-noetic-std-msgs \
ros-noetic-rospy \
ros-noetic-roscpp \
ros-noetic-map-server \
ros-noetic-sensor-msgs \
ros-noetic-message-generation \
ros-noetic-message-runtime \
ros-noetic-cv-bridge \
ros-noetic-image-transport \
ros-noetic-map-server \
libeigen3-dev \
ros-noetic-tf2-sensor-msgs \
libpugixml-dev \
bash-completion \
ros-noetic-geographic-msgs \
libgeographic-dev \
&& rm -rf /var/lib/apt/lists/*

# CasaDI installation
WORKDIR /home/$USERNAME
USER $USERNAME
RUN git clone --recurse-submodules https://github.com/casadi/casadi.git
WORKDIR /home/$USERNAME/casadi
RUN mkdir -p build && cd build && cmake -DWITH_IPOPT=true .. && make -j$(nproc)
USER root
RUN cd /home/$USERNAME/casadi/build && make install

#This casadi is for python version i did not include the local path for pyton codes.
RUN pip3 install casadi

# Setting up Catkin workspace
WORKDIR /home/$USERNAME
RUN mkdir -p autonomus_ws/src && chown -R $USERNAME:$USERNAME autonomus_ws
RUN cd autonomus_ws/src && git clone -b devel https://github.com/Renbago/autonomus_vehicle.git
WORKDIR /home/$USERNAME/autonomus_ws
RUN /bin/bash -c '. /opt/ros/noetic/setup.bash; catkin_make'

USER root
RUN apt-get update
# Here is setting the necessery gazebo and ros package and also chmod+x all of it.
USER $USERNAME
RUN echo "if [ -f /etc/bash_completion ]; then" >> ~/.bashrc && \
echo " . /etc/bash_completion" >> ~/.bashrc && \
echo "fi" >> ~/.bashrc && \
echo "source /opt/ros/noetic/setup.bash" >> /home/$USERNAME/.bashrc && \
echo 'export ROS_PACKAGE_PATH="/home/'$USERNAME'/autonomus_ws/src/autonomus_vehicle/src:$ROS_PACKAGE_PATH"' >> ~/.bashrc && \
echo 'export GAZEBO_MODEL_PATH="/home/'$USERNAME'/autonomus_ws/src/autonomus_vehicle/src/models_pkg:$GAZEBO_MODEL_PATH"' >> ~/.bashrc && \
echo 'source /home/'$USERNAME'/autonomus_ws/devel/setup.bash' >> ~/.bashrc && \
find /home/$USERNAME/autonomus_ws/src/autonomus_vehicle -type f -name "*.py" -exec chmod +x {} \; && \
find /home/$USERNAME/autonomus_ws/src/autonomus_vehicle -type f -name "*.cpp" -exec chmod +x {} \;
23 changes: 23 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: '3'
services:
autonomous_ws:
build: .
volumes:
- type: bind
source: /tmp/.X11-unix
target: /tmp/.X11-unix
- type: bind
source: /etc/timezone
target: /etc/timezone
- type: bind
source: /dev
target: /dev
device_cgroup_rules:
- 'c 81:* rmw'
- 'c 189:* rmw'
environment:
- DISPLAY=:1
- TZ=Turkey
container_name: autonomous_ws
command: /bin/bash
tty: true
17 changes: 0 additions & 17 deletions frames.gv

This file was deleted.

Binary file removed frames.pdf
Binary file not shown.
Binary file added obstacle_detection.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pngs/Picture1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
0 parkour.png → pngs/parkour.png
100644 → 100755
File renamed without changes
Binary file added pngs/rviz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pngs/traffic_lights_pkg.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed rviz.png
Binary file not shown.
18 changes: 0 additions & 18 deletions src/example/CMakeLists.txt

This file was deleted.

Loading