rolandash pim 1 of USB2 and pin2 of J3 are connected. And I double checked the USB2. It is giving 5V on VCC. I think my last measurement was wrong.

    zhanghaijason I tried method 2 and used /dev/ttyAMA0, not USB0, now it seems working, the ROS can get the FCU heartbeat. I will try offboard mode to see if it is really working or not.

      zhanghaijason

      To use Telem1 for onboard computer, make sure telem1 baud rate setting is the same as in Raspi side.
      Seems in later px4 firmware version you do not need to change source code to set that. You can set in QGC through parameter:
      SER_TEL1_BAUD
      on the fly.

        6 days later

        rolandash Hi sorry for the delay. It worked once. I tried 3 or 4 times with offboard hovering. Only succeed once (Everytime, It could switch to offboard (If I publish the local position with ROS before switching mode), but only took off and hovered once.) I don't know it is because I am using raspi 3A+ (less powerful) or not. I will receive some raspi 3B+ tomorrow and will experiment more.

          rolandash I can switch to offboard, because the green LED blinked when I switch. However, I use a mavros etpoint_position/local topic to publish desired local position (0,0,0.7). The drone won't take off and hover. And I saw a massage from mavros says "No local position". So I am wondering if the distance sensor and optical flow can publish local position or not (or may be not fast enough, it is only 10hz in GCS). I uploaded one of such logs: https://review.px4.io/plot_app?log=01cd4714-6b13-45f0-ad20-c65ca3478ce5 I also tried telem2, same result. I may need to ask mavros developers to see what should be the possible reason. Thanks.

          I tried two more times and now it can take off. one crashed and one succeed. I am just confused why it is kind of unreliable.

            is the uploaded log a successful takeoff or failure?

            Do you always get "no local position" message even when success?

              rolandash The log is a failure. The drone didn't take off at all on this log. When I succeed, I didn't see 'no local position'. I think it might be the problem of the optical flow and distance sensor positioning system. Because when I tried with Optitrack for positioning. It worked well.

                zhanghaijason
                As the discussion is more related to PMW3901 so I will move to that thread to continue instead of getting this unrelated post too long...

                  3 months later

                  rolandash Just pay attention as no flow control line on Telem2 so mind your data rate setting not to exceed the processing speed of CPU on both side

                  Hi Roland, recently when I fly the drone with offboard mode, the drone loses offboard command very often. The error in mavros is : "Failsafe enabled: No offboard". The ros rate I set is 100 and the topic (mavros/setpoint_raw/attitude) buffer size is 5, 1 or 10 (I changed to different sizes to see it it can solve it). And i am using Telem2 by removing R34. Is what you said the reason why the failsafe always be enabled?

                  And I also tried to use Telem1, however, when I change mav_1_config to telem1, reconnect the USB to mindracer. I cannot see mav_1_mode, mav_1_forward, mav_1_rate (can be seen if change mav_1_config to telem2). And when i use the motion tracking system, the topic mavros/local_position/pose is published very slowly with wrong numbers (The output from motion tracking system is relayed to mavros/vision_pose/pose, it is correct).

                    rolandash It has been 3 weeks I think. This error will not appear every time.

                    But when I first succeed the offboard using setpoint_raw/attitude to hover it, there is no such an issue. As I increased my code to do more tasks (basically step 1 hover at position 1, step2 go to hover position 2, step 3 use pi camera to do some image processing at hover position 2 and adjust yaw angle accordingly, and finally step4 move upward to the goal position), it appears. It appeared in every step, but most likely in step 2 and step 3, which making me can only do less than 20 experiments for the whole afternoon.

                      zhanghaijason
                      OK I see.

                      From what you described the messages did seem lost, but not because the reason you quoted.
                      I think it is very likely your software in Pi are missing incoming messages. When you do image processing the Pi processor is occupied and have no time slot for receive UART incoming messages, that is why ros topics been published very slowly and out of order.
                      I think you may need to optimize your pi code so that it always have a chance to handle incoming messages from UART, even in middle of image processing. Try to multi-thread it and see if any improvement.

                        rolandash Hi Roland, I have the following questions related to this issue
                        1. I have tested the image processing frequency, it is usually at least 40HZ, and after every image processing, I will use the output from images to send the desired yaw angle and other attitude setpoints to control the drone. So I think theoretically it should be fast enough. And the losing rapi information also occurs before the image processing stage where I only take images and send attitude setpoints.

                        1. I tried to simply publish position command and it won't lose onboard signal. And I also update the firmware to 1.11.0. With the latest firmware, the drone will definitely lose raspi information at the begging of my task. I tested 5 times I think, and this losing signal occurs at the beginning where only take images (without processing) and send attitude setpoints. Sometimes it can regain the signal and finish the task (including image processing) or lose signal again. Since losing signal occurs 100% after the firmware update, I am wondering if it is related to the firmware or not. May using older firmware like 1.9.X help? And for the firmware, With the newer firmware, the mavros will not report the error anymore, but it still loses signal.

                        2. I will certainly go through my code to see what is exactly causing the problem. I may try multi-thread last since I am totally new to this.

                        Thanks for your help.

                          zhanghaijason

                          Can you please upload a illustration of your system setup including drone, rasPi, and ROS machine, the connection in between, and the software components installed as well? a handcraft will be good enough, so I can better understand the situation.

                          thanks.

                            rolandash
                            Hi Roland, I failed to upload the pic so I share it through google drive https://drive.google.com/file/d/1DvEXXpXnRFS4InUIgzG88MbvlkpcNXdW/view?usp=sharing

                            Is it good to you? Thanks

                            And I tried to change the code a little bit. It seems working, but I only did 2 tests. Then the mindracer got reset again even I followed you suggestion to modify the firmware using the SD card. I will do more tests tomorrow

                              zhanghaijason

                              I got the picture.

                              I forgot to mention that you may need to resize the picture before uploading to avoid too large size, recommended like 800x600.
                              This forum does not do auto-resize :-(

                                zhanghaijason

                                The output from motion tracking system is relayed to mavros/vision_pose/pose

                                How is your motion tracking system connected with the drone?

                                  rolandash Hi Roland, I followed this tutorial https://risc.readthedocs.io/1-indoor-flight.html,
                                  motion tracking system software is running on a windows machine and broadcast through WIFI to raspberry pi. The raspberry pi sends the local position to mindracer through telem2 and mavros I think.

                                  And the internet quality is not as good as before in my university these days. I am wondering is it because the bad wifi signal? In that case, the local_position is not updated fast enough, then the mindracer will consider there is no local_position information, and exit the offboard mode.