Step by Step - samirasancheze/EV3MeSy_Siegen_2018-2019 GitHub Wiki

If you are working on Ubuntu 14.04 follow this Installation tutorial and then start from step 1.

If you are going to work on Virtual box download the image and follow inside the slides' "Tutorial 1" and then start from step 1.

  1. Create a catking workspace, you can follow this tutorial or follow inside the slides' "Tutorial 2". Now you would have a folder called catkin_ws in your Home folder, in catking_ws there are three folders src, build and devel but you only have to worry about src folder, there is where all your packages are going to be.
NOTE.

every time you want to biuld a package open a new terminal and then type

$ cd ~/catkin_ws

$ catkin_make

$ . ~/catkin_ws/devel/setup.bash

and check that your package have been build writing in the same terminal

$ rospack list


  1. In order to download the control and sensor packages that you are going to use

$ cd ~/catkin_ws

$ cd src

$ git clone https://github.com/Hacks4ROS/h4r_ev3_ctrl

$ catkin_make

$ . ~/catkin_ws/devel/setup.bash

Now you have to have inside catkin_ws/src a folder called h4r_ev3_ctrl. Inside there are four folders

  • h4r_ev3_control
  • h4r_ev3_launch
  • h4r_ev3_manager
  • h4r_ev3_msgs

Each of them are packages itself

  1. To activate the motors
  • Open the folder ~/catkin_ws/src/h4r_ev3_ctrl/h4r_ev3_launch/config/ and copy the path of the file motors.yaml
  • Open the folder ~/catkin_ws/src/h4r_ev3_ctrl/h4r_ev3_launch/launch/ and open the file motors.launch

in this line replace your motors.yaml file path, instead of $(find h4r_ev3_launch)/config

<rosparam file="$(find h4r_ev3_launch)/config/motors.yaml" command="load"/>

  1. To connect the PC with the robot follow inside the slides' "Tutorial 4"

  2. Run the motors following "Tutorial 5" inside the slides'.

but instead of

$ roslaunch ./motors.launch ev3_hostname:=ev3dev

you have to specify where motors.launch is

$ roslaunch PASTE HERE THE PATH/motors.launch ev3_hostname:=ev3dev

and to run for example the color sensor, ultrasonic sensor and gyroscope at the same time, create a new launch file called sensors.launch and then run it

$ roslaunch PASTE HERE THE PATH/sensors.launch ev3_hostname:=ev3dev

type

$ rostopic list

You are going to see /color, /ultrasonic, /gyro, /ev3dev/OutPortA/command, /ev3dev/OutPortB/command and another 2 topics.

  1. Send to the motors a speed number

$ rostopic pub /ev3dev/OutPortA/command std_msgs/Float64 "data: 1.0"

$ rostopic pub /ev3dev/OutPortB/command std_msgs/Float64 "data: 1.0"

Stop them sending 0.0 instead of 1.0

  1. See what the color sensor is sending

rostopic echo /color

Do the same for the /ultrasonic and /gyro sensors.

  1. To run your own code, save it in ~/catkin_ws/src/h4r_ev3_ctrl/h4r_ev3_control/src/h4r_ev3_control
  • open a new terminal and go to the folder where your code is ( ~/catkin_ws/src/h4r_ev3_ctrl/h4r_ev3_control/src/h4r_ev3_control) and then type $ chmod +x YOUR FILE.py (if you are working on c++ change .py into .cpp)
  • Then type $ rosrun h4r_ev3_ctrl YOUR FILE.py