dji-sdk / RoboMaster-SDK

DJI RoboMaster Python SDK and Sample Code for RoboMaster EP.
Apache License 2.0
311 stars 142 forks source link

Push Notifications vs Events. #19

Open brunoga opened 4 years ago

brunoga commented 4 years ago

I am trying to figure out how exactly this all should work but without success. When I send something like:

gimbal push attitude on;

to the robot, I get an ok reply but it does not look like I am receiving anything either via port 40924/udp (Message push) or 40925/tcp (Event reporting). WHere should I get those messages? Are they being sent at all?

nanmu42 commented 4 years ago

Push and event are working well, give this a try:

https://github.com/nanmu42/robo-playground#drive-your-robomaster-using-keyboard

Push and event will appear in console logs: https://github.com/nanmu42/robo-playground/blob/7654497072ae11e84124a7e6b37f5ab472d7f159/drive.py#L174

brunoga commented 4 years ago

Push and event are working well, give this a try:

https://github.com/nanmu42/robo-playground#drive-your-robomaster-using-keyboard

Push and event will appear in console logs: https://github.com/nanmu42/robo-playground/blob/7654497072ae11e84124a7e6b37f5ab472d7f159/drive.py#L174

Yep, it was a bug on my code in the end. Still the documentation could be improved. As it is now, it is a bit confusing.

Anyway, I am also writing a framework for the SDK but using Go instead of Python. You might be interested in taking a look at it although it is not even close to be as feature complete as robomasterpy. Go Robomaster Framework

nanmu42 commented 4 years ago

Cool, take my star.

brunoga commented 4 years ago

So, it looks like there is no explicit use of the "Event reporting" endpoint in the API at all so I wonder what it is for. Everything seems to use push notifications ("Message push").

What is it supposed to be used for?

nanmu42 commented 4 years ago

Have a look at armor hit and sound applause.

brunoga commented 4 years ago

Have a look at armor hit and sound applause.

I did not implement the Armor or Applause stuff yet in my framework but, from the documentation (against, translated form chinese to english so that might be the issue) it looks like those are push events (see highlighted parts):

3.2.6.3. Reporting control of armor plate events IN: armor event

description Control the reporting of armor plate detection events See event reporting data format armor plate event reporting data parameter attr ( armor_event_attr_enum): Event attribute name switch ( switch_enum): Event attribute control switch Examples armor event hit on;: open the armor plate detection event push 3.2.6.4. Data reporting for armor plate incidents OUT: armor event hit

description When an armor plate tapping event occurs, this message can be received from the event push port parameter [...]

nanmu42 commented 4 years ago

drive.py has used all these stuffs, you may try and see.

brunoga commented 4 years ago

drive.py has used all these stuffs, you may try and see.

Oh, don't take me wrong, I believe what you are saying. I just wanted to make a point that the documentation is confusing in this respect.