I keep running into this error:
malformed launch argument 'topic_publisher.launch.py', expected format '<name>:=<value>'
after running this command to launch:
user:~/ros2_ws/src$ ros2 launch topic_publisher_pkg topic_publisher.launch.py
I’m not sure what the issue is. I just used the launch file from Unit 2 as a guide and changed the file names as needed, so I am not sure what I did wrong.
Here is my topic_publisher.launch.py file:
from launch import LaunchDescription
import launch_ros.actions
def generate_launch_description():
return LaunchDescription([
launch_ros.actions.Node(
package='topic_publisher_pkg',
executable='simple_publisher_node',
output='screen'),])
here is my CMakeList.txt file:
cmake_minimum_required(VERSION 3.5)
project(topic_publisher_pkg)
# Default to C99
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# uncomment the line when a copyright and license is not present in all source files
#set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# uncomment the line when this package is not in a git repo
#set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()
add_executable(simple_publisher_node src/simple_topic_publisher.cpp)
ament_target_dependencies(simple_publisher_node rclcpp std_msgs)
install(TARGETS
simple_publisher_node
DESTINATION lib/${PROJECT_NAME}
)
# Install launch files.
install(DIRECTORY
launch
DESTINATION share/${PROJECT_NAME}/
)
ament_package()
and the simple_topic_publisher.cpp file which is copied from the instructions:
#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/int32.hpp"
int main(int argc, char * argv[])
{
rclcpp::init(argc, argv);
auto node = rclcpp::Node::make_shared("simple_publisher");
auto publisher = node->create_publisher<std_msgs::msg::Int32>("counter", 10);
auto message = std::make_shared<std_msgs::msg::Int32>();
message->data = 0;
rclcpp::WallRate loop_rate(2);
while (rclcpp::ok()) {
publisher->publish(*message);
message->data++;
rclcpp::spin_some(node);
loop_rate.sleep();
}
rclcpp::shutdown();
return 0;
}