SDK or API
5704 13 2021-5-27
Uploading and Loding Picture ...(0/1)
o(^-^)o
ceinem
lvl.1

Germany
Offline

Hi,
I'm wondering, has anyone managed to get the R SDK for the RS2 working?
I've been banging my head on this for the past few weeks.
It's implemented as a CAN bus to interface with the gimbal and the documentation and sample code are not bad, but I just can't get it running.
No actions from the gimbal, no reply CAN messages, nothing.

I also emailed the DJI support, but didn't get a reply.

Did anyone have any luck with this?

Thanks
2021-5-27
Use props
Kamin
lvl.1

Netherlands
Offline

Hi ceinem,

I have the same problem. Have you made any progress?
2021-6-8
Use props
ceinem
lvl.1

Switzerland
Offline

Hi Kamin,
yes, I actually managed to get the gimbal to move, however no response messages yet. So, partial success. I'm in the progress of writing a nicer library and want to put it on GitHub, I'll let you know once I get so far.
2021-6-8
Use props
Kamin
lvl.1

Netherlands
Offline

This is awesome. I am waiting for the result of your work on Github.

But I had a few questions for now:
Which converter do you use? Is it USB CAN-II? (I'm using Seeed USB-Can analyzer)
Do you use a Ronin Focus Wheel or you connect the Can analyzer directly to the DJI RS 2?

Thanks
2021-6-9
Use props
ceinem
lvl.1

Switzerland
Offline

Sure. I'm using a CANUSB by can232.com for now, but am trying to get it working using an Arduino with a MCP2515 CAN-Shield as a Serial-to-CAN-Connection.
The thing is then connected as an slcan interface via socketcan on my Linux machine, which allows easy integration with python.

Yes, am using a Ronin Focus Wheel, but as fas as I know the contacts are only passed through, so it should also be possible without it.
2021-6-9
Use props
ceinem
lvl.1

Switzerland
Offline

A few months later, finally an update. I wrote a ROS package to control the RS2. It provides position and velocity control. You can find it here.
2021-10-21
Use props
djiuser_pq3hvMBRR91E
New

Germany
Offline

Hello all,

could someone share your example codes for this please ?
do I need to use a can-usb cinnector for this ? So if I am basically sendig can signals to gimbal, what is sdk/api doing ?

2021-10-28
Use props
ceinem
lvl.1

Switzerland
Offline

Yes, you need some kind of Can to USB converter, no chance without one. I used a device called canUSB. But I also got it working using an Arduino and a special CAN shield for it.
My Code is implemented using ROS and a CAN package for ROS. Adjusting it for pure python without ROS would be a bit of work, but absolutely doable.

You would have to use the python-can package to receive data from the canUSB adapter, basically replacing the ROS part of my code, and then use parts of my code to be able to send commands/receive feedback.

the SDK/API tells you what CAN signal to send to get the effect you want. Can signals are only lots of hex codes, the SDK tells you which hex code is a position command and how to set a position, or whatever you want to do. furthermore, the SDK tells you how to compute the check_sums for creating valid CAN signals.

I just noticed that using markdown for adding links in my last post didn't work properly, so here you can find my code: https://github.com/ceinem/dji_rs2_ros_controller
2021-10-28
Use props
sleepzero
lvl.1

United States
Offline

ceinem Posted at 2021-10-28 07:23
Yes, you need some kind of Can to USB converter, no chance without one. I used a device called canUSB. But I also got it working using an Arduino and a special CAN shield for it.
My Code is implemented using ROS and a CAN package for ROS. Adjusting it for pure python without ROS would be a bit of work, but absolutely doable.

Thanks for that, super helpful!

I was able to get it working with the USB CAN analyzer +  python-can (hints: frame data size needs to be 8 bytes or less, and a small delay needs to be inserted between each frame.  e.g. 5ms, maybe less, haven't tuned it yet)

Were you able to get the set speed operation to work? I expected to call set speed, then set position, and have the position set at the declared speed, but instead when I call set speed, it immediately sets the position as a delta of 1/2 the speed. e.g. if I set the yaw speed to 3600, it would immediately rotate 180 degrees -- which was -- unexpected.

I realize the set position operation has a time of operation byte, but it seems to be limited. I can't get the arm to move as fast I'd like.

2022-4-26
Use props
ceinem
lvl.1

Switzerland
Offline

Glad my code helps.

As far as I understood the documentation, you can basically only set the speed or the position. If you want it to go to a target position, you can not control the speed, only the "time of operation". If you control the speed of the gimbal, you can not (at least not directly) control the target position. imagine the speed control more like the buttons on a remote.

you could of course using the position feedback of the gimbal, implement a position and speed controller based using only the speed control commands of the API, but I have doubts on how well that would work.

Also, if you call set-speed, it has a timeout attached to it. if you set the yaw speed to 10deg/sec, the gimbal will not rotate for ever. The command times out after some millieseconds or half a second or something. if you want it to rotate continously, you have to keep sending the set speed command.
2022-4-28
Use props
sleepzero
lvl.1

United States
Offline

ceinem Posted at 4-28 02:48
Glad my code helps.

As far as I understood the documentation, you can basically only set the speed or the position. If you want it to go to a target position, you can not control the speed, only the "time of operation". If you control the speed of the gimbal, you can not (at least not directly) control the target position. imagine the speed control more like the buttons on a remote.

I see, so it intentionally works this way.
> you could of course using the position feedback of the gimbal, implement a position and speed controller

Yeah, this is what I'm doing.  Seems to work, but I'll need to fine tune it a lot to get the accuracy I want.

Thanks again!
2022-4-28
Use props
FJ2022
lvl.1

Japan
Offline

Hi,
What cable should I use to connect the Focus wheel to the CANUSB?
Is it available at the DJI store? Or do I have to make it myself?
2022-7-13
Use props
ceinem
lvl.1

Switzerland
Offline

FJ2022 Posted at 7-13 00:55
Hi,
What cable should I use to connect the Focus wheel to the CANUSB?
Is it available at the DJI store? Or do I have to make it myself?

I haven't seen a cable anywhere, had to make my own. on the focus wheel it's a simple dupont connector. I just purchased a cable with a serial connector (which was also used by my CAN adapter), cut it in half and crimped on a dupont connector.

I actually don't know if you need to connect the VCC line, I only connected CAN_H, CAN_L and GND, works fine.
2022-7-13
Use props
FJ2022
lvl.1

Japan
Offline

I have no experience with that kind of thing, but I will try.
Thank you very much.
2022-7-13
Use props
Advanced
You need to log in before you can reply Login | Register now

Credit Rules