Giter Club home page Giter Club logo

robot_painter's Introduction

Software installation on KRC4

EKI interface is required on both, KRC4 and NUC. Detailed information on how to set it up on KRC4 is presented here. Launch it on robot's controller.

Software installation on NUC

ROS

sudo apt-get install ros-melodic-desktop-full
sudo apt-get install ros-melodic-joint-trajectory-controller

librealsense opencv

Create a catkin workspace:

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/
catkin build

Download ROS packages. All the scripts are stored here. Clone the repository:

cd src
git clone --branch test_branch https://github.com/airalab/robot_painter
cd robot_painter
rm -rf scenes
mv * ../
cd ..
rmdir robot_painter

You may need some header files and libraries to make it all work correctly. Download them:

cd ~
git clone https://github.com/PaTara43/kuka_moveit_webots
cd kuka_moveit_webots
sudo mv headers/* usr/include/c++/7/
sudo mv libs/* /usr/local/lib/
cd ~
svn checkout https://github.com/PX4/Matrix/trunk/matrix
mv matrix -r /usr/include/c++/7/
sudo apt-get install ros-melodic-brics-actuator
cd ~/catkin_ws
catkin build

Add source command to .bashrc file:

echo “source ~/catkin_ws/devel/setup.bash” >> ~/.bashrc
source ~/.bashrc

Up to now you should be able to launch the scripts. If something goes wrong, try some troubleshooting.

Filling in constants

First of all, the robot needs to know canvas location and orientation as well as the paint tin position. All of this is specified in fake_painter_enviroment_tf/src/tf_broadcaster.cpp. Let's take a look into it.

// Plane constants
const double A = -0.0641;
const double B = 0.0214;
const double C = 0.9977;
const double D = -0.2198;

// Canvas transform
const double px = 0.52;
const double py = -0.24;
const double qx = -0.011;
const double qy = -0.032;
const double qz = 0.0;
const double qw = 0.999;

These are the plane equation constants which specify canvas position in 3-D space. They are to be obtained during a calibration process described below. Next goes the paint.

colorTransform.transform.translation.x = 0.5;
colorTransform.transform.translation.y = 0.2;
colorTransform.transform.translation.z = 0.258;

These are paint tin coordinates. They also may be specified while calibrating. Canvas size is specified in

canvas.width = 0.5;
canvas.height = 0.4;

Several more important constants are stored in local_task_planner/src/Drawing.cpp:

const double COLOR_BOTLE_HEIGHT = 0.06;
const double COLOR_HEIGHT = 0.045;
const double HEIGHT_OFFSET = COLOR_BOTLE_HEIGHT - COLOR_HEIGHT + 0.02;
const double BRUSH_HEIGHT = 0.01;
const double BRUSH_WIDTH = 0.01;

Their names say it all, so fill them in according to the situation.

Calibrating Gaka-Chu

The calibration process itself is pretty simple.

  1. Start EKI interface on the KRC4:

Log in in 'AUT' mode, turn on drivers and launch the script eki_hw_interface.

  1. Start EKI interface on the NUC
roslaunch kuka_eki_hw_interface test_hardware_interface.launch

It should output endless logs.

  1. Start RViz
roslaunch kuka_moveit_config demo.launch

Try moving the end effector and clicking 'Plan and Execute'. The robot should move. On SmartPad go to Display -> Actual position and observe end effector's coordinate. Place a canvas horizontally to the robot base. Plug a brush into the brush holder and carefully move it till it barely touches the canvas. At this position, save end effector's coordinates. Repeat 12-15 times. Also, save the coordinates of the canvas center and paint tin. When you have a set of coordinates, use these Matlab scripts to resolve the missing constants and quaternion. Paste them. Rebuild your workspace with

cd ~/catkin_workspace
rm -rf build logs devel
catkin build

Testing Gaka-Chu calibration

When calibrated, Gaka-Chu needs to be tested by drawing the borders of canvas. To make him do so execute each in new terminal:

roslaunch kuka_eki_hw_interface test_hardware_interface.launch
roslaunch kuka_moveit_config demo.launch
rosrun fake_painter_enviroment_tf tf_broadcaster
rosrun local_task_planner draw_workspace

In terminal press "S" to perform testing. Robot's end effector should move right above the borders of the canvas and the brush should gently touch the canvas during the entire movement. If not so, try recalibrating. If the canvas model is rotated wrong, you can rotate it by changing quaternion in Matlab.

Making art

You need 6 basic modules to make it all work:

  • EKI interface;
  • MOVEit + RViz;
  • Environment frames broadcasting;
  • Picture converter service;
  • Trajectories drawing module;
  • Starting trigger.

Let's launch them one by one.

Eki interface

On KRC4 launch eki_hw_interface, on NUC in a new terminal do:

roslaunch kuka_eki_hw_interface test_hardware_interface.launch

RViz and MOVEit

You need a planner and a simulation. Launch them with

roslaunch kuka_moveit_config demo.launch

Environment

Tell the robot where the paint tin and the canvas are. Note that it is not necessary to launch draw workspace node, the tf_broadcaster shares the canvas size. It just doesn't show it in RViz.

rosrun fake_painter_enviroment_tf tf_broadcaster

Pictures processor

All incoming pictures need to be processed. Launch the service.

rosrun picture_preprocessing TextConverter.py

When it receives the call, it processes a picture with a HP filter and creates a rosbag file with trajectories.

Trajectories drawer

The mainest script here is the trajectories drawer itself. It waits for the picture, calls TextConverter service and draws the painting.

rosrun local_task_planner trajectory_drawing

Send the robot a picture to draw

The robot listens to a specific ROS-topic where you need to pass the path to a desired picture. The picture should be square (width equals height) and made of lines. Send the path:

rostopic pub /run std_msgs/String "data: '<path_to_picture>'"

After that. Two windows pop up showing the contours and the tracks. Close them and see Gaka-Chu drawing. Watch out for safety and alwasy be ready to press emergency stop button. When Gaka-Chu finishes his art, you can send another path to picture and painter repeats the whole process.

robot_painter's People

Contributors

alexeiovcharov avatar nakata5321 avatar patara43 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

5l1v3r1 zdkhit

robot_painter's Issues

Error with "Marker pudlisher" during calibration

Problem

When we want to calibrate workspase with command: rosrun local_task_planner draw_workspace error occurrences: can't find a publisher to marker.

Solution

add next strings:

    - Class: rviz/Marker
      Enabled: true
      Marker Topic: /visualization_marker
      Name: Marker
      Namespaces:
        basic_shapes: true
      Queue Size: 100
      Value: true

in file robot_painter/kuka_kr6r900_common/kuka_moveit_config/launch/moveit.rviz between 308 and 309 lines.

uncorrect position in config file controllers.yaml

Problem

execute command roslaunch kuka_moveit_config demo.launch give error:
[ERROR] [1605642695.396393908]: Action client not connected: kuka_arm/arm_controller/follow_joint_trajectory

As result, we can't move kuka.

Solution

In config file kuka_kr6r900_common/kuka_moveit_config/config/controllers.yaml we should change second line:
from - name: kuka_arm/arm_controller to - name: position_trajectory_controller

Cmake error

In local task planner dir in Cmake file missed word "include" after "include_directories"

include_directories(
    
    ${catkin_INCLUDE_DIRS}
)

Need to add it:

include_directories(
    include
    ${catkin_INCLUDE_DIRS}
)

TextConverter fails after draving 3 strange lines

After running

rosrun picture_preprocessing TextConverter.py
rosrun local_task_planner trajectory_drawing
rostopic pub /run std_msgs/ String "data: ''"

TextConverter.py outputs Start image preprocessor!
Kuka draws 3 strange lines and then TextConverter.py fails with Error processing request, need more than 2 values to unpack

Solution:

change line 111 of TextConverter.py to contours, hierarchy = cv2.findContours(bw2, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

It still draws 3 strange lines in the beginning though

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.