RIVeR-Lab / epos_hardware

Other
12 stars 39 forks source link

Could not find motor #22

Closed ndalmedico closed 5 years ago

ndalmedico commented 6 years ago

Hi, firstly, I have seen the other 'Could not find motor' thread, but it did not help me. I have been using the package on (ROS Indigo/Ubuntu 14.04) to control the position of an EC brushless motor (number 118889) and everything was working fine, but a week ago the package could not find my motor anymore, apparently with no changes to my yaml, urdf or launch files. I suspect it was a software update but I'm not able to say which software.

I then tried to install the package in an older ubuntu pc I have and it worked on first try. The old ubuntu 14.04 was kernel 4.2.0-42-generic, while the 14.04 in my regular pc is 4.4.0-116-generic. To determine if it really was an update I updated the software and the kernel of the old ubuntu (using ubuntu's software updater), and it stopped being able to find the motor as well. Then, I did the logical step of downgrading the regular pc to the 4.2.0 kernel, but it still could not find the motor. I have tried compiling in a new catkin workspace and giving USB permissions every step. I don't know what else I should try, is it possible that some software update made the package not work anymore? Or is downgrading not as effective as I think it is? How could I proceed to debug this further?

Any response should be useful, thanks in advance :)

OliEfr commented 6 years ago

