Exercise 4.2 - Odometry Subscriber causes all processes to die on machine

Running my launch file for Exercise 4.2, but the odom_subscriber launch fille just immediately ends after running

odom_sub_node (my_examples_pkg/odom_subscriber.py)

process[odom_sub_node-1]: started with pid [25381]
[odom_sub_node-1] process has finished cleanly
log file: /home/user/.ros/log/f875e7de-f97f-11eb-8b29-0242c0a83007/odom_sub_node-1*.log
all processes on machine have died, roslaunch will exit
shutting down processing monitor…
… shutting down processing monitor complete


< launch >
< !-- My Package launch file – >
< node pkg=“my_examples_pkg” type=“move_robot.py” name=“MoveRobot” output=“screen”>
< /node >
< /launch >


< launch >
< !-- My Package launch file – >
< node pkg=“my_examples_pkg” type=“odom_subscriber.py” name=“odom_sub_node” output=“screen” >
< /node >
< /launch >


pub = rospy.Publisher(‘/cmd_vel’, Twist, queue_size=1)
rate = rospy.Rate(2)
var = Twist()
factorX = 0.5
factorZ = 0.5

while not rospy.is_shutdown():
for _ in range(10):
valueX = random()
valueZ = random()
var.linear.x = valueX-factorX
var.angular.z = valueZ-factorZ
print("x: ", var.linear.x)
print("z: ", var.angular.z)
rate.sleep() # Make sure the publish rate maintains at frequency

Not sure what is wrong. I am running another concurrent launch file move_robot that is automatically moving the robot around to generate odometry so I can get live odom data in this exercise.

Hi, welcome back to the community!

That error of immediately ending might be an error with your node itself. What happens when you try to run the node outside of the launch file?

rosrun my_examples_pkg odom_subscriber