dynamixel_motor icon indicating copy to clipboard operation
dynamixel_motor copied to clipboard

Joint_controller Services listen before everything is initialized

Open maxired opened this issue 12 years ago • 6 comments
trafficstars

When launching Position joint controller and the other package of my robot on a board with few ressources, the program crash at launch with error :

AttributeError: JointPositionController instance has no attribute 'MIN_VELOCITY'

Looking at the code, it looks like the services are up and running from joint_controller but the velocity parameters are set later in the initialize method in the joint_position_controller

Do you think of any way to prevent this ?

maxired avatar Nov 22 '13 09:11 maxired

Hi, could you post the full error with line numbers where this fails? One solution would be to move Service initializations into the initialize method of joint_controller and call that in the subclasses before doing the controller specific initializations. Could you see if that fixes your problem?

arebgun avatar Nov 22 '13 15:11 arebgun

Hi,

here is the stack track that you asked.

Traceback (most recent call last):
  File "/opt/ros/groovy/lib/python2.7/site-packages/rospy/impl/tcpros_service.py"  , line 619, in _handle_request
    response = convert_return_to_response(self.handler(request), self.response_class)
  File "/root/ros_pkg/dynamixel_motor/dynamixel_controllers/src/dynamixel_controllers/joint_controller.py", line 145, in process_set_speed
    self.set_speed(req.speed)
  File "/root/ros_pkg/dynamixel_motor/dynamixel_controllers/src/dynamixel_controllers/joint_position_controller.py", line 133, in set_speed
    mcv = (self.motor_id, self.spd_rad_to_raw(speed))
  File "/root/ros_pkg/dynamixel_motor/dynamixel_controllers/src/dynamixel_controllers/joint_position_controller.py", line 123, in spd_rad_to_raw
    if spd_rad < self.MIN_VELOCITY: spd_rad = self.MIN_VELOCITY
AttributeError: JointPositionController instance has no attribute 'MIN_VELOCITY'
[ERROR] [WallTime: 1385408836.222017] Error processing request: JointPositionController instance has no attribute 'MIN_VELOCITY'

I added a sleep in the bash script launching my stack, this help to recude the problem, but from time to time this still happen.

What you suggest may work most of the time, can't we have sometimes the same problem ? I believe this should be done in the Start method, just after topic declaration

maxired avatar Nov 25 '13 17:11 maxired

Hi,

Putting the Service declarations in the start method seems reasonable too. Does this fix this problem? Could you make a pull request with necessary changes if it does? Thanks!

arebgun avatar Dec 03 '13 19:12 arebgun

I was having the same problem as @maxired and, if I am following you guys, putting the Service declarations in the start method seems to be working for me. I have created my own fork and will submit a pull request after I track down the cause of another error I am getting at startup that I will post as a separate issue.

pirobot avatar Dec 10 '13 01:12 pirobot

Patrick, could you submit a pull request for this issue if you have it fixed on your end?

arebgun avatar Feb 13 '14 23:02 arebgun

Sorry for the delay--for the life of me I can't find my branch files where I made the fix. However, in the meantime, I haven't seen this error in a long time so maybe it got fixed another way?

pirobot avatar Mar 03 '14 06:03 pirobot