Hello, i ran in the same issue as well (Thread doesn't help, no kernel-version helps). I keep on trying and will share my results in case of success.

Greetings

ndalmedico commented 6 years ago

Hi, did some more testing with a virtual machine. The indigo version really stops being able to find motors only when the ubuntu 14.04 is completely updated, some old versions work as expected. The kinetic version of the package still works, including with the new version Ubuntu 16.04.4.

Since I already had to upgrade my project to 16.04 I solved my problem, so I recommend it for everyone having this trouble, but people that have to use the 14.04 should install an outdated iso and turn off updates until this is fixed :/

I will leave this thread open until the authors help us find a way to make it work again on updated 14.04

OliEfr commented 6 years ago

I am pretty much a newbe here. I got kinetic running on ubuntu 16.04 and it is not working work. What to you mean by 'kinetic' versionof the package. According to ros_wiki, there is only indigo. I cloned the indigo-repo and builded it manually. Or is there another way to get it to kinetic?

Thanks so long. Help much appreciated.

JimmyDaSilva commented 6 years ago

Hi @OliEfr , here on GitHub there is an unreleased version of the package for kinetic. To access it you just need to change the GitHub branch to kinetic-devel

OliEfr commented 6 years ago

Great! I cloned kinetic-devel and runned example.launch ... but unfortunately the same error "Could not find motors" occurred. For me it seems like a problem with the controller-spawner, because the "could not find motors" error is not declared in epos_hardware pkg IMHO.

ndalmedico commented 6 years ago

The 'could not find motor' error is in the epos.cpp file. Run 'rosrun epos_hardware list_devices' with the motor connected in USB to see if list_devices can inform the motor serial number, if it finds, check the yaml, urdf and launch file to see if everything is set up with the right parameters

It may also be the USB permission, you can type 'sudo chmod 777 -R /dev/tty*' to get permission, then try list_devices and example.launch again

OliEfr commented 6 years ago

Thanks- at least I found the Error in epos.cpp.

But already set-up permissions. Running list_devices i get "Could not get port names: Bad Parameter"

My EPOS4 status LED is blinking green.

Btw the HelloEposCmd.cpp is working. Just not the epos_hardware package.

ndalmedico commented 6 years ago

Blinking green is how it is supposed to be. Don't know what might it be then.

When you type 'lsusb' it lists the EPOS FTDI connection?

OliEfr commented 6 years ago

Running lsusb or lsinput lists the port and that something is connected, but doesn't display any name for the connection. Much like no device would be connected. I tried on 2 PCs. When i connect it via CAN-USB to my pc i experience the same problem - nothing is detected with list_devices.

Windows though, recognises the device via USB as EPOS4.

ndalmedico commented 6 years ago

Strange, try reconfiguring the motor on epos studio. Other than that I dont know what might be the problem, since ubuntu have ftdi drivers by default. lsusb should be showing 'future technologies', 'epos' or something similar :/ I'd suggest trying it on a clean ubuntu to be sure.

OliEfr commented 6 years ago

I tried everything out with epos studio - everything works finde. I updated the firmware of EPOS4 controller just to be sure. I tried it with 3 Ubuntus now: on 1 it works and on 2 not. All basically having same software packages.

When i ran 'dmesg | grep USB' i get: ... usb 2-1.3: new full-speed USB device number 8 using ehci-pci
usb 2-1.3: New USB device found, idVendor=24e7, idProduct=3b01
usb 2-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-1.3: Product: EPOS4
usb 2-1.3: Manufacturer: maxon motor ag
usb 2-1.3: SerialNumber: 00000000
hid-generic 0003:24E7:3B01.0004: hiddev0,hidraw0: USB HID v1.11 Device [maxon motor ag EPOS4] on usb-0000:00:1d.0-1.3/input0 ...

and lsusb -v also shows Manufactur: Maxon, Product: EPOS4.

So actually the EPOS controller IS recognised by the system. But still not with lsusb.

grafoteka commented 6 years ago

Hi @OliEfr did you finally get the motor the motor work? I have the same error for CANopen connection. I can run the Maxon example (HelloEposCmd.cpp) without any problem, but in ROS I got the error:

[ERROR] [1526632900.958318393]: Could not find motor
[ERROR] [1526632900.958367949]: Could not configure motor: my_joint_actuator
[FATAL] [1526632900.958392468]: Failed to initialize motors
OliEfr commented 6 years ago

Hi @grafoteka , unfortunately no. BUT: i ended up using the CANOpenLibrary for Python, which of course can be easily integrated into ros: http://canopen.readthedocs.io/en/latest/ This library works like charm! You have to connect your PC to the CAN Network for example via Socketcan (PCAN ...), in order to get can-communication. PythonCanopen allows you to use CANOpen (including .eds, sod, mnt, pdo ...........) I can provide you with example code for the EPOS4 Controller if you wish. In order to find out, which sdo or pdo requests to send to move the Motor, you should take a look in the application guide for your Epos Controller. PAY ATTENTION: You should implement a manual delay in python (ros.sleep() or whatever) of about 15ms between sending sdo requests to the Motor (the Motor Needs responds time, espacially after switching in enabled mode).

If you have any further questions, feel free to ask.

Greetings Oli

grafoteka commented 6 years ago

Hi @OliEfr , thank you for your answer. It would be a good idea to try to use CANOpenLibrary, I don't know python, but I would do the effort. Yes, my PC is connected to the CAN Network via an IXXAT adapter. It is in the direction CAN0. Your example code would be helpful.

Kinds regards, Jorge

OliEfr commented 6 years ago

Ok. Here you find application guide: http://academy.maxonjapan.co.jp/wp-content/uploads/manual/epos4/EPOS4-Application-Notes-Collection-En.pdf I used page 5-50 in my example (PPM).

Here is my ros--python code. It's so easy. If you run it, the motor should move a bit.

 #!/usr/bin/env python3

 import rospy
 import can
 import canopen
 import std_msgs
import os,sys
from struct import *

    def main():

rospy.init_node('maxon_control', anonymous=True)
current_time = rospy.Time.now()
print("initialized maxon motor control node ...")

network = canopen.Network()

# Add node with corresponding Object Dictionaries
node = network.add_node(31, '.../epos4_maxon.eds')

#connect to network
    #socketcan (this works fine for me ater connecting to socketcan)
network.connect(bustype='socketcan', channel='can0')            
# network.connect(bustype='ixxat', channel=0, bitrate=250000)   #ixxat (never tried this one)

    #this has to be executed just once, in order to set motor in enabled
node.sdo.download(0x6040, 0, b'\x06\x00')
node.sdo.download(0x6040, 0, b'\x0F\x00')
rospy.sleep(0.03)                                                           #wait 30ms to get in enabled mode

    #you can put this in a loop or callback to move the motor as you wish
   #node.sdo.download(0x6081,0, b'\xE8\x0A\x00\x00')    #you can set desired velocity if you want
node.sdo.download(0x607A, 0, b'\xFF\xF3\x00\x00')   #set target position
node.sdo.download(0x6040, 0, b'\x7F\x00')
node.sdo.download(0x6040, 0, b'\x0F\x00')

   #read statusword
statusword = node.sdo[0x6041].raw
print(statusword)

network.disconnect()
   if __name__ == '__main__':
try:
    main()
except rospy.ROSInterruptException:
    pass 
grafoteka commented 6 years ago

Thank you for the information OliEfr, I am trying to configure all the CANopen and SocketCan for ROS, but still continue trying with package too.

I continue following the code and I think that the error is in utils.cpp line 180:

if(!(handle = CreateDeviceHandle(device_name, protocol_stack_name, interface_name, port_name, error_code))){
    return 0;
}

I try to insert it manually:

  if(!(handle = CreateDeviceHandle("EPOS", "CANopen", "CAN_ixx_usb 0", "CAN0", error_code))){
    ROS_INFO("Error in CreateDeviceHandle");
    return 0;
  }

And unfortunately I got the message: Error in CreateDeviceHandle

grafoteka commented 6 years ago

@OliEfr with the ros--python code are you able to control the position/velocity of the motor and get it position?

Jorge

OliEfr commented 6 years ago

Yeah, it is possible

grafoteka commented 6 years ago

@OliEfr have you controlled the motors in velocity profile? or just in position?

I can't move them in velocity.

OliEfr commented 6 years ago

In both i think, you can show me your code If you want.

Jorge De León Rivas notifications@github.com schrieb am Do., 28. Juni 2018, 09:32:

@OliEfr https://github.com/OliEfr have you controlled the motors in velocity profile? or just in position?

I can't move them in velocity.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RIVeR-Lab/epos_hardware/issues/22#issuecomment-400940393, or mute the thread https://github.com/notifications/unsubscribe-auth/AdrskNyOFvNT7qiupYdhv1yQvjHusA4Mks5uBIZ2gaJpZM4SVla0 .

grafoteka commented 6 years ago

@OliEfr do you mind if we talk in this ros question? Just because we are talking from another package.

Or in this one.

Thank you

ndalmedico commented 5 years ago

Closing this issue since it's been open for a few months now and I got around the problem upgrading to 16.04, I don't think many people will use 14.04 anymore meaning this issue will hardly be useful again.