dji-sdk / Onboard-SDK-ROS

Official ROS packages for DJI onboard SDK.
443 stars 309 forks source link

3.3 dji_sdk/flight_control_setpoint_generic control referece to 3.1/3.2 /drone->attitude_control(0x0a, y,x,z,yaw); #142

Closed snakehaihai closed 6 years ago

snakehaihai commented 7 years ago

Can I check with you, this dji_sdk/flight_control_setpoint_generic works like typical RC just that control by serial, right? Is it in stable mode? I tried to control this using Logitech joystick. but hard seems only have altutude control. In 3.1/3.2 we were using attitude_control function call with mode 0x0a. Can hold position indoor very well with lidar feedback. whats the difference in the new topic based control node in terms of flight control mode?how is it referred to the old way of control? I feel the default lightbridge RC flight is quite stable. how can I sent command to drone using API to control as stable as lightbridge RC flight? If can u using either touch screen or logitech joystick to control it as stable as light bridge RC contorl. then i can interface easily with vision based or lidar based guidance program.

zliDJI commented 7 years ago

As the name indicates, the topic dji_sdk/flight_control_setpoint_generic will cover whatever is capable by the attitude_control function, and cover more modes (such as commanding roll/pitch rates), based on the flag you provide.

I'll suggest that you read our ros wiki for details: http://wiki.ros.org/dji_sdk#Subscribed_Topics

And more details about possible flags: http://wiki.ros.org/dji_sdk#Details_on_flight_control_setpoint

For your question about interface with your guidance program, you can use sdk to read the RC stick, and send control through API.

snakehaihai commented 7 years ago

I see from the API

So I didn`t set it joy[4] which means default 0x00. means its default mode. the output i get is I only have throttle control. although pitch and yaw are bettween -1 to 1 input. but there is no response on the drone.

0x00 Command roll and pitch angle Ground/Body 0.611 rad (35 degree
0x00 Command the vertical speed Ground -5 to 5 m/s

since I only feel vertical throttle control. is that means I have to publish another control say update x y on 0x40 mode?

Say for autonomous mode, there is more than 3 command which is executed at the same time. what should i do? For example, if I issue throttle z adjust to main UAV at my set point from the help of my vicon/camera/lidar by using command 0x00. Then if issue a yaw pitch command to adjust x y position by calling 0x40. will the later one override the previous command? since position feedback->action are usually issue at the same time. and the previous pub only executed for like 50us? how to execute 4 commands at all time? like the previous control drone->attitude_control?

The new api confuse me a bit. since traditional robotics gays just publish to 1 topic called /cmd_vel and all parameters are updated at the same time to a lower driver(either apm sort of or converter to sabertooth sort of).

zliDJI commented 7 years ago

We don't use the px4 way to generate the command, which takes the horizontal, yaw, and vertical channel separately. Here you have to send the roll pitch yaw, thrust commands in a single message.

snakehaihai commented 7 years ago

I understand it not px4 way. I`m sending command to /dji_sdk/flight_control_setpoint_generic (sensor_msgs/Joy). controlVelYawRate.axes.push_back(y); controlVelYawRate.axes.push_back(x); controlVelYawRate.axes.push_back(z); controlVelYawRate.axes.push_back(yaw); ctrlBrakePub.publish(controlVelYawRate);

i can see my topic from rostopic echo dji_sdk/flight_control_setpoint_generic I didn`t set joy[4] which by default is 0x00.
x y z yaw are from either my PID control node or Logitech joystick However, i only feel throttle control. The pitch and roll control are missing. When I take off, drone slide to the wall and i have no control over x and y direction. the only control i have is the z.

  1. Why would it happen?
  2. say if I want to first have full control it from Logitech joystick, what should I do?
  3. does it take gps to fly in this 0x00 mode? I`m testing indoor without GPS. does that affect drone?
zliDJI commented 7 years ago

Could you send the following command in a terminal in simulation? This will publish at 20Hz, with constant roll angle 5 degree, and z speed 0.5, until you hit ctrl+c

rostopic pub -r 20 /dji_sdk/flight_control_setpoint_generic sensor_msgs/Joy "header:
  seq: 0
  stamp:
    secs: 0
    nsecs: 0
  frame_id: ''
axes:
- 0.0
- 5.0
- 0.5
buttons:
- 0"

You'll need to first call the rosservice call /dji_sdk/sdk_control_authority "control_enable: 1" to obtain control, and then call rosservice call /dji_sdk/drone_task_control "task: 4" to take off.

snakehaihai commented 7 years ago

how to run dji simulation one? never tried. saw you guys have one in the dji assistant in the windows. does ubuntu have 1 as well?

zliDJI commented 7 years ago

Simulation option is turned on using DJI Assistant 2 on Windows or Mac.

snakehaihai commented 7 years ago

tested. works in simulation. will try with actual flight.

snakehaihai commented 7 years ago

tried. in the simulation have the response. in actual no response. is my value given too small? Is there any way for me to see what kind of command it is receiving. ack from A3. not the set point from /dji_sdk/flightcontrol...generic

when

0x40 Command horizontal velocities Ground/Body 30 m/s

is called. for joy[0] and joy[1] is it remapped between -1 to 1? or should i put it -30 to 30? oso for throttle, i already tried scale with 1, 10, 100, 1000, 10000 which all dont seems to have effect in make it fly

more details. I tried to mapped Logitech joy to lightbridge RC. in simluation, the stick movement to drone angle is similar between those 2 control method. I can verified in the dji assistant.

However in the actual flight, my command from logitech barely have any effect. beside throttle down, which will cut power to prop

will record a video to show

1st video shows that in simulation everything works. and all channel max rate is similar between Lightbridge RC and Logitec joy input. https://drive.google.com/open?id=0BxGBtcQP0EL7dVJQUWg0NTNNODA

2st video shows that same command that works in the simulation doesn't work. can't even take off. however, the going down with throttle down does work. https://drive.google.com/open?id=0BxGBtcQP0EL7MVNLcHF2VE13SGs

the flag i was using was uint8_t flag = (DJISDK::VERTICAL_VELOCITY | DJISDK::HORIZONTAL_VELOCITY | DJISDK::YAW_RATE | DJISDK::HORIZONTAL_BODY //| //DJISDK::STABLE_ENABLE );

https://github.com/dji-sdk/Onboard-SDK-ROS/issues/140 has same issue is also. in simulation every authority works. swich to F mode no matter in obtain or release API mode, RC always can by pass. but in reality. it is not working, simulation and actualy flight are much different.Even I switch to F mode by pass API control, i can not regain control in RC. But in terminals, every error message appear to be the correct.

Are you guys sure that simulator drone and actual A3 drone code are the same?

zliDJI commented 7 years ago
  1. You should take off before publishing to flight control topics.
  2. You are using horizontal velocity, while in door there is no gps and so you don't have reliable velocity as feedback.

You want to verify if the flightcontrol...generic topic is working in real flight, I think a definitive way to verify that is to:

  1. take your drone to a safe outside place, better tethered from below for safety.
  2. write a small piece of code, such that, when you hit a button on your logitech joy, or flip the "H" switch on the LB2 RC, the code will send a constant small angle command at 20 Hz for 1 second and release sdk control or land.
  3. take off and obtain control before you start your code in 2.

Thanks!

snakehaihai commented 7 years ago

You should take off before publishing to flight control topics. You are using horizontal velocity, while in door there is no gps and so you don't have reliable velocity as feedback.

don't dare to do that anymore. this drone was tether and fly like that b4. 80degree sideway flying. very scary. and F mode bypass is not working #140 . true. will change another control flag and try

take your drone to a safe outside place, better tethered from below for safety. write a small piece of code, such that, when you hit a button on your logitech joy, or flip the "H" switch on the LB2 RC, the code will send a constant small angle command at 20 Hz for 1 second and release sdk control or land.

not really safe. since we had plenty of crash experience due to the high wind on the roof top, that's what i did b4. for 3.1 build. I can take off even with logitech joystick. but now i cant

this drone can work indoor. no gps needed at all. there are plenty of high-value task with the risk of magnetic or EMP interference. which deny the usage of pure GPS hold. even from what I observed, phantom 4 gps hold is more like IMU based hold running in high frequency. averaging feedback GPS hold running in low frequency. and drift can be quite high.

if you dont believe i can show you another video that we did. indoor position hold and navigation with 2X hokuyou lidar A3 on oldest 3.1 build. The control was achieved by calling /drone->attitude_control(0x0a, y,x,z,yaw);, we have no problem in flying in 20mX300m fully covered metal container even with top fully covered, Thats why i was asking for similar control method as 3,1 /drone->attitude_control with flag 0x0a

Problem is right now is I need to improve performance. say from +-5cm in position hold error. to +-1 cm in position hold error. To do that I need high fps IMU for visual - inertial based navigation and lidar-inertial based navigation testing. previous 3.1 cant do this.

can u help suggest a similar method in 3,3 which works like 3,1 /drone->attitude_control with flag 0x0a

zliDJI commented 7 years ago

uint8_t flag = (DJISDK::VERTICAL_VELOCITY | DJISDK::HORIZONTAL_VELOCITY | // --> change to DJISDK:: HORIZONTAL_ANGLE DJISDK::YAW_RATE | DJISDK::HORIZONTAL_BODY //| //DJISDK::STABLE_ENABLE

snakehaihai commented 7 years ago

k, will try it when i go to the lab. so as far as i can understand, a3 need the internal reference to execute the command, angle is using IMU. make sense. will get back to you later

snakehaihai commented 7 years ago

tested it is woking solution is -> change to DJISDK:: HORIZONTAL_ANGLE, interesting to see why horizontal will affect vertical operation, But there is still a problem of emergency by pass issue, switch to F mode while api is still obtaining control will cause both api and rc to lose control. how to solve that?

snakehaihai commented 7 years ago

does DJISDK::STABLE_ENABLE required GPS? its IMU based or GPS based?

snakehaihai commented 7 years ago

dji error insufficient payload..then uav go to full throttle and pitch back mode, F mode by pass not working, API by pass not working. how to solve this

snakehaihai commented 6 years ago

add more payload. change mode to PAG then dont pub in main loop. can already