It builds well. However when I try to run the package like this:
ros2 run testpackage test_node
it says no executable found.
Is there something like roscore in ros2 to have the ROS_MASTER and ros services running? I have sourced install/local_setup.bash as given in the tutorials.
I have built using the command = ament build --symlink-install --only-package testpackage
Also i realised, my library is not created inside install/lib/.
Your CMake installs you binary to bin, but ros2 run only looks in the “libexec” folder (actually lib/pkg) for executables. Your binary is just on the PATH, so you don’t need ros2 run to easily execute it.
Also, I realized when I run my executable like ros2 run testpackage test_node … and then do ros2 node list. It shows me the right name. However, when I exit my program (Ctrl+C) I still happen to find my ros2 node if I do a ros2 node list. The instance continues to be there which is sometimes also seen in ROS 1 if a large number of nodes are running however not for just one node.
Another point is my topic names. Even after exiting my running executable ros2 topic list still, shows the topic names. I changed the topic names in my program and built it again and ran it, however, the topic names weren’t changed or I don’t know if it’s the old instance running. Regardless of that, I tried killing the node by ros2 node kill --all however seems like that is not the command to kill anymore.
For me it works for the demo_nodes_cpp / demo_nodes_pytalker and listener using FastRTPS on Ubuntu using Beta 3. Maybe you can provide more information what environment / version / nodes you are experiencing it with.
When I try this ros2 topic pub /test_topic std_msgs/String "hello"
It throws me this:
Traceback (most recent call last):
File "/home/artc/ros2_ws/install/bin/ros2", line 9, in <module>
load_entry_point('ros2cli==0.0.0', 'console_scripts', 'ros2')()
File "/home/artc/ros2_ws/install/lib/python3.5/site-packages/ros2cli/cli.py", line 64, in main
rc = extension.main(parser=parser, args=args)
File "/home/artc/ros2_ws/install/lib/python3.5/site-packages/ros2topic/command/topic.py", line 38, in main
return extension.main(args=args)
File "/home/artc/ros2_ws/install/lib/python3.5/site-packages/ros2topic/verb/pub.py", line 43, in main
return main(args)
File "/home/artc/ros2_ws/install/lib/python3.5/site-packages/ros2topic/verb/pub.py", line 47, in main
return publisher(args.message_type, args.topic_name, args.values)
File "/home/artc/ros2_ws/install/lib/python3.5/site-packages/ros2topic/verb/pub.py", line 78, in publisher
set_msg_fields(msg, values_dictionary)
File "/home/artc/ros2_ws/install/lib/python3.5/site-packages/ros2topic/verb/pub.py", line 92, in set_msg_fields
for field_name, field_value in values.items():
AttributeError: 'str' object has no attribute 'items'
Did you try passing a yaml dictionnary as the help message suggests? ros2 topic pub /test_topic std_msgs/String "data: Hello World"
Copied from:
usage: ros2 topic pub [-h] topic_name message_type [values]
Publish a message to a topic
positional arguments:
topic_name Name of the ROS topic to publish to (e.g. '/chatter')
message_type Type of the ROS message (e.g. 'std_msgs/String')
values Values to fill the message with in YAML format (e.g. "data:
Hello World"), otherwise the message will be published with
default values
Ah yeah the space is not obvious given that the help message wraps the line just after the :. That tricked me recently as well. The error message has been improved recently to make it clearer that a YAML dictionary is expected.
This has been brought up recently but it hasn’t been decided yet if metapackages should exist as ament packages or if they should be stored in a central place given that they are for producing binaries only and should not be used as dependencies