辅导案例-CSC477-assignment 1

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
CSC477 – Introduction To Mobile Robotics
assignment 1, 15 points
due: october 7, 2019, at 3pm
Course Page: http://www.cs.toronto.edu/~florian/courses/csc477_fall20
Overview: In this assignment you will write a feedback controller that enables a ground robot, which
obeys differential drive dynamics, to follow a wall. The purpose of this assignment is to make you develop
experience with the following concepts:
• Robot Operating System: its architecture and its publisher-subscriber model, which abstracts away
the details of distributed computation and message passing from the robot programmer. Familiarity
will also be developed with ROS’s main visualization tool, called rviz.
• Controlling the yaw of a ground robot via PID control
• Processing 2D laser measurements
• The gazebo simulator, which is currently one of the most popular simulators in the robotics community.
Setting up VNC:
If you are planning on using the lab machines for this assignment, you will have to use VNC to access the
lab PCs since you will need a GUI to run the simulations.
We will be putting up a shared google doc or spreadsheet to assign lab machines to students, so please refer
to Quercus for instructions on how to get a lab PC for yourself, if you need one.
VNC is already installed on all the systems, but you need to set up your credentials so you can run your
own VNC server that only you can access.
1. ssh into your account on your assigned lab PC
2. Type vncpasswd to create a password for yourself to access the PC
3. run vncserver with the following command so it creates the required directories.
vncserver
4. Then kill the server with
vncserver -kill :*
5. Use your favourite text editor to open the .vnc/xstartup file and put the following text in it:
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
startxfce4 &
6. Now start a vncserver again with the same command:
vncserver
page 1 of 8
CSC477: Introduction to Mobile Robotics - Assignment 1 Sept 24, 2020
7. In the output of the command you just ran, make note of the :1 (or whatever number it is, it will be :x
where x is an integer)
Here is an example of the output where the x=2 :
UTORid@dh2026pc09:~$ vncserver
New ’dh2026pc09.utm.utoronto.ca:2 (UTORid)’ desktop at :2 on machine dh2026pc09.utm.utoronto.ca
Starting applications specified in /student/UTORid/.vnc/xstartup
Log file is /student/UTORid/.vnc/dh2026pc09.utm.utoronto.ca:2.log
Use xtigervncviewer -SecurityTypes VncAuth -passwd /student/UTORid/.vnc/passwd :2 to connect to the VNC server.
Now on your desktop:
1. Install a vncviewer (I installed realvnc-vnc-viewer but I think any one will work)
2. Start an ssh tunnel which the vncserver will go through. We are doing this because the vnc connection
by itself is not encrypted and insecure, so its important that all the packets for your vnc connection pass
through the secure ssh tunnel. To start the tunnel use the command:
ssh -L yyyy:localhost:590x -C UTORid@[your assigned lab pc].utm.utoronto.ca
where yyyy is a port you want to use on your workstation that is not already used. And x is the :x number
that is shown to you when you started vncserver. The ’-C’ is to allow compression, it should help your
remote instance be more responsive.
3. Once you log in, leave the window open and start the vncviewer on your local pc. The address you would
be connecting to would be
localhost:yyyy
4. It will prompt for the vncpasswd that you created, and you should see your desktop.
If you run into trouble at any of the above steps, you may want to go through the relevant sections of the
following VNC guides to see if they solve your problem before you ask for help.
For Ubuntu 18:
www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-18-04
For Ubuntu 20:
www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-20-04
For Mac OS and Windows:
www.linode.com/docs/applications/remote-desktop/install-vnc-on-ubuntu-18-04/
page 2 of 8
CSC477: Introduction to Mobile Robotics - Assignment 1 Sept 24, 2020
Figure 1: Gazebo environment with walls only on one side of the robot.
Setting up ROS: If you are planning to work from the MCS lab machines in Deerfield Hall (e.g. DH2020,
DH2010, DH2026), Ubuntu and ROS are already installed and available to you. If you want to work from
your own machine, we are assuming that you are running Ubuntu 18.04 on a computer which you have
sudo access, then please make sure the following are installed:
• Ubuntu 18.04 (Ubuntu 20.04 is not compatible with ros melodic, so it will not work)
• ROS (melodic) http://wiki.ros.org/melodic/Installation/Ubuntu
• Gazebo 9 from http://gazebosim.org/ or from sudo apt-get install gazebo9
• numpy
• scipy
• git
• Python 2 or 3
• any video screen recorder for assignment submission (e.g. recordmydesktop
https://wiki.ubuntu.com/ScreenCasts/RecordMyDesktop)
Get and run the starter code: We have created a few simulated worlds consisting of sequences of walls
and a simulated ground robot for you for the purposes of this assignment. A screenshot of the what the
Gazebo simulation environment looks like is shown in Fig 1.
page 3 of 8
CSC477: Introduction to Mobile Robotics - Assignment 1 Sept 24, 2020
We are also providing starter code for this assignment. This starter code is provided in the form of ROS
packages in your workspace. Make sure the following lines are at the end of your /home/[username]/.bashrc
file:
export ROS_HOME=~/.ros
source /opt/ros/melodic/setup.bash
source ~/csc477_ws/devel/setup.bash
Then run the following command, this adds the paths to catkin and ros for your bash terminal, allowing
you to use them
source ~/.bashrc
Then actually create your workspace:
mkdir -p ~/csc477_ws/src
cd ~/csc477_ws/src
catkin_init_workspace
In csc477 ws/src download the starter code:
git clone https://github.com/florianshkurti/csc477_fall20.git
Then compile it, but you have to run catkin make twice, as it fails the first time :
cd ~/csc477_ws
catkin_make
source ~/.bashrc
If this last command results in errors, you might need to install additional packages. Please post your
questions on Quercus if this is the case and you don’t know what to do. In the MCS lab machines this will
most likely not be an issue. If you are working from a personal laptop or desktop, however, you might need
to install the following packages:
sudo apt-get install ros-melodic-control-toolbox ros-melodic-joystick-drivers
sudo apt-get install ros-melodic-realtime-tools ros-melodic-ros-control
sudo apt-get install ros-melodic-ros-controllers ros-melodic-gazebo-ros-control
If you still get errors after installing them please post a question on Quercus or email us as soon as possible.
If compilation goes smoothly, move on to the following.
Your assignment is run using 3 commands, each in their own separate terminal. First you create the
simulation environment, then you populate it with a virtual husky robot, and finally you run your code
piloting the husky around the environment. This is what the commands look like at a glance, they are
explained in further detail, and with some more setup info + checks below:
roslaunch wall_following_assignment gazebo_world.launch world_name:=[world_name]
roslaunch wall_following_assignment husky_follower.launch
roslaunch wall_following_assignment wall_follower_[language].launch
Here is a step-by-step walkthrough of the commands:
Bring up a world with walls in the gazebo simulator
roslaunch wall_following_assignment gazebo_world.launch world_name:=walls_one_sided
Bring up the robot (husky) in that world
roslaunch wall_following_assignment husky_follower.launch
page 4 of 8
CSC477: Introduction to Mobile Robotics - Assignment 1 Sept 24, 2020
Figure 2: Rviz visualization for the Husky robot in Fig 1. Overlaid on the robot you can see the various
reference frames from ROS’s tf system.
The only error that should appear after these two commands is that no joystick can be found. If another
error is printed, please let us know. If these two commands go well this should make the gazebo image in
Fig 1 shown above appear. Then, call rviz, which is the default visualization system for ROS:
rosrun rviz rviz
And then go to File > Open config and select the config file
csc477 ws/src/wall following assignment/resources/csc477.rviz
You should see what’s shown in Fig 2:
The rainbow-colored line is actually a set of points detected by the simulated 2D laser. The other line and
frames represent the tree of reference frames that the system is aware of. If all of this goes well then you will
be ready to proceed to the next section, which is the essence of the assignment, and to write your controller
code to make the robot move. At this point, you can run a simple last check:
rosrun teleop_twist_keyboard teleop_twist_keyboard.py \
cmd_vel:=/husky_1/husky_velocity_controller/cmd_vel
This command bring up a node publishing on topic /husky 1/husky velocity controller/cmd vel and
enable you to control the robot through keyboard. If you can successfully move husky around using the
keyboard through the command-line interface shown in Fig. 3 then you are ready to proceed with writing
your PID controller.
Implement and test a wall-following controller (15 pts) The input to the robot will be laser scan
messages from the robot’s simulated laser scanner. See here http://docs.ros.org/api/sensor_msgs/
html/msg/LaserScan.html for the ROS message definition. Also, make sure you have understood these
ROS tutorials about the publisher-subscriber model of distributed computing: http://wiki.ros.org/ROS/
Tutorials. We have provided starter code for Python and C++ in the files
page 5 of 8
CSC477: Introduction to Mobile Robotics - Assignment 1 Sept 24, 2020
Figure 3: Command-line interface for the node teleop twist keyboard.py which allows you to drive the
robot using your keyboard. If you can do this successfully then you are ready to proceed with designing the
controller.
page 6 of 8
CSC477: Introduction to Mobile Robotics - Assignment 1 Sept 24, 2020
csc477_ws/src/csc477_fall19/wall_following_assignment/python/wall_follower.py
csc477_ws/src/csc477_fall19/wall_following_assignment/src/wall_follower_node.cpp
csc477_ws/src/csc477_fall19/wall_following_assignment/include/wall_following_assignment/pid.h
Choose your language and edit the appropriate files. Specifically:
[Part A, 2 pts] Compute the cross-track error based on each incoming laser scan and publish it un-
der the topic name /husky 1/cte with the ROS message type std msgs/Float32, which can be found here
http://wiki.ros.org/std_msgs. Tutorials for how to write your own publisher in Python can be found
at http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28python%29.
[Part B, 7 pts] Populate the PID class based on the provided API. For each incoming laser scan is-
sue an angular velocity command to the robot at the topic /husky 1/cmd vel, based on the output of the
PID controller. You need to follow the wall on the LEFT of the robot, as it is placed in its initial configu-
ration.
[Part C, 2 pts]
NOTE: There are some issues getting part C to work at the time of writing these instructions, so if you have
build or import errors during this part, check the course webpage or announcements for a possible solution.
If not, let us know.
Create a dynamic reconfigure server for tweaking your controller’s parameters in real time. Follow the in-
structions presented here: http://wiki.ros.org/dynamic_reconfigure/Tutorials. Add at least three
parameters for the PID gains and run
rosrun rqt_reconfigure rqt_reconfigure
to tweak the PID parameters manually. A set of parameters is considered good enough and the run is
considered successful if the robot does not collide with the wall and completes at least 3/4 of a full circuit
around the left wall.
[Part D, 4 pts] For each of the two simple wall worlds in wall following assignment/worlds/, namely:
walls one sided.world, walls two sided.world, do the following:
Launch your wall following controller like this:
roslaunch wall_following_assignment wall_follower_python.launch
or
roslaunch wall_following_assignment wall_follower_cpp.launch
according to your language of choice.
• (1pt/world) Use a desktop recording program such as recordMyDesktop or something similar to record
a video of your robot while it is following the wall. Be sure to include any failure cases.
• (1pt/world) Record the cross-track error published by your node as follows:
rosbag record /husky_1/cte
and after your robot’s run is done, convert the recorded messages in the bag into a text file like so:
rostopic echo -b file.bag -p /husky_1/cte > cross_track_error.csv
rosbag play file.bag
page 7 of 8
CSC477: Introduction to Mobile Robotics - Assignment 1 Sept 24, 2020
Submission Instructions Assignment submissions will be done on Quercus. You will submit a zip file
containing the following:
1. Your csc477 fall20/wall following assignment directory for Parts A, B, and C.
2. Two videos, one for demonstrating the robot’s navigation in the world walls one sided.world and
another video for the world walls two sided.world as explained in Part D. The videos should be
named as follows:
FirstName_LastName_StudentNumber_walls_one_sided.[mp4/avi]
FirstName_LastName_StudentNumber_walls_two_sided.[mp4/avi]
Each video should not exceed 10MB.
3. Similarly, two csv files from Part D. They should be named:
FirstName_LastName_StudentNumber_walls_one_sided.csv
FirstName_LastName_StudentNumber_walls_two_sided.csv
The point of including a video of your controller in your submission is not just for us to easily examine
your code. It’s also so that you can easily show your work later on to classmates/coworkers/employers.
It becomes part of your portfolio. It is also worth noting that, due to the ROS abstraction layer, if
you want, you could run your feedback controller on a real Husky robot, without major modifications.
We expect your code to run on the MCS Lab machines. If it does not you will lose marks. We expect to be
able to compile it using catkin make. Once we compile your code we will run the following:
roslaunch wall_following_assignment gazebo_world.launch world_name:=[world_name]
roslaunch wall_following_assignment husky_follower.launch
roslaunch wall_following_assignment wall_follower_[language].launch
We will test your code on other similar worlds to the one provided. We will also test it using different
desired distances away from the goal. The default desired distance is 1 meter away, and the default forward
speed is 1m/s. We will test your code with different parameters in that neighbourhood. Your code will also
be examined for correctness, style and efficiency. We recommend that you come by during office hours or
email us if you are unsure of your implementation.
page 8 of 8

欢迎咨询51作业君
51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468