ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange

# How can I correct the problem in a simple question

Recently, I learnt on ros_ignite. I just start learning on topics.

The slogan is: Create a package with a launch file that launches the code simple_topic_publisher.py. Modify the code you used previously to publish data to the /cmd_vel topic. Launch the program and check that the robot moves. 1.- The /cmd_vel topic is the topic used to move the robot. Do a rostopic info /cmd_vel in order to get information about this topic, and identify the message it uses. You have to modify the code to use that message.

2.- In order to fill the Twist message, you need to create an instance of the message. In Python, this is done like this: var = Twist()

3.- In order to know the structure of the Twist messages, you need to use the rosmsg show command, with the type of the message used by the topic /cmd_vel.

4.- In this case, the robot uses a differential drive plugin to move. That is, the robot can only move linearly in the x axis, or rotationaly in the angular z axis. This means that the only values that you need to fill in the Twist message are the linear x and the angular z.

5.- The magnitudes of the Twist message are in m/s, so it is recommended to use values between 0 and 1. For example, 0'5 m/s.

Here is the given code, but there is a problem:

move_robot.py

import rospy
from geometry_msgs.msg import Twist

rospy.init_node('move_robot_node')
pub = rospy.Publisher('/cmd_vel', Twist, queue_size=1)
rate = rospy.Rate(2)
move = Twist()
move.linear.x = 0.5 #Move the robot with a linear velocity in the x axis
move.angular.z = 0.5 #Move the with an angular velocity in the z axis

while not rospy.is_shutdown():
pub.publish(move)
rate.sleep()


move_robot.launch

<launch>
<node pkg="exercise_21" type="move_robot.py" name="move_robot_node" output="screen" />

</node>
</launch>


package.xml

<?xml version="1.0"?>
<package>
<name>exercise_21</name>
<version>0.0.0</version>
<description>The exercise_21 package</description>
<maintainer email="user@todo.todo">user</maintainer>

<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<run_depend>roscpp</run_depend>
<run_depend>rospy</run_depend>
<run_depend>std_msgs</run_depend>

<export>
</export>
</package>


Problem is:

user:~/catkin_ws\$ roslaunch exercise_21 move_robot.launch
... logging to /home/user/.ros/log/d040bc5e-6476-11e8-88f0-065a2c6c1cb0/roslaunch-ip-172-31-47-59-17102.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

Invalid roslaunch XML syntax: mismatched tag: line 4, column 6
The traceback for the exception was written to the log file


How can I correct the problem?

edit retag close merge delete

You should make short question that the answer is for eliminating single problem at a time.

( 2018-05-30 22:11:58 -0500 )edit

Sort by ยป oldest newest most voted

This error indicates that there is a syntax error in your launch file: Invalid roslaunch XML syntax: mismatched tag: line 4, column 6

"mismatched tag" in XML means that you have a close tag (starts with </) that the XML parser wasn't expecting. In this case, you've closed the node tag twice: once by using a self-closing tag (<node/>) and again with an explicit close tag on line 4, where the parser pointed out your error (</node>).

You should change your launch file so that you either use matching open and close tags ( <node> and </node> ) or use the self-closing tag ( <node/> )

I suggest

<launch>
<node pkg="exercise_21" type="move_robot.py" name="move_robot_node" output="screen" />
</launch>

more

Thank you! You are right. But when I changed the .launch file. A new problem occurred... It is said: ERROR: cannot launch node of type [exercise_21/move_robot.py]: can't locate node [move_robot.py] in package [exercise_21] I tried to solve it by chmod +x move_robot.py

( 2018-05-31 03:45:53 -0500 )edit

But a new problem occurred again, it is : Unable to launch [move_robot_node-1]. If it is a script, you may be missing a '#!' declaration at the top. The traceback for the exception was written to the log file. Could you please tell me how to solve this one?

( 2018-05-31 03:47:17 -0500 )edit
1

I solved problems in move_robot.py. I omitted the #! /usr/bin/env python in python file. I used to think it is useless.

( 2018-05-31 04:31:35 -0500 )edit

## Stats

Asked: 2018-05-30 21:16:25 -0500

Seen: 1,007 times

Last updated: May 30 '18