Simulating the robot

Before testing on the real robot, it is vital to test your code on a simulator. We use Gazebo to visulise the movement of the Panda Emika robot to see if it behaves properly. Form experience, IF and ONLY if it works in the simulation is there a REMOTE chance that your code will work on the actual robot.

Word of advice: Simulate, Simulate, Simulate. Until everything works perfectly in the simulation.

Note that the actual Franka Emika robot costs several thousand Euros, and you will have a very limited time with the actual robot. You can save a lot of time by simulating everything on your computer. By simulating, you can potentially avoid getting the robot to do unexpected things. E.g spin around and smash into the wall behind. It would be a very expensive error.

Here is a video a full game simulation of the robot.

Starting up your simulation

Open five terminals, navigate to /catkin_ws and run the following commands in each:

Run Roscore, the master messaging core

roscore

Open up Gazebo, the simulation software

source devel/setup.bash
rosrun gazebo_ros gazebo

Now open up Rviz, and open up the Movit motion planner plugin used for motion planning.

source devel/setup.bash
roslaunch panda_moveit_config demo.launch rviz_tutorial:=true

Now you need to activate motion planning using the Movit plugin. Add motion Motion Planning in the Add button. Then make sure Planning Scene Topic is set to /planning_scene . Also, set Planning Request to panda_arm . Under the Planning tab, make sure Use Cartesian Path is selected. You can set it up as shown in the image below.

_images/planning_scene.png

Run the ‘’panda_publisher.py’’ utility that broadcasts movement of the joints and gripper such that gazebo knows that it has moved.

cd src/panda_publisher
python panda_publisher.py

Finally, spawn the robot arm in Gazebo.

source devel/setup.bash
roslaunch franka_gazebo panda_arm_hand.launch

Running Connect Four game code

Now that we have the simulation setup, we can run the code to move the robot and play the Connect Four game. We need to return to the home directory, \RoboticsProject, and open a new terminal. We then navigate to franka_main, where our python script to move the robot and play the game is stored. In your terminal opened in \RoboticsProject:

cd Franka_ws
python main.py

Now you should be able to see the game startup on your terminal. It will give your instructions to help you position the Connect Four board right under the robot’s gripper. More instructions on playing the game will be in the next page.

Simulation setup screencast

For your reference, here is video showing the whole setup operation that will allow you to run a full simulation.