Wiki

Clone wiki

scl-manips-v2 / iiwa / iiwa_prog

Using the lab computer

The easiest way to program and control the Kuka IIWA robot is to use the lab computer that has set up everything for you.

Run ROS stuff

1. In the lab computer, login into account:

Username: CS225A_IIWA

Ask us for the password.

2. Open a terminal, type in the folloiwng command

roscore

This should automatically starts a new ROS master running on http://192.168.168.1:11311/. If you see error message, check if there's a ethernet connection called IIWA. If not, you need to connect to black ethernet cable from the robot to this computer.

3. Open a new terminal window (you can use Ctrl+Shift+T), type in

rosrun IIWA IIWA-bin

This should keep printing out "waiting for the IIWA robot to connect ..." before you run the ROS node on that orange panel.

4. Pick up the annoying orange industrial contraption with buttons and knobs on it.

Run through this archaic ritual to start the robot (click on the preview image below to see higher resolution image)

Step 1 : Push the button
Step1.jpg

Step 2 : Push the buttons (in order)
Step2.jpg

Step 3 : Flick the switch (Use much brain power, this does)
Step3.jpg

Step 4 : On the new screen: Push the button (I hope you're still alive)
Step4.jpg

Step 5 : Flick the switch back (Who designed this?)
Step5.jpg

Step 6 : Push the green button (You know you were waiting for this one...)
Step6.jpg

Click just once and be patient - you'll hear the sound of the robot unlocked. The robot will also move slowly to the default position if it's not at default positions. (This default joint position is documented in the scl-manips-v2/specs/iiwa/iiwa.xml file.) Wait until it finishes.

If you click the green button and the program does not start, probably the robot was stuck in operation last time. In this case, you'll have to follow this tute to fix the problem

5. When the ROSCom program finally starts to run, come back to the terminal, it should say "IIWA Robot is connected.".

Run the demo program

1. Now open another terminal window, type in

cd ~/Documents/scl-manips-v2/application-linux/scl_iiwa_ctrl/
sh run.sh

This should open a demo program of the IIWA robot. You can use W/A/S/D/Q/E to change the desired position of the end effector (the red sphere).

2. Now comes the exciting part! Finally!

Before that, make sure the simulated robot has a configuration that's close to the actual robot. (The simulated robot should be by default the same as the initial configuration of the real robot if you haven't moved it)

When you're ready, with the graphics window active, click "0" on the keyboard to activate controlling the real robot. This will start sending joint positions in the simulation to the real robot. Now the robot will move exactly as how it moves in the simulation.

Use your own simulation

The basic thing you need to add is

  • Read the robot's current joint positions and use the information to set your robot's initial joint positions in your simulation.
  • Send your simulated robot's current joint positions to the ROS node. This is done by a socket communication library called zmqpp. To set this up, you need to go through the following steps:

1. You mush read the robot's current joint positions and set it in your simulation before you connect your simulation with the robot. In the demo program source code (Documents/scl-manips-v2/application-linux/scl_iiwa_ctrl/CIiwaApp.cpp) find the function receiveFromRobot(Eigen::Vector &q), copy and insert it in your code.

2. Then in wherever your control loop is running, insert these codes before you update the robot's dynamic model (usually at the beginning of your loop):

Eigen::VectorXd q_recv_;
if (!robotEnabled && receiveFromRobot(q_recv_))
{
  robot_.setGeneralizedCoordinates(q_recv_);
  robot_.setGeneralizedVelocitiesToZero();
  robot_.setGeneralizedAccelerationsToZero();
}

Note that the variable robotEnabled is not optional - you must have a way in your simulation to switch between "receive" mode and "send" mode.

3. To send your robot's current joint positions, you need to find the function sendToRobot() in the demo program source code (Documents/scl-manips-v2/application-linux/scl_iiwa_ctrl/CIiwaApp.cpp). Copy and insert it in your codes.

4. In your control loop, insert these codes after the integrate function.

if (robotEnabled && ctrl_ctr_ % 2 == 0)
   sendToRobot();

ctrl_ctr_% 2 == 0 is for setting a reasonable sending rate. You don't have to send the joint position every loop. Sending it too fast may also cause message to pile up and slow down the robot's response significantly.

5. Wherever you add this sendToRobot() function, you need to add

#include <zmqpp/zmqpp.hpp>

6. In your CMakeLists.txt, add zmq and zmqpp in your target_link_libraries

target_link_libraries(... zmq zmqpp)

Debug your simulation

If you need to check the connection between your simulation and the ROS node (or for other debugging purpose), you can modify the ROS codes and run it without running the ROSCom on the robot. To modify and recompile the ROS code:

1. Open the source code: Home/Catkin_ws/src/IIWA/src/main.cpp

2. Modify the codes to print out something. For example, you can uncomment the cout line that prints the message the program receives. NOTE: comment any cout line when running with the real robot!! Also be careful if you try to do more than just printing stuff.

3. In the terminal window, run

catkin_make

Pause your experiment

If you want to modify your codes when experimenting with the robot, there's no need to kill the ROSCom running on that orange panel (just leave it running). Just Ctrl+C the ROS node running on the computer and the simulation.

Don't kill the ROS master! (where you run roscore)

Do Rosrun IIWA IIWA-bin before running your simulation.

Use your own computer/account

Aside from what's been described above, you need to do some more things to set up the environment:

1. Install ROS (either indigo or hydro), the latest version hasn't been tested yet.

2. Configure ROS environment following this tute.

3. Download the ROS IIWA package

4. Before you proceed to catkin_make, you need to install zmq and zmqpp in your computer first. You can download zmq from Zeromq software, download the stable release 4.0.5. Navigate to the folder in your terminal, and run these commands:

sudo apt-get install libtool autoconf automake uuid-dev build-essential
./configure
make
sudo make install
sudo ldconfig

5. You can download zmqpp by typing

git clone https://github.com/zeromq/zmqpp.git

Then follow the instruction here to install the library in your computer

6. Now you can go back to catkin_ws

cd ~/catkin_ws

and run

catkin_make

Updated