SJSU-Robotic / ros-curriculum

ROS Curriculum for SJSU Robotics Team - Intelligent Systems Division
MIT License
4 stars 8 forks source link

masonEngineer47 ros-track #4

Open ntwong0 opened 4 years ago

ntwong0 commented 4 years ago

Upcoming

Curriculum

Capstone

ntwong0 commented 4 years ago

Reposting:

Follow-up on your CMakeLists.txt for beginner_tutorials,

rospy nodes need fewer modifications [ref]

...
# add the following catkin_install_python() call to ensure 
# 1. the Python script is installed properly, and
# 2. the correct Python interpreter is used
# even then, these scripts are 
catkin_install_python(PROGRAMS scripts/talker.py scripts/listener.py
  DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
...

…while roscpp nodes need several modifications [ref]

...
## Find catkin and any catkin packages
find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs genmsg)
...
## Generate added messages and services
generate_messages(DEPENDENCIES std_msgs)
...
## Explicitly identify talker node's main cpp file
add_executable(talker src/talker.cpp)
## Specify the talker executable as the library link target
target_link_libraries(talker ${catkin_LIBRARIES})
## Specify dependencies for the talker executable
add_dependencies(talker beginner_tutorials_generate_messages_cpp)

## Do the same as talker for listener
add_executable(listener src/listener.cpp)
target_link_libraries(listener ${catkin_LIBRARIES})
add_dependencies(listener beginner_tutorials_generate_messages_cpp)

It looks like rospy handles many of these compilation steps at runtime through the interpreter (i.e. message generation). Even then, it seems that the catkin_install_python() can be optional - with respect to Python assets, there seems to be no difference in the build/ and devel/ folders whether this call is commented out or not.