ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to rosmake and run roslisp talker and listener successfully?

asked 2012-08-13 03:55:34 -0600

sam gravatar image

updated 2012-08-13 23:38:41 -0600

I followed roslisp/Overview/Installation and Roslisp Basic Usage.

I run:

  roscreate-pkg sam_begin_lisp roslisp roslisp_runtime
  cd sam_begin_lisp/
  mkdir src

y src/talker.lisp:

  (in-package :sam_begin_lisp)

  (defun talker ()
    "Periodically print a string message on the /chatter topic"
    (with-ros-node ("talker")   
      (let ((i 0) (pub (advertise "chatter" "std_msgs/String")))
        (loop-at-most-every .1
           (publish-msg pub :data (format nil "foo ~a" (incf i)))
        )
      )
    )
  )

My src/listener.lisp

  (in-package :sam_begin_lisp)

  (defun listener ()
    (with-ros-node ("listener" :spin t)
      (subscribe "chatter" "std_msgs/String" #'print)
    )
  )

My CMakeLists.txt:

  cmake_minimum_required(VERSION 2.4.6)
  include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

  # Set the build type.  Options are:
  #  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
  #  Debug          : w/ debug symbols, w/o optimization
  #  Release        : w/o debug symbols, w/ optimization
  #  RelWithDebInfo : w/ debug symbols, w/ optimization
  #  MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries
  #set(ROS_BUILD_TYPE RelWithDebInfo)

  rosbuild_init()

  #set the default path for built executables to the "bin" directory
  set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
  #set the default path for built libraries to the "lib" directory
  set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

  #uncomment if you have defined messages
  #rosbuild_genmsg()
  #uncomment if you have defined services
  #rosbuild_gensrv()

  #common commands for building c++ executables and libraries
  #rosbuild_add_library(${PROJECT_NAME} src/example.cpp)
  #target_link_libraries(${PROJECT_NAME} another_library)
  #rosbuild_add_boost_directories()
  #rosbuild_link_boost(${PROJECT_NAME} thread)
  #rosbuild_add_executable(example examples/example.cpp)
  #target_link_libraries(example ${PROJECT_NAME})
  rospack_add_lisp_executable(bin/talker sam_begin_lisp sam_begin_lisp:talker)
  rospack_add_lisp_executable(bin/listener sam_begin_lisp sam_begin_lisp:listener)

When I rosmake, it shows:

  sam@/home/sam/code/ros/lisp/sam_begin_lisp$ rosmake
  [ rosmake ] No package specified.  Building ['sam_begin_lisp']                                                                                              
  [ rosmake ] Packages requested are: ['sam_begin_lisp']                                                                                                      
  [ rosmake ] Logging to directory/home/sam/.ros/rosmake/rosmake_output-20120813-214948                                                                       
  [ rosmake ] Expanded args ['sam_begin_lisp'] to:
  ['sam_begin_lisp']                                                                                         
  [ rosmake ] Checking rosdeps compliance for packages sam_begin_lisp.  This may take a few seconds.                                                          
  [ rosmake ] rosdep check passed all system dependencies in packages                                                                                         
  [rosmake-0] Starting >>> roslib [ make ]                                                                                                                    
  [rosmake-0] Finished <<< roslib ROS_NOBUILD in package roslib                                                                                               
  [rosmake-1] Starting >>> rosbuild [ make ]                                                                                                                  
  [rosmake-1] Finished <<< rosbuild ROS_NOBUILD in package rosbuild
   No Makefile in package rosbuild                                                          
  [rosmake-2] Starting >>> std_srvs [ make ]                                                                                                                  
  [rosmake-2] Finished <<< std_srvs ROS_NOBUILD in package std_srvs                                                                                           
  [rosmake-3] Starting >>> sbcl [ make ]                                                                                                                      
  [rosmake-1] Starting >>> roslang [ make ]                                                                                                                   
  [rosmake-3] Finished <<< sbcl ROS_NOBUILD in package sbcl                                                                                                   
  [rosmake-1] Finished <<< roslang ROS_NOBUILD in package roslang
   No Makefile in package roslang                                                             
  [rosmake-0] Starting >>> std_msgs [ make ]                                                                                                                  
  [rosmake-0] Finished <<< std_msgs ROS_NOBUILD in package std_msgs                                                                                           
  [rosmake-1] Starting >>> roslisp [ make ]                                                                                                                   
  [rosmake-1] Finished <<< roslisp ROS_NOBUILD in package roslisp                                                                                             
  [rosmake-1] Starting >>> roslisp_runtime [ make ]                                                                                                           
  [rosmake-1] Finished <<< roslisp_runtime ROS_NOBUILD in package roslisp_runtime                                                                             
  [rosmake-1] Starting >>> sam_begin_lisp [ make ]                                                                                                            
  [ rosmake ] Last 40 linesm_begin_lisp: 1.1 sec ]                                                                                  [ 1 Active 9/10 Complete ]
  {-------------------------------------------------------------------------------
    make[3]: Entering directory `/home/sam/code/ros/lisp/sam_begin_lisp/build'
    Scanning dependencies of target rospack_genmsg_libexe
    make[3]: Leaving directory `/home/sam/code/ros/lisp/sam_begin_lisp/build'
    [  0%] Built target rospack_genmsg_libexe
    make[3]: Entering directory `/home/sam/code/ros/lisp/sam_begin_lisp/build'
    Scanning dependencies of target rosbuild_precompile
    make[3]: Leaving directory `/home/sam/code/ros/lisp/sam_begin_lisp/build'
    [  0%] Built target rosbuild_precompile
    make[3]: Entering directory `/home/sam/code/ros/lisp/sam_begin_lisp/build'
    Scanning dependencies of target _roslisp_bin_talker
    make[3]: Leaving directory `/home/sam/code/ros/lisp/sam_begin_lisp/build'
    make[3]: Entering directory `/home/sam/code/ros/lisp/sam_begin_lisp/build'
    [  0%] Generating ../bin/talker ...
(more)
edit retag flag offensive close merge delete

Comments

I don't see what causes the problem, maybe you can first try out rosmake for the tutorial source code, by checking out from svn: svn checkout https://code.ros.org/svn/ros/stacks/roslisp_support/trunk/roslisp_tutorials

KruseT gravatar image KruseT  ( 2012-08-13 04:16:38 -0600 )edit

To be able to help we will need a little more information: can you please add the contents of your .asd file and your package definition (usually in the file package.lisp)?

Lorenz gravatar image Lorenz  ( 2012-08-13 06:40:59 -0600 )edit

I revised my original post to add few src. And roslisp_tutorials package is pass the rosmake.

sam gravatar image sam  ( 2012-08-13 22:29:55 -0600 )edit

You still have sam_begin_lisp somewhere in in-package. It should be (in-package :sam-begin-lisp)

Lorenz gravatar image Lorenz  ( 2012-08-13 23:42:31 -0600 )edit

Thank you~I find it. It is in CMakeLists.txt.

sam gravatar image sam  ( 2012-08-13 23:54:32 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2012-08-13 22:49:38 -0600

Lorenz gravatar image

updated 2012-08-14 01:44:06 -0600

You are missing #:common-lisp in the use section of your package definition and you must not use #:roslisp_runtime. Another issue is that you don't export the symbols TALKER and LISTENER although you use them in the CMakeLists.txt. It should be something like that:

(defpackage sam-begin-lisp
  (:nicknames :first-package)
  (:use #:common-lisp #:roslisp)
  (:export talker listener))

You then need to change your asd file to use your new, renamed package:

rospack_add_lisp_executable(bin/talker sam-lisp-system sam-begin-lisp:talker)
rospack_add_lisp_executable(bin/listener sam-lisp-system sam-begin-lisp:listener)

Btw. it is really uncommon to use rosmake while developing a lisp node. Rather, people use the REPL to interactively develop their code. That makes debugging much easier because you get backtraces that show where an error happened.

Try the following:

rosrun roslisp_repl repl

This will start up an emacs instance with a lisp shell. Then inside the lisp shell in emacs, run:

(ros-load:load-system "sam_begin_lisp" :sam-lisp-system)
(in-package :sam-begin-lisp)
(talker)

If the first line of the lisp commands above should fail, please copy-paste the complete backtrace to this question.

Now the talker should be running in lisp. You can check in a terminal with

rostopic echo /chatter

In the lisp repl, press Ctrl-c Ctrl-c and then click on abort. That shuts down the talker. Then execute in the lisp repl:

(listener)

Execute in a terminal:

rostopic pub /chatter std_msgs/String 'foo' -r 1

Now you should receive data in the lisp shell. After all of these steps worked, you can call rosmake again and it should not error out anymore. Then you can use your lisp wrapper binaries from the command line.

edit flag offensive delete link more

Comments

I can't see 'foo' string on listener of emacs. But I can see that on 'rostopic echo /chatter '. Is that correct? Thank you~

sam gravatar image sam  ( 2012-08-14 00:01:22 -0600 )edit

I also find typo errors on this answer. Should I point out? Thank you~

sam gravatar image sam  ( 2012-08-14 00:07:59 -0600 )edit

The listener should actually show something if it is running. It could be a problem with multi-threading though. Try: 'cp rospack find roslisp_repl/swank.lisp ~/.swank.lisp' (note there is a . at the beginning of the destination file). And sure. I'll fix all the typos you found.

Lorenz gravatar image Lorenz  ( 2012-08-14 00:13:39 -0600 )edit

The type I found: '#:commin-lisp' -> '#:common-lisp', 'in-package :sam_begin_lisp' -> 'in-package :sam-begin-lisp'. And the last comment's 'lsitener' -> 'listener'. I also want to thank you for so detail describe.

sam gravatar image sam  ( 2012-08-14 00:26:36 -0600 )edit

Great~~ I try 'cp `rospack find roslisp_repl`/swank.lisp ~/.swank.lisp' success!! Thank you~

sam gravatar image sam  ( 2012-08-14 00:32:33 -0600 )edit

Question Tools

Stats

Asked: 2012-08-13 03:55:34 -0600

Seen: 530 times

Last updated: Aug 14 '12