This is a very quick demo of ros & ev3dev.
Requires Ubuntu 14.04 + ev3dev + Ros & ev3dev-lang-cpp:
See my instructions to install all requirments here: https://github.com/moriarty/ros-ev3
In the above instructions, I recommend python because the steps are much easier. This demo is for roscpp + ev3dev-lang-cpp.
Most of the steps are detailed in this document: brickstrap build steps, so I will just mention the high level steps.
- Install Ubuntu 14.04. If running windows or OS X, installing in a virtual machine works. (Instructions can be found online)
- Install Brickstrap (see doc link above)
- In the Brickstrap environment for your target device (EV3, rpi, rpi2):
- Install
ros_comm
dependencies - Install
ros_comm & common_msgs
- Install
ev3dev-lang-cpp
NOTE: Use instructions above, as I provide a patch to the CMakeLists.txt in ev3dev-lang-cpp for easier use with ros. - Create SD Card from brickstrap for EV3
- The EV3 doesn't have enough CPU/RAM to run
roscore
, so you'll need a computer on your network with ROS installed and roscore running. This can be the virtual machine from above. - A RaspberryPi/BrickPi with ev3dev can run roscore, see notes
catkin_make
will run out of memory on the EV3. The quick fix, is develop inside of brickstrap and dump the whole catkin workspace over with FileZilla. Not an elegant solution but it works.
This instructions are standard to create a catkin workspace
- Open at least one shell to the brickstrap environment created above.
- Inside of the brickstrap environment:
- Source setup.bash for ROS:
-
source /opt/ros/indigo/setup.bash
- Change to the robot home directory and create a catkin workspace
-
mkdir -p /home/robot/catkin_ws/src
-cd /home/robot/catkin_ws/src
-catkin_init_workspace
- Clone this repository into the catkin workspace
-
git clone https://github.com/moriarty/ev3dev_ros_demo.git
-cd /home/robot/catkin_ws
-catkin_make
I recommend FileZilla for this as it's really easy.
- Install FileZilla in your Ubuntu environment (not brickstrap)
sudo apt-get update && sudo apt-get install filezilla
- Open Filezilla and use the following connection information:
- Host:
ev3dev.local
- IP or network name of your device. For example mine isev3dev.local
but not all networks are set up to add the.local
domain. - Username:
robot
- Default user for ev3dev - Password:
maker
- Currently the default password for ev3dev - Port:
22
- use SSH File Transfer Protocol.
- Click Quickconnect, and accept the ssh key box which might pop up.
- In
Local site:
- Go to where the brickstrap catkin_ws is located. For example:
/home/alex/brickstrap-workspace/ev3-rootfs/home/robot/catkin_ws/
- In
Remote site:
- Go to
/home/robot
(FileZilla likely opened this location by default)
- Drag
catkin_ws
fromLocal site
to/robot/home/
inRemote site:
- If you already have a
catkin_ws
there from following these steps, FileZilla will ask what to do with duplicate files.
- All that is needed is a motor in
Output B
. ev3dev_test_node.cpp
is the source file.ev3dev_test_node_cpp
is the target defined in the CMakeLists.txtev3test_controller
is the node name when runningev3dev_test_node_cpp
ev3test_controller
:
- Listens for the string
"start"
or"stop"
on the topic/ev3test_controller/cmd
- Publishes the current state
"RUN"
or"IDLE"
on the topic/ev3test_controller/state
- Start roscore on Ubuntu machine:
roscore
- SSH into ev3, source & setup ROS, run ev3dev_test_node_cpp:
ssh robot@ev3dev.local
source /opt/ros/indigo/setup.bash
export ROS_MASTER_URI=http://192.168.0.101:11311
(replace with IP of machine running roscore)- run test node, either directly or with
rosrun
./catkin_ws/devel/lib/ev3dev_ros_demo/ev3dev_test_node_cpp
orrosrun ev3dev_ros_demo ev3dev_test_node_cpp
(rosrun has some overhead and delays start)
- Back on Ubuntu machine:
- Check node is running
rosnode list
- Get node info
rosnode info
- Publish a start command:
rostopic pub /ev3test_controller/cmd std_msgs/String "data: 'start'"
- Publsih a stop command:
rostopic pub /ev3test_controller/cmd std_msgs/String "data: 'stop'"
Here is the output of rosnode info. As you can see from the hostnames, it's running on ev3dev.local and my desktop is alex-linux-desktop.local where I'm publishing start and stop.
$ rosnode info /ev3test_controller
--------------------------------------------------------------------------------
Node [/ev3test_controller]
Publications:
* /ev3test_controller/state [std_msgs/String]
* /rosout [rosgraph_msgs/Log]
Subscriptions:
* /ev3test_controller/cmd [std_msgs/String]
Services:
* /ev3test_controller/get_loggers
* /ev3test_controller/set_logger_level
contacting node http://ev3dev.local:32963/ ...
Pid: 2244
Connections:
* topic: /rosout
* to: /rosout
* direction: outbound
* transport: TCPROS
* topic: /ev3test_controller/cmd
* to: /rostopic_17467_1460401560340 (http://alex-linux-desktop.local:38400/)
* direction: inbound
* transport: TCPROS
Here is the output of rostopic echo
$ rostopic echo /ev3test_controller/state
data: RUN
---
data: IDLE
---
$ rostopic pub /ev3test_controller/cmd std_msgs/String "data: 'start'"
publishing and latching message. Press ctrl-C to terminate
^C
$ rostopic pub /ev3test_controller/cmd std_msgs/String "data: 'stop'"
publishing and latching message. Press ctrl-C to terminate