-
-
Notifications
You must be signed in to change notification settings - Fork 9
Reference (ROS)
Jason Wang edited this page Sep 25, 2022
·
1 revision
ROS is very simple, its just been over complicated by the website
catkin_ws/
src/ # Contains the repositories you clone into the folder
build/ # Contains intermediate build steps used by ROS only
devel/ # Contains include paths, executables, shared libraries, and source script that is built by the source code
log/ # Not used
You need python-catkin-tools, you can install it using sudo apt-get install python-catkin-tools
catkin build # Builds all the packages in the src/ folder
catkin clean # Automatically deletes the build/ devel/ and log/ folder
catkin build soccerbot # builds the soccerbot package inside the src/ folder
# and recursively all the dependencies that the package.xml file references
catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release # Builds all the source code on release mode
source devel/setup.bash # Adds all the packages that you built before using catkin build to your $PATH you can can run things
- Inside the package.xml, there are multiple tags, all of them are not relevant and only provide information about the package. But please edit the file
- Ensure that the name
<name>soccer_communication</name>
is correct - Ensure that
<package format="2">
is format 2 - Add
<buildtool_depend>catkin</buildtool_depend>
, needed for all package.xml files - Add the dependencies
<depend>dep</depend>
, you can replace dep with any package inside the workspace, or you can add a system dependency here
To make sure all your packages and package dependencies are in order
cd ~/catkin_ws
rosdep install --from-paths src --ignore-src -r -y
# This will install all extra dependencies into the $ROS_PACKAGE_PATH (/opt/ros/kinetic/) and system dependencies using apt
cmake_minimum_required(VERSION 2.8.3) # Required
project(soccer_transforms) # The name of the package, must be the same as package.xml <name> property
add_compile_options(-std=c++11) # Optional
find_package(catkin REQUIRED COMPONENTS # Required to be a catkin package,
roscpp # the components must be also found in the <depend> tag of the package.xml
std_msgs
soccer_msgs
)
catkin_package() # Declares this package as a catkin package
include_directories( # include is a folder inside the package, ${catkin_INCLUDE_DIR} includes
include # all the include folders used in the find_package components.
${catkin_INCLUDE_DIRS} # include folders can ONLY contain header files
)
# Creates a single C++ node instance. The Node is found in src/node.cpp and is named node, it depends on the catkin exported targets and its own exported targets (executables), and depends on the LIBRARIES that are added in find_package
add_executable(node src/node.cpp)
add_dependencies(node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(node ${catkin_LIBRARIES})
# Creates a single Python node instance. The node is found in scripts/pythonscript.py
install(PROGRAMS
scripts/pythonscript.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
ROS Workspace (catkin_ws)
ROS Package 1 (soccer-control)
ROS node 1 (soccer-control-head)
ROS subscriber 1 - ROS topic A (headmessage (string))
ROS subscriber 2 - ROS topic B (trajectory (int))
ROS publisher 1 - ROS topic A (headmessage (string))
ROS publisher 2 - ROS topic B (trajectory (int))
ROS service 1 # Do not use
ROS service 2 # Do not use
ROS client 1 # Do not use
ROS client 2 # Do not use
ROS node 2
ROS Package 2
- Subscribers -> Publishers (include a "topic_name_string" and a ROS Message type)
- Services -> Clients (include a "topic_name_string" and a ROS Service type)
Debugging commands
rosnode list # Lists all nodes
rostopic list # Lists all topics
rosmsg list # Lists all messages
rosnode info nodename # Gets information about nodename
rostopic info topicname # Gets information about topic name
rosmsg info msgname # Gets information about message name
Found in packagename/launch/launchfile.laucnh
<launch>
# Running a node in the current package
# givennodename can be anything, runs the nodename in the packagename
<node name="givennodename" pkg="packagename" type="nodename" />
# Referencing another launch file
<include file="$(find packagename)/launch/launchfilename.launch" />
# Using arguments into another launch file
<include file="$(find packagename)/launch/launchfilename.launch">
<arg name="argname" value="argvalue" />
</include>
# Using params given by another launch file, this argument will set this node name to argname
<arg name="argname" default="argvalue" />
<node name="$(arg argname)" pkg="packagename" type="nodename">
</launch>
To launch a roslaunch file, make sure you sourced your workspace (see above in catkin tutorial) then run
roslaunch packagename launchfilename.launch
- use for viewing active topics
Just type in rqt into the command line, you can use the plugins tools above to be able to conveniently
- Publish messages
- Publish services
- View the TF tree (which tells you the network of frames of references)
- View the ROS log console (Which outputs things that are printed using ROS_INFO_STREAM, ROS_WARN_STREAM in the individual ROS nodes
Very useful tool in visualizing what the robot is seeing, Either put in into your launch file or just type rviz
- View Camera input
- View World objects
- View the TF Tree and it in 3D
- View Computer Vision Scans and Maps
- View other robots (in the future)
- $ROS_IP is an environmental variable that tells the $ROS_MASTER_URI what is the IP of the device connecting to the $ROS_MASTER_URI
- $ROS_MASTER_URI tells you which device that has the roscore running for all the ros commands to connect to
These need to be put into your .bashrc file to tell the system what are you connecting to
catkin build --verbose --catkin-make-args run_tests