⚠️ Attention
Before making any changes in the project, make sure to be on the page ie to have the last version of the project : git pull.
Check the last section to learn how to do it !
- First part : Useful commands
- Second part : Github guide
- All the ROS2 packages are located in the commande folder
- In each ROS2 packages is located a README file to explain how to start the nodes inside the package
- The used sdf file, diff_drive.sdf, is located in the world folder
- The used launch file, MCAR.launch.py, is located in the launch folder
Here find a detail of the ROS2 packages in the project :
- centered_cmd : makes two turtles following a middle point between them contained in a trajectory
- Follow.py : makes a turtle following a leader turtle by using PID controllers in turtleSim
- Follow_etat.py : makes two turtles following each other by using a state equation (gains to adjust) in turtleSim
- node_cmdTurtle1.py : bases for creating a subcriber, a publisher and how to use them for moving turtles in turtleSim
- node_follow_trajectory.py : generation of a random trajectory which is followed by a turtle
- utils : regroup all the handmade functions needed in the package
- README : explain how to start the nodes of the package
- centered_cmd : makes two robots following a middle point between them contained in a trajectory
- robotFollower.py : makes a robot following a leader robot in Gazebo by using PID controllers
- leaderPath.py : makes the leader robot following a pre-defided trajectory
- utils : regroup all the handmade functions needed in the package
- README : explain how to start the nodes of the package
If it is necessary, build the project and source the environment :
cd ~/ROS2_Project
colcon build
source install/setup.bashThen, enter the following command to start gazebo with the correct sdf file :
ros2 launch launch/MCAR.launch.py Now that Gazebo started using the right .sdf file, you just have to start the desired nodes.
First go to the correct folder :
Here we go to the command folder inside the main folder because it is where we put all our ROS packages
cd ~/ROS2_Project/commande/Rebuild if it is necessary :
colcon buildSource the terminal :
source install/setup.bashFinally, enter and adapt the following command :
ros2 run packagename packagenodeHere find an example for starting the node for the leader car in the case of the shadowing part :
cd ~/ROS2_Project/commande/
colcon build
source install/setup.bash
ros2 run robotFollower robotLeadersource ~/ROS2_Project/install/setup.bashign sdf -k diff_drive.sdfTo check if you have git, check the version with the following command :
git --versionIf no message is written, then you need to install git.
For that, start by the following command :
sudo apt update Then :
sudo apt install git You can check if git is well installed by checking the version like we did in a first time.
Here, we use the HTTPS link.
Find here the link of the project :
https://github.com/romaindgc/ROS2_Project.gitNext, thanks to your terminal, go where you want to put the folder.
For example, it can be at your root, use the next command to go there :
cdThen, use the following command for cloning the repository in your machine :
git clone https://github.com/romaindgc/ROS2_Project.gitIf you have already created a token, you can directly go to the next step.
Hence, go to this website for creating a new github token (classic) :
If you’ve never configured Git on your machine, start by setting your name and email (which will be attached to your commits). Use these commands in the terminal :
git config --global user.name "Your Name"git config --global user.email "youremail@example.com"Before pushing your changes, check which files have been modified using :
git statusYou can also use this command to see the progression in the pushing process.
You need to add the modified or created files to the staging area before commiting :
- To add all changed files :
git add .- To add specific files :
git add *path/namefile*Once files are added to the staging area, create a commit to save the changes with a descriptive message:
git commit -m "Description of your changes"Finally, push the changes to the remote repository on GitHub using :
git push origin masterIn our case, master refers to the main branch of the repository. If you are working in another branc, replace master with the appropriate branch name.
Fist, navigate to the local repository.
If you put it at your root, it should be located there :
cd ~/ROS2_ProjectUse the following command to pull the latest changes from the remote repository to your local repository :
git pull origin masterIn our case, master is the default name for the remote repository.
If there are changes both in your local repository and on GitHub, there might be merge conflicts. Git will notify you if there are any, and you will need to manually resolve them before completing the pull.
Once you’ve resolved any conflicts, stage the changes, commit them, and finish the pull.