How to construct CMakeLists.txt for Snap creation?

asked 2020-10-28 08:46:15 -0500

Py gravatar image

I am trying to create a Snap of a ROS package. When I run snapcraft, this is successful but when I launch the Snap I get the following error:

RLException: [manual_operation.launch] is neither a launch file in package [contamination_mapping] nor is [contamination_mapping] a launch file name
The traceback for the exception was written to the log file

This makes me wonder if there is a problem with my CMakeLists.txt file or my snapcraft.yaml file. Both are pasted below.

CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)

project(robot_brain)

cmake_policy(SET CMP0054 OLD)

find_package(catkin REQUIRED COMPONENTS
        roscpp
        rospy
        std_msgs
        gazebo_ros
        cartographer_ros
        rosbridge_server
        gazebo_ros REQUIRED
        )

catkin_package(
        INCLUDE_DIRS include
        LIBRARIES ${PROJECT_NAME}
        CATKIN_DEPENDS
        roscpp
        rospy
        std_msgs
        gazebo_ros
        cartographer_ros
        rosbridge_server
)

include_directories(
        ${Boost_INCLUDE_DIR} ${catkin_INCLUDE_DIRS} ${GAZEBO_INCLUDE_DIRS}
)

link_directories(
        ${GAZEBO_LIBRARY_DIRS}
)

catkin_install_python(PROGRAMS
        src/scripts/node_script_a.py
        src/scripts/node_script_b.py
        src/scripts/node_script_c.py
        src/scripts/node_script_d.py
        DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

install(DIRECTORY launch/
        DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
        PATTERN ".svn" EXCLUDE)

snapcraft.yaml

name: robot-brain
version: '0.1'
summary: ROS package.
description: |
  This ROS package is a robot brain.

confinement: devmode
base: core18
grade: devel

parts:
  brain:
    plugin: catkin
    source: https://github.com/user/robot-brain.git
    source-branch: master

apps:
  robot-brain:
    command: roslaunch ros_package robot_brain_operation.launch    
    plugs: [network, network-bind]

Can anybody spot any errors?

Thanks!

edit retag flag offensive close merge delete

Comments

https://github.com/user/robot-brain.git is of course not real so I don't know this for sure, but the source for the catkin plugin needs to be a ROS workspace, where various packages are contained within a src subdirectory (by default). If that repository doesn't meet that requirement, you could have issues. You might want to consider using a rosinstall file instead. For example, use source: . in the plugin and then alonside the snap folder create a my-stuff.rosinstall file pointing at your repo. Then update the brain part to have rosinstall-files: [my-stuff.rosinstall]. Then snapcraft will create a workspace and merge that in for you.

kyrofa gravatar image kyrofa  ( 2020-10-28 14:15:18 -0500 )edit

Thanks very much. I'm just giving this a try (i.e. run snapcraft).... it seems to be taking a long time. Is this expected? The message being shown is:

Initializing workspace (if necessary)...
Merging /root/parts/part-a/src/my_package_snap.rosinstall
Updating workspace...
Py gravatar image Py  ( 2020-10-29 06:55:35 -0500 )edit

It's hitting the network and downloading stuff at that point. Regarding how much time I would expect it to take, it really depends on how many repos are in the rosinstall file, how big they are, and what kind of network connectivity you have.

kyrofa gravatar image kyrofa  ( 2020-10-29 12:36:15 -0500 )edit