For this exercise, work independently to compute \([x, y, z]\) of the robot's end effector in terms of the lengths of the robot's two linkages \((l_1, l_2)\) and the angles of rotation of the two revolute joints \( (q_1, q_2) \). If it's useful to you, feel free to reference the slides we just went over in class.
Once you've finished computing \([x, y, z]\), please wait for others to finish. We'll go over the solution in the main Zoom room together.
Please head into breakout rooms for this class exercise.
In this class exercise, you will 1) learn the basics of turtlebot's arms though GUIs, 2) learn how to manipulate the arm through code.
Let's go over the Turtlebot3 tools that allows you to control the robot arm with a GUI. First run the following command, which starts starts a gazebo session a Turtlebot3 with an OpenMANIPULATOR arm.
$ roscore
$ roslaunch turtlebot3_manipulation_gazebo turtlebot3_manipulation_gazebo.launch
Next, you need MoveIt to manipulate the arm. Launch the following in a new terminal. Once this node is up and running, start your gazebo simulator by pressing the ▶ button in the
bottom left. You should see a message that says, You can start planning now! in the terminal running the move_group
.
$ roslaunch turtlebot3_manipulation_moveit_config move_group.launch
Finally, you need some GUI to control the robot arm. The ROBOTIS GUI provides you with a simple window that allows control of the robot arm within gazebo. Use the following command to launch the GUI. Make sure your gazebo simulation is running and not stopped; otherwise the GUI window will not pop up.
$ roslaunch turtlebot3_manipulation_gui turtlebot3_manipulation_gui.launch
The GUI provides the following information,
Let's make sure your simulation robot can move its arm. Press Time Start and then click on Home Pose. You should see your robot arm move to a new position in the simulation. Pay close attention to how the new pose changes the joint and XYZ values.
Manual movement of the arm is possible through the options in the bottom right features of the GUI. There are two options available for this purpose,
Task Space Control
: Sets the position of the red square between the robot's grippers to a certain XYZ. Joint Space Control
: Sets the position of each single join. The window with an s next to it is for selecting how fast you want the the transformation to occur. Once you are done with your manual selection, send your desired positions to the robot and watch the arm move.
Think about the following questions while you experiment with the GUI,
The MoveIt ROS package provides a simple, yet powerful interface to control the OpenMANIPULATOR arm on our Turtlebot3. This section outlines the general interface. There is no need to implement anything in the section. Just make sure that you understand the basics of the interface.
First, we setup the interface for controlling the gripper and the arm in the object initialization.
#!/usr/bin/env python3
import rospy
# import the moveit_commander, which allows us to control the arms
import moveit_commander
class Robot(object):
def __init__(self):
# initialize this node
rospy.init_node('turtlebot3_dance')
# the interface to the group of joints making up the turtlebot3
# openmanipulator arm
self.move_group_arm = moveit_commander.MoveGroupCommander("arm")
# the interface to the group of joints making up the turtlebot3
# openmanipulator gripper
self.move_group_gripper = moveit_commander.MoveGroupCommander("gripper")
With this starter code, moving the arm or the gripper using joint angles is fairly simple. Let's try moving the arm,
def run(self):
...
...
# We can use the following function to move the arm
# self.move_group_arm.go(arm_joint_goal, wait=True)
# arm_joint_goal is a list of 4 radian values, 1 for each joint
# wait=True ensures that the movement is synchronous
# Let's move the arm based on what we have learned
# First determine at what angle each joint should be.
# You can use the GUI to find appropriate values based on your need.
arm_joint_goal = [0.0,
math.radians(5.0),
math.radians(10.0),
math.radians(-20.0)]
# Move the arm
self.move_group_arm.go(arm_joint_goal, wait=True)
# The above should finish once the arm has fully moved.
# However, to prevent any residual movement,we call the following as well.
self.move_group_arm.stop()
Moving the gripper is very similar.
# We can use the following function to move the gripper
# self.move_group_gripper.go(gripper_joint_goal, wait=True)
# gripper_joint_goal is a list of 2 values in meters, 1 for the left gripper and one for the right
# wait=True ensures that the movement is synchronous
# Let's move the gripper based on what we have learned
# First determine what how far the grippers should be from the base position.
# You can use the GUI to find appropriate values based on your need.
gripper_joint_goal = [0.009,0.0009]
# Move the gripper
self.move_group_gripper.go(gripper_joint_goal, wait=True)
# The above should finish once the arm has fully moved.
# However, to prevent any residual movement,we call the following as well.
self.move_group_gripper.stop()
In this exercise, we will use the arm of the turtlebot to guide an imaginary traffic. You should not use the robot's wheels for this exercise. You will be working the same groups.
To get started on this exercise, update the intro_robo
class package to get the class_meeting_08_kinematics ROS package and starter code that we'll be using for this activity.
$ cd ~/catkin_ws/src/intro_robo
$ git pull
$ git submodule update --init --recursive
$ cd ~/catkin_ws && catkin_make
$ source devel/setup.bash
traffic_status
topic.
Here is an example scenario.
First terminal: run roscore.
$ roscore
Second terminal: run your Gazebo simulator with the intersection environment provided in today's class repo.
$ roslaunch class_meeting_08_kinematics turtlebot3_intersection.launch
Thrid terminal: Launch the MoveIt move_group.
.
$ roslaunch turtlebot3_manipulation_moveit_config move_group.launch
Forth terminal: Run the python node that moves your robot arm.
$ rosrun class_meeting_08_kinematics move.py
class_meeting_08_kinematics/msg/Traffic.msg
, you will see that it is an empty msg file. Update the msg file such that you can encode at least 3 directions with that message. Here are some helpful resources: official wiki and our short intro to ros msgs. class_meeting_08_kinematics/scripts/traffic.py
file such that it publishes a traffic message with a different direction every 10 seconds. After this step, relaunch your gazebo world and make sure that your traffic controller is publishing traffic messages appropriately via rostopic echo traffic_status.class_meeting_08_kinematics/scripts/move.py
file such that the turtlebot arm performs something different per msg received in the traffic_status
callback function. Once done, run the move.py
file and make sure your robot arm moves as it receives different messages. Here is the example solution code
move_group
node will need to get launched every time you wish to control the robot through code using the MoveIt interface. I want to thank Woolfrey for their helpful Youtube videos on forward and inverse kinematics for helping to inform the content for today's class.