The goals for this lab are to:
By the end of this Lab you will need to:
This time, when you execute the ros2_jmu_setup.sh script you should go through the process of logging into GitHub. Otherwise you won’t be able to clone or push your repository.
First, cd into ~/dev_ws/src
.
cd ~/dev_ws/src/
Now create the package:
ros2 pkg create --build-type ament_python --node-name wander_node wander
This will populate the wander
folder with a properly-formatted
ROS2 Python package.
If you look inside your wander
folder, you should now see the following
initial layout:
wander/ <-- Folder name matches package name
package.xml <-- ROS2 package information
setup.cfg <-- Python package installation config file
setup.py <-- Python package installation script
resource/ <-- Honestly... I'm not sure
wander
test/
test_flake8.py <-- Tests for Python PEP8 formatting
test_pep257.py <-- Tests for docstrings
test_copyright.py <-- Test that a copyright is provided
wander/ <-- Python package source
__init__.py <-- Turns the folder into a Python package
wander_node.py <-- Python executable
Build your newly created package by changing into your workspace directory and typing:
colcon build --symlink-install
Once this command completes, there should be build
, install
and log
directories alongside the existing src
directory.
Type the following command into the terminal:
source install/setup.bash
This command configures your environment so that the ROS 2 system is aware of your newly created package.
You should now be able to interact with your package using ROS 2 command line tools:
ros2 run wander wander_node
$ Hi from wander.
Congratulations! You now have a fully-functional, properly built, ROS 2 package.
Copy the URL for the assignment invitation from the course Piazza page. Paste the URL into your browser window and follow the link.
Click on the link to access the GitHub page for your repository.
Follow the instructions to select a team name for this
assignment. Your team name should have the format
wander_name1_name2
where name1
and name2
are the last names
of the team members. You should see a page with some text like the
following:
Your team’s assignment repository has been created:
https://github.com/JMU-CS354-F22/wander-wander_name1_name2
Complete the following steps in order to add your package to a new
git repository. Don’t just copy and paste the instructions below!
Make sure you understand the meaning of each step. (GIT_URL
should be replaced with the URL for your GitHub project. It
should look something like:
https://github.com/JMU-CS354-F23/wander-wander_name1_name2
)
cd ~/dev_ws/src/wander
git init
echo "# Packaging Lab" >> README.md
git add *
git commit -m "first commit"
git branch -M main
git remote add origin GIT_URL
git push -u origin main
Reload your repository in GitHub to confirm that your package has been pushed correctly.
Congratulations! You have a git repository on GitHub.
At this point you should log out and log back in and SOMEONE ELSE from your group should clone the repository and make the changes described below. Full credit for the lab will require commits from multiple group members.
Note that if you clone the package like this:
git clone GIT_URL
The folder will have the same name as the GitHub repository.
If you clone it like this:
git clone GIT_URL wander
Then the folder name will match the package name, which will be less
confusing. Once the repository is cloned into ~/dev_ws/src
complete
the steps below.
Copy the contents of your wander.py
solution from the previous
lab into wander_node.py
. Rebuild your package and test that you
can use ros2 node run
to execute your new node:
ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py
In a separate terminal:
ros2 run wander wander_node
Copy your forward.py
solution form the last lab into a file
named forward_node.py
. Update setup.py
so that it recognizes
forward_node
as an entry point, rebuild, and test the result:
ros2 run wander forward_node
You can check style issues by running flake8
in the folder
containing your Python code. For example:
python -m flake8 --max-line-length 100
Fix as many style errors as possible.
Once you are satisfied with your package, commit your work, and push it back to GitHub by completing the following steps:
Change into your package folder and type:
git add *
to add all of your newly created files to the repository.
Commit your changes by typing:
git commit -m 'Added wander code. Fixed style issues.'
Every time you commit your code you MUST provide a reasonably informative commit message.
Push your changes
git push
Your changes are not safe until you complete this step! Once you have completed the previous step, test that everything is OK by accessing your repository through the GitHub web interface. You should be able to see the files you’ve pushed.
There is nothing to submit for this lab. I’ll check your work through GitHub.
Modify your wander_node.py
solution (or mine) so that the wandering
is random. Rather than turning until the obstacle is out of range,
turn by some randomly determined angle. Push your changes to the
GitHub repository.
You may also want to improve the avoidance logic so that the obstacle detection takes into account the width of the robot.