I've run into a very strange problem in Exercise 3.2.

When I try to roslaunch the service server and then call its service, I get the error "ERROR: service [/bb8_square_Service] responded with an error: error processing request: 'module' object has no attribute 'publisher'". This was a bug in my move_bb8.py file, where I called rospy.publisher() instead or rospy.Publisher(). The problem is that I've fixed the bug. I can call move_bb8.py directly with rosrun and it works fine. However, when I try to use launch the server with roslaunch unit_3_services start_bb8_move_in_square_service_server.launch and then call the service, I still get the error.

I've tried restarting the kernel and refreshing the page, both with no luck. How can I reset WebShell so it links my current move_bb8.py file rather than the cached one it seems to be using right now?

My move_bb8.py file is as follows:

#!/usr/bin/env python
import rospy
from geometry_msgs.msg import Twist
import time

class MoveBB8():

    def __init__(self):
        self.vel_publisher = rospy.Publisher('/cmd_vel', Twist, queue_size = 1)
        self.rate = rospy.Rate(10)
        self.halt = False

    def shutdownhook(self):
        self.halt = True

    def publish(msg):
        while not self.halt:
            connections = self.vel_publisher.get_num_connections()
            if connections > 0:

    def stop_movement(self):
        cmd = Twist()
        cmd.linear.x = 0
        cmd.angular.z = 0

    def make_movement(self, linear_speed, turn_speed, move_time):
        cmd = Twist()
        cmd.linear.x = linear_speed
        cmd.angular.z = turn_speed


    def move_square(self):
        i = 0
        while not self.halt and i < 4:
            self.make_movement(0.2, 0.0, 2.0)
            self.make_movement(0.0, 0.0, 1.0)
            self.make_movement(0.0, 0.2, 3.5)
            self.make_movement(0.0, 0.0, 1.0)
            i += 1
        rospy.loginfo("Move_BB8: Square complete")
        print("Square complete!")

if __name__ == '__main__':
    rospy.init_node('move_bb8_test', anonymous = True)
    test_object = MoveBB8()

And my service server file is as follows:

#! /usr/bin/env python

import rospy
from std_srvs.srv import Empty, EmptyResponse # you import the service message python classes generated from Empty.srv.
from move_bb8 import MoveBB8

def my_callback(request):
    print "My_callback has been called"
    movebb8_object = MoveBB8()
    return EmptyResponse() # the service Response class, in this case EmptyResponse

my_service = rospy.Service('/bb8_square_Service', Empty , my_callback) # create the Service called my_service with the 
defined callback
rospy.spin() # mantain the service open.

asked 18 Dec '18, 07:18

trevormuraro%40gmail.com's gravatar image

accept rate: 0%

closed 08 Mar, 23:08

marcoarruda's gravatar image

marcoarruda ♦♦

Here's a further wrinkle. I deleted move_bb8.py entirely, then tried running my service again. The service still successfully imported move_bb8, and still returned the same error. I then recreated move_bb8.py, with completely identical contents, in the package's /src folder. The code then worked. I then moved move_bb8.py back to the /scripts folder, and the code still worked.

(19 Dec '18, 08:52) trevormuraro...

WebShell - or worse, something about ROS - appears to be treating the last version of a program file that appeared in /src as the definitive program file, even though the program file has since moved. When I first created move_bb8.py in /scripts, attempts to import it would fail until I moved it to /src. It then continued working after I moved it to /scripts, but then my error correction didn't apply when the file was imported until I moved it back to /src.

(19 Dec '18, 08:52) trevormuraro...

The question has been closed for the following reason "Too subjective and argumentative" by marcoarruda 08 Mar, 23:08

Hello @trevormuraro,

Are you still having this problem?

You might have placed the file in the wrong folder, that could be the reason why it was happening.

Please, let us know if you still need help on it.

permanent link

answered 08 Jan, 11:48

marcoarruda's gravatar image

marcoarruda ♦♦
accept rate: 18%


If by "wrong folder" you mean using the /scripts folder in a package like I was instructed, then I did use the "wrong" folder. That doesn't explain why roslaunch used the version of the code that was last in the /src folder even after that code had been deleted, though.

Shortly after posting this, I worked around the problem by putting my scripts in the /src folder, so I have no idea if the problem is still there.

(09 Jan, 04:09) trevormuraro...

I see, there are few other possibilities, like a problem in the IDE to update the files. Unfortunately it's hard to help in this kind of problem through the forum, since we may take some hours or days to answer, but you can always use the gitter chat, where we use to answer in real time. Thank you for your feedback and sorry for this inconvenience.

(09 Jan, 11:12) marcoarruda ♦♦

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 18 Dec '18, 07:18

question was seen: 315 times

last updated: 08 Mar, 23:08

powered by OSQA