Difference between revisions of "Create and Build Follow"
(→Create Follow) |
(→Change Color) |
||
(25 intermediate revisions by the same user not shown) | |||
Line 16: | Line 16: | ||
Please edit follow/manifest.xml and mainpage.dox to finish creating your package | Please edit follow/manifest.xml and mainpage.dox to finish creating your package | ||
− | This will create the follow directory with make files, a source and include | + | This will create the follow directory with make files, Doxygen template, a source directory and include directory. |
epp@tabor:ros_workspace$ '''cd follow''' | epp@tabor:ros_workspace$ '''cd follow''' | ||
Line 22: | Line 22: | ||
eepp@tabor:follow$ '''ls''' | eepp@tabor:follow$ '''ls''' | ||
CMakeLists.txt include mainpage.dox Makefile manifest.xml src | CMakeLists.txt include mainpage.dox Makefile manifest.xml src | ||
+ | |||
+ | manifest.xml will contain the dependencies listed in the package create command. | ||
+ | <pre> | ||
+ | <package> | ||
+ | <description brief="follow"> | ||
+ | |||
+ | follow | ||
+ | |||
+ | </description> | ||
+ | <author>Ed C. Epp</author> | ||
+ | <license>BSD</license> | ||
+ | <review status="unreviewed" notes=""/> | ||
+ | <url>http://ros.org/wiki/follow</url> | ||
+ | <depend package="std_msgs"/> | ||
+ | <depend package="rospy"/> | ||
+ | <depend package="roscpp"/> | ||
+ | |||
+ | </package> | ||
+ | </pre> | ||
+ | |||
+ | == Build == | ||
+ | |||
+ | Entering a make from the follow directory will create the bin and build directories. | ||
+ | |||
+ | epp@tabor:follow$ '''make''' | ||
+ | mkdir -p bin | ||
+ | cd build && cmake -Wdev -DCMAKE_TOOLCHAIN_FILE=`rospack find rosbuild`/rostoolchain.cmake .. | ||
+ | -- The C compiler identification is GNU | ||
+ | -- The CXX compiler identification is GNU | ||
+ | -- Check for working C compiler: /usr/bin/gcc | ||
+ | -- Check for working C compiler: /usr/bin/gcc -- works | ||
+ | -- Detecting C compiler ABI info | ||
+ | -- Detecting C compiler ABI info - done | ||
+ | -- Check for working CXX compiler: /usr/bin/c++ | ||
+ | -- Check for working CXX compiler: /usr/bin/c++ -- works | ||
+ | -- Detecting CXX compiler ABI info | ||
+ | -- Detecting CXX compiler ABI info - done | ||
+ | -- Found PythonInterp: /usr/bin/python2.6 | ||
+ | [rosbuild] Building package follow | ||
+ | [rosbuild] Cached build flags older than manifests; calling rospack to get flags | ||
+ | [rosbuild] Including /opt/ros/electric/stacks/ros_comm/clients/rospy/cmake/rospy.cmake | ||
+ | [rosbuild] Including /opt/ros/electric/stacks/ros_comm/clients/roslisp/cmake/roslisp.cmake | ||
+ | [rosbuild] Including /opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/cmake/roscpp.cmake | ||
+ | -- Configuring done | ||
+ | -- Generating done | ||
+ | -- Build files have been written to: /home/eepp/ros_workspace/follow/build | ||
+ | cd build && make | ||
+ | make[1]: Entering directory `/home/eepp/ros_workspace/follow/build' | ||
+ | make[1]: Leaving directory `/home/eepp/ros_workspace/follow/build' | ||
+ | |||
+ | build will contain all the make infrastructure specified by CMakeLists.txt file. bin will also be created but will be empty because the src directory is empty and no source files are specified in CMakeLists.txt. | ||
+ | |||
+ | == Add the track_it Program == | ||
+ | |||
+ | Create a program in the src directory. In this case the [[Track It Program]] named track_it.cpp. | ||
+ | |||
+ | Uncomment the genmsg line in CMakeLists.txt. | ||
+ | rosbuild_genmsg() | ||
+ | Also add the following line to the end of CMakeLists.txt. | ||
+ | rosbuild_add_executable(track_it src/track_it.cpp) | ||
+ | The first parameter, track_it, specifies the name of the binary that will go into the bin directory. The second parameter specifies where to find the source. | ||
+ | |||
+ | Add the following dependencies to manifest.xml. | ||
+ | <depend package="sensor_msgs"/> | ||
+ | <depend package="opencv2"/> | ||
+ | <depend package="cv_bridge"/> | ||
+ | <depend package="image_transport"/> | ||
+ | <depend package="ihr_demo_bags"/> | ||
+ | |||
+ | Do a make in the follow directory. | ||
+ | eepp@tabor:follow$ '''make''' | ||
+ | |||
+ | The compile log will look something like [[Track It Compile Log]]. The bin directory should now contain the binary. | ||
+ | |||
+ | == Run track_it == | ||
+ | |||
+ | Create a launch subdirectory and add a track_it.launch file with the following contents. | ||
+ | |||
+ | <pre> | ||
+ | <launch> | ||
+ | <node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" > | ||
+ | <param name="video_device" value="/dev/video0" /> | ||
+ | <param name="image_width" value="320" /> | ||
+ | <param name="image_height" value="240" /> | ||
+ | <param name="pixel_format" value="mjpeg" /> | ||
+ | <param name="camera_frame_id" value="usb_cam" /> | ||
+ | <param name="io_method" value="mmap"/> | ||
+ | </node> | ||
+ | <node name="track_it_node" pkg="follow" type="track_it" output="screen" /> | ||
+ | </launch> | ||
+ | </pre> | ||
+ | |||
+ | From the follow directory enter | ||
+ | |||
+ | eepp@tabor:follow$ '''roslaunch launch/track_it.launch''' | ||
+ | <pre> | ||
+ | ... logging to /home/eepp/.ros/log/7e9b6af0-a2a0-11e1-986c-0001c005f78e/roslaunch-tabor-4077.log | ||
+ | Checking log directory for disk usage. This may take awhile. | ||
+ | Press Ctrl-C to interrupt | ||
+ | Done checking log file disk usage. Usage is <1GB. | ||
+ | |||
+ | started roslaunch server http://tabor:55227/ | ||
+ | |||
+ | SUMMARY | ||
+ | ======== | ||
+ | |||
+ | PARAMETERS | ||
+ | * /usb_cam/image_width | ||
+ | * /usb_cam/video_device | ||
+ | * /rosdistro | ||
+ | * /usb_cam/pixel_format | ||
+ | * /usb_cam/io_method | ||
+ | * /usb_cam/camera_frame_id | ||
+ | * /rosversion | ||
+ | * /usb_cam/image_height | ||
+ | |||
+ | NODES | ||
+ | / | ||
+ | usb_cam (usb_cam/usb_cam_node) | ||
+ | track_it_node (follow/track_it) | ||
+ | |||
+ | ROS_MASTER_URI=http://localhost:11311 | ||
+ | |||
+ | core service [/rosout] found | ||
+ | process[usb_cam-1]: started with pid [4095] | ||
+ | process[track_it_node-2]: started with pid [4096] | ||
+ | usb_cam video_device set to [/dev/video0] | ||
+ | usb_cam io_method set to [mmap] | ||
+ | usb_cam image_width set to [320] | ||
+ | usb_cam image_height set to [240] | ||
+ | usb_cam pixel_format set to [mjpeg] | ||
+ | usb_cam auto_focus set to [0] | ||
+ | [swscaler @ 0xb4612ea0]No accelerated colorspace conversion found. | ||
+ | 1 frames/sec at 1337554297.005945436 | ||
+ | [swscaler @ 0xb4615f80]No accelerated colorspace conversion found. | ||
+ | [swscaler @ 0xb46160e0]No accelerated colorspace conversion found. | ||
+ | [swscaler @ 0xb4616250]No accelerated colorspace conversion found. | ||
+ | [swscaler @ 0xb4616350]No accelerated colorspace conversion found. | ||
+ | [swscaler @ 0xb4616400]No accelerated colorspace conversion found. | ||
+ | [ INFO] [1337554297.209471523]: x: 220 y: 153 r: 29 | ||
+ | [ INFO] [1337554297.211299688]: x: 282 y: 194 r: 57 | ||
+ | Last message repeated 11 times | ||
+ | [swscaler @ 0xb4616430]No accelerated colorspace conversion found. | ||
+ | 23 frames/sec at 1337554297.770509308 | ||
+ | Last message repeated 6 times | ||
+ | [swscaler @ 0xb4616420]No accelerated colorspace conversion found. | ||
+ | [swscaler @ 0xb4616450]No accelerated colorspace conversion found. | ||
+ | [ INFO] [1337554298.147127004]: x: 222 y: 144 r: 35 | ||
+ | [ INFO] [1337554298.148639488]: x: 296 y: 181 r: 82 | ||
+ | [ INFO] [1337554298.459755557]: x: 180 y: 125 r: 68 | ||
+ | </pre> | ||
+ | |||
+ | The following window should pop up. | ||
+ | |||
+ | [[Image:Track_it02.jpg]] | ||
+ | |||
+ | My head appears to be a perfect match for a large orange. Control C when you are done. | ||
+ | |||
+ | == Add the move_it Program == | ||
+ | |||
+ | Repeating much of what we did for the track_it program. Create a new program in the src directory. In this case the [[Move It Program]] named move_it.cpp. | ||
+ | |||
+ | Also add the following line to the end of CMakeLists.txt. | ||
+ | rosbuild_add_executable(move_it src/move_it.cpp) | ||
+ | |||
+ | Do a make in the follow directory. | ||
+ | eepp@tabor:follow$ '''make''' | ||
+ | |||
+ | == Run move_it == | ||
+ | |||
+ | Asumption that roscore is running, in three different terminal windows enter the following commands. | ||
+ | |||
+ | eepp@tabor:~$ rosrun phidgets motor_control_hc | ||
+ | |||
+ | eepp@tabor:follow$ roslaunch follow track_it.launch | ||
+ | |||
+ | eepp@tabor:follow$ rosrun follow move_it | ||
+ | |||
+ | The following also run track_it and follow_it if our current directory is follow. | ||
+ | |||
+ | eepp@tabor:follow$ roslaunch launch/track_it.launch | ||
+ | |||
+ | eepp@tabor:follow$ bin/move_it | ||
+ | |||
+ | == Change Color == | ||
+ | |||
+ | Change to the blueish color using the track_set_it program which has the [[Changing Tracking Color with Messages]] features added. | ||
+ | |||
+ | eepp@tabor:~$ rosrun phidgets motor_control_hc | ||
+ | eepp@tabor:~$ roslaunch follow track_set_it.launch | ||
+ | eepp@tabor:~$ rostopic pub -1 /hue_set geometry_msgs/Point 95 105 100 | ||
+ | eepp@tabor:~$ rosrun follow move_it |
Latest revision as of 14:52, 5 August 2012
Contents
Create Follow
The Follow package will depend on messages, Python, and C++ packages.
eepp@tabor:~$ cd ros_workspace eepp@tabor:ros_workspace$ roscreate-pkg follow std_msgs rospy roscpp Created package directory /home/eepp/ros_workspace/follow Created include directory /home/eepp/ros_workspace/follow/include/follow Created cpp source directory /home/eepp/ros_workspace/follow/src Created package file /home/eepp/ros_workspace/follow/Makefile Created package file /home/eepp/ros_workspace/follow/manifest.xml Created package file /home/eepp/ros_workspace/follow/CMakeLists.txt Created package file /home/eepp/ros_workspace/follow/mainpage.dox Please edit follow/manifest.xml and mainpage.dox to finish creating your package
This will create the follow directory with make files, Doxygen template, a source directory and include directory.
epp@tabor:ros_workspace$ cd follow eepp@tabor:follow$ ls CMakeLists.txt include mainpage.dox Makefile manifest.xml src
manifest.xml will contain the dependencies listed in the package create command.
<package> <description brief="follow"> follow </description> <author>Ed C. Epp</author> <license>BSD</license> <review status="unreviewed" notes=""/> <url>http://ros.org/wiki/follow</url> <depend package="std_msgs"/> <depend package="rospy"/> <depend package="roscpp"/> </package>
Build
Entering a make from the follow directory will create the bin and build directories.
epp@tabor:follow$ make mkdir -p bin cd build && cmake -Wdev -DCMAKE_TOOLCHAIN_FILE=`rospack find rosbuild`/rostoolchain.cmake .. -- The C compiler identification is GNU -- The CXX compiler identification is GNU -- Check for working C compiler: /usr/bin/gcc -- Check for working C compiler: /usr/bin/gcc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Found PythonInterp: /usr/bin/python2.6 [rosbuild] Building package follow [rosbuild] Cached build flags older than manifests; calling rospack to get flags [rosbuild] Including /opt/ros/electric/stacks/ros_comm/clients/rospy/cmake/rospy.cmake [rosbuild] Including /opt/ros/electric/stacks/ros_comm/clients/roslisp/cmake/roslisp.cmake [rosbuild] Including /opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp/cmake/roscpp.cmake -- Configuring done -- Generating done -- Build files have been written to: /home/eepp/ros_workspace/follow/build cd build && make make[1]: Entering directory `/home/eepp/ros_workspace/follow/build' make[1]: Leaving directory `/home/eepp/ros_workspace/follow/build'
build will contain all the make infrastructure specified by CMakeLists.txt file. bin will also be created but will be empty because the src directory is empty and no source files are specified in CMakeLists.txt.
Add the track_it Program
Create a program in the src directory. In this case the Track It Program named track_it.cpp.
Uncomment the genmsg line in CMakeLists.txt.
rosbuild_genmsg()
Also add the following line to the end of CMakeLists.txt.
rosbuild_add_executable(track_it src/track_it.cpp)
The first parameter, track_it, specifies the name of the binary that will go into the bin directory. The second parameter specifies where to find the source.
Add the following dependencies to manifest.xml.
<depend package="sensor_msgs"/> <depend package="opencv2"/> <depend package="cv_bridge"/> <depend package="image_transport"/> <depend package="ihr_demo_bags"/>
Do a make in the follow directory.
eepp@tabor:follow$ make
The compile log will look something like Track It Compile Log. The bin directory should now contain the binary.
Run track_it
Create a launch subdirectory and add a track_it.launch file with the following contents.
<launch> <node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" > <param name="video_device" value="/dev/video0" /> <param name="image_width" value="320" /> <param name="image_height" value="240" /> <param name="pixel_format" value="mjpeg" /> <param name="camera_frame_id" value="usb_cam" /> <param name="io_method" value="mmap"/> </node> <node name="track_it_node" pkg="follow" type="track_it" output="screen" /> </launch>
From the follow directory enter
eepp@tabor:follow$ roslaunch launch/track_it.launch
... logging to /home/eepp/.ros/log/7e9b6af0-a2a0-11e1-986c-0001c005f78e/roslaunch-tabor-4077.log Checking log directory for disk usage. This may take awhile. Press Ctrl-C to interrupt Done checking log file disk usage. Usage is <1GB. started roslaunch server http://tabor:55227/ SUMMARY ======== PARAMETERS * /usb_cam/image_width * /usb_cam/video_device * /rosdistro * /usb_cam/pixel_format * /usb_cam/io_method * /usb_cam/camera_frame_id * /rosversion * /usb_cam/image_height NODES / usb_cam (usb_cam/usb_cam_node) track_it_node (follow/track_it) ROS_MASTER_URI=http://localhost:11311 core service [/rosout] found process[usb_cam-1]: started with pid [4095] process[track_it_node-2]: started with pid [4096] usb_cam video_device set to [/dev/video0] usb_cam io_method set to [mmap] usb_cam image_width set to [320] usb_cam image_height set to [240] usb_cam pixel_format set to [mjpeg] usb_cam auto_focus set to [0] [swscaler @ 0xb4612ea0]No accelerated colorspace conversion found. 1 frames/sec at 1337554297.005945436 [swscaler @ 0xb4615f80]No accelerated colorspace conversion found. [swscaler @ 0xb46160e0]No accelerated colorspace conversion found. [swscaler @ 0xb4616250]No accelerated colorspace conversion found. [swscaler @ 0xb4616350]No accelerated colorspace conversion found. [swscaler @ 0xb4616400]No accelerated colorspace conversion found. [ INFO] [1337554297.209471523]: x: 220 y: 153 r: 29 [ INFO] [1337554297.211299688]: x: 282 y: 194 r: 57 Last message repeated 11 times [swscaler @ 0xb4616430]No accelerated colorspace conversion found. 23 frames/sec at 1337554297.770509308 Last message repeated 6 times [swscaler @ 0xb4616420]No accelerated colorspace conversion found. [swscaler @ 0xb4616450]No accelerated colorspace conversion found. [ INFO] [1337554298.147127004]: x: 222 y: 144 r: 35 [ INFO] [1337554298.148639488]: x: 296 y: 181 r: 82 [ INFO] [1337554298.459755557]: x: 180 y: 125 r: 68
The following window should pop up.
My head appears to be a perfect match for a large orange. Control C when you are done.
Add the move_it Program
Repeating much of what we did for the track_it program. Create a new program in the src directory. In this case the Move It Program named move_it.cpp.
Also add the following line to the end of CMakeLists.txt.
rosbuild_add_executable(move_it src/move_it.cpp)
Do a make in the follow directory.
eepp@tabor:follow$ make
Run move_it
Asumption that roscore is running, in three different terminal windows enter the following commands.
eepp@tabor:~$ rosrun phidgets motor_control_hc
eepp@tabor:follow$ roslaunch follow track_it.launch
eepp@tabor:follow$ rosrun follow move_it
The following also run track_it and follow_it if our current directory is follow.
eepp@tabor:follow$ roslaunch launch/track_it.launch
eepp@tabor:follow$ bin/move_it
Change Color
Change to the blueish color using the track_set_it program which has the Changing Tracking Color with Messages features added.
eepp@tabor:~$ rosrun phidgets motor_control_hc eepp@tabor:~$ roslaunch follow track_set_it.launch eepp@tabor:~$ rostopic pub -1 /hue_set geometry_msgs/Point 95 105 100 eepp@tabor:~$ rosrun follow move_it