Tag Archives: ur5

CANSEND? CANDO! Controlling gripper motor via handtyping CAN protocol messages (Linux / Steadywin)

I got a gripper from some very nice SteadyWin folks at the boston robotics expo (part of boston robotics week / boston tech week) and finally got it working last week!! going to attach it to the UR5 once I’m done with the mount design.

 

After chatting with the steadywin folks on wechat, I got a link to their wiki.

The relevant pages are

How motor talk = registers

The way these quasi direct-drive (QDD — has small planetary gearbox, not direct drive) brushless DC (BLDC) motors with integrated controllers (driver is built into the housing) work: you write to a register to control the motor and read from the register to get statuses.

On to the practical part:

Hardware setup

The XT30(2+2) consists of the fat motor power wires and two small signal wires. [6]

Plug in the cable, then connect to 1) the power supply and 2) the USBCAN device.

After wiring up the gripper, make sure to also:

** Connect USB CAN to laptop. **

** Turn on power to motor **

Don’t forget the above steps 🙂

Software setup 

I got this working in Linux with the Steadywin motors.

In a nutshell:

$ uv venv
$ uv pip install python-can

$ sudo slcand -o -c -s8 /dev/ttyACM2  # [1]
$ sudo ip link set can0 up txqueuelen 1000 # [2]

# In a new terminal:
$ candump can0 # Listen to all the CAN messages back and forth

CANSEND? CANDO!

Sending CAN commands by hand

The overall flow

Check the motor is talks back and where it thinks it is using #280204 (ask for current position, should get a response from the motor), #21000103FFFFFF (set to position control), #34000101FFFFFF (set position to zero so we don’t get unexpected big movement — this needs to happen while torque is off, and we should get 01 in response, not 00), #00020101FFFFFF (torque on), #14020400040000 (command a position), #00020100FFFFFF (torque off).

The commands I used


cansend can0 001#01                  # ping — confirm it answers
cansend can0 001#02                  # status
cansend can0 001#280204              # read position
cansend can0 001#21000103FFFFFF      # mode = position (0x03, FFFFFF is for padding)
cansend can0 001#280204              # read position
cansend can0 001#34000101FFFFFF      # [3] set position to zero -- should get 01 as response, not 00 ! 
cansend can0 001#280204              # read position
cansend can0 001#00020101FFFFFF      # torque on (0x01)
cansend can0 001#14020400040000      # goal +1024
cansend can0 001#280204              # read position
cansend can0 001#00020100FFFFFF      # torque off (0x00)
cansend can0 001#02                  # check motor still alive. I use this because it's easy to remember

 

SUCCESS!!!!!!!111111!!!

The first high was when the motor actually talked back, the second was when it finally moved !!!!!!!!!!!!111111111!!!!!!!!!!!!!1

Parenthetical Notes

[1] Use sudo dmesg | tail to find the port, you’ll see something like […] ttyACM2: USB ACM device. (See later section on udev for how to fix it so the address doesn’t change each time you plugin the device).

[2] The TX Queue length increases the buffer so that while the motor is still processing a command, incoming commands may not get dropped. AFAIK.

[3] Reading candump. The successful reply looks like the following, where (can0 = the interface, 001 = motor CAN id, [1] for length of message, 01 for message — aka success)

can0  001   [1]  01

[6]  Iif you’re fancy you can terminate the XT30(2+2) data wire in wire ferrules with a crimper, then they fit nicely into the usb can headers)

Interactive UR5 demo: hand-tracking

this was fun and quick !

i need to go clean up the code so the “documentation” post later but here’s a demo

back story

I worked on this short coding challenge for many hours, got nowhere and gave up. Then in the same amount of time got this robot demo working …

Maybe 2 hours setting up a safety plane in ur5, 2 hrs on the actual hand coordinate to robot coordinate code, and 2 hrs taking videos and showing friends heh.

next steps thoughts

honestly with the word salad machine’s help (pointed out I could use servoL, aka giving it velocities, instead of position coordinates moveL) I finished this much faster than I thought and now I’m at a loss as to what to do next (then my brain was like “oh, it was so easy, the only thing it demoed was me not having enough experience to realize how simple it is” thanks brain that’s the whole point of why we’re doing this, to gain more experience)

i could make the code accept z as well (right now it’s limited to a xy plane for safety), add kd (right now if you swing your hand around too fast too many times the robot starts to wildly swing in bigger and bigger circles), try rewriting with moveJ and seeing what happens, make a gripper, switch to a wrist-mount camera, make the robot high-five and fist bump, switch back to small arms and collect sock data (probably the main issue is I should set the small arms up with my desktop instead of my laptop so I’m not having to plug in 6 cables each time to go between ur5 and the desktop arms), giving the robot expressions… putting aside thinking about what tasks are “how to job” since that will sap all the joy out of robots again

i think i was most excited about a robot that could fold my laundry and also do other tasks like put my tools back or sort screws. it’d be fun to have it make me a sandwich. then there’s another category of what other people would enjoy — people find interactive demos fun, and this hand-tracking fell under that.

Hmm, people also find food fun. So perhaps getting the UR5 to make sandwiches should be my next goal!!