Hello Fellow Yuneec Pilot!
Join our free Yuneec community and remove this annoying banner!
Sign up

St16 v1.

The FFplay shows all the parameters of the played video. Connect pi to the camera, start watching with FFplay rtsp://blah-blah-blah. See what it gives. Prepare the same. 3 and 3+ have the same video format.
 
The FFplay shows all the parameters of the played video. Connect pi to the camera, start watching with FFplay rtsp://blah-blah-blah. See what it gives. Prepare the same. 3 and 3+ have the same video format.


I will have to install FFMPEG and try to get the settings like you suggest. I tried getting the settings by playing with VLC but maybe it doesn't show all the settings. On the raspberry pi I'm using VLC to stream video, so maybe I need to switch that to using FFMPEG also?

The current status of trying to emulate the CGO3P from a raspberry pi:
On the ST16: No errors during initialization, but no video is displayed
On the ST10: No errors during initialization, videos is displayed and clear, but has ~2seconds of lag.

Dylan
 
Good news!

The VLC is not suitable for this. There is no chance to avoid the lag due to the buffering.

I'd like to recommend you to use this chain.
FFmpeg to transform your source format to YUYV and to pack it on H.264. v4l2rtspserver to broadcast the signal. Don't expect a lag lower than 0.2-0.3 seconds, this is technologically almost impossible. Precompiled versions in the repos are good or not so. Better is to compile them from scratch. Especially for FFmpeg.

Good luck!
 
Forget to say. You'll need to have v4l2loopback to connect the FFmpeg output with the v4l2rtspserver. There is no way to use it precompiled. This is very highly dependent from the kernel version module. Only copmilation. FFMpeg is not good enough for RTSP.
 
Forget to say. You'll need to have v4l2loopback to connect the FFmpeg output with the v4l2rtspserver. There is no way to use it precompiled. This is very highly dependent from the kernel version module. Only copmilation. FFMpeg is not good enough for RTSP.
I will try to figure it out.
 
Here you can get q500log2kml for Raspberry Pi (from Raspi 3, Raspbian, 32bit). Maybe it is helpful to check commands and responses directly from Raspberry Pi.

br HE

Thanks, I'm not sure I need it but I will take a look.

Below is the webserver.js file I made to emulate the CGO3 responses to commands enough to get through initialization. I installed node.js using "apt-get install node.js" and then run the file using "node webserver.js". Other than node.js the only other thing you need is to create an iptables rule to forward port 80 to 8080 (which is what the webserver is listening on). I will need to add more to it to make it parse commands better it can better respond to anybody's ST16 but this works for testing right now.

Code:
var http = require('http');
var url = require('url');
var prev = 'cmds:';
http.createServer(function (req, res) {

   res.writeHead(200, {'Content-Type': 'text/html'});
   var command = url.parse(req.url).search.slice(1);
   prev = prev + ',' + url.parse(req.url).search.slice(1);

     if (command.includes("SET_TIME")==true) {
        res.end(JSON.stringify({"rval":0,"msg_id":"336", "type":"camera_clock" }));
        command="";
     } else {

 switch(command) {
     case "CMD=INIT_CAMERA":
        res.end(JSON.stringify({"rval":0,"msg_id":"257","param":1,"fw_ver":"1.8.00(E)","cam_mode":"1","status":"vf","iq_type":"1","white_balance":"0","sdfree":"15191040","sdtotal":"15549440","exposure_value":"0.0",
"video_mode":"3840x2160F30","speed_rate":"6M","sharpness":"6","record_time":"0","awb_lock":"0","ae_enable":"1","audio_sw":"1","shutter_time":"60","iso_value":"ISO_1600","photo_format":"dng"}));
//res.end();
        command="";
        break;
     case "CMD=INDEX_PAGE":
        res.end(JSON.stringify({"rval":0,"msg_id":"257","param":"1","fw_ver":"3.2.34(A)","cam_mode":"1","status":"vf","iq_type":"1","white_balance":"0","sdfree":"0","sdtotal":"0","exposure_value":"0.0",
"video_mode":"3840x2160F30","speed_rate":"54M auto","record_time":"0","awb_lock":"0","ae_enable":"1","audio_sw":"1","shutter_time":"30","iso_value":"ISO_3200","photo_format":"jpg" ,"audio_enable":"1","rtsp_res":"720P",
 "photo_mode":"1", "photo_num":"1", "photo_times":"1", "ev_step":"0.000000", "interval_ms":"333","soft_ver":"30234", "cam_scene":"0", "left_time":"0","metering_mode":"2","x_ratio":"0.00","y_ratio":"0.00","layers":"1",
 "pitch":"0", "yaw":"60", "timer_photo_sta":"0" }));
        command="";
     break;

   case "CMD=GET_STATUS":
        res.end(JSON.stringify({"rval":0, "msg_id":1, "cam_mode":"1", "status":"vf","sdfree":"0","sdtotal":"0","record_time":"0","white_balance":"0","ae_enable":"1","iq_type":"1","exposure_value":"0.0",
"video_mode":"3840x2160F30","awb_lock":"0","audio_sw":"1","shutter_time":"30","iso_value":"ISO_3200","photo_format":"jpg", "rtsp_res":"720P", "photo_mode":"1", "photo_num":"1", "photo_times":"1", "ev_step":"0.000000",
 "interval_ms":"333", "cam_scene":"0", "audio_enable":"1","left_time": "0","metering_mode":"2","x_ratio":"0.00","y_ratio":"0.00", "layers":"1", "pitch":"0", "yaw":"60", "timer_photo_sta":"0" }));
        command="";
   break;

   case "CMD=SET_RTSP_VID&Reslution=720P":
      res.end(JSON.stringify({"rval":0,"msg_id":"373"}));
      command="";
   break;

   case "CMD=previous":
         res.end(prev);
         command="";
   break;
   case "CMD=get_bind_state":
      res.end(JSON.stringify({"isbinded":"yes", "binded_client_address":"e0:b6:f5:80:79:69"}));
      command="";
   break;
   case "CMD=request_bind&client_mac_address=e0:b6:f5:80:79:69":
       res.end(JSON.stringify({"result":"ok", "server_mac_address":"1c:bf:ce:d9:aa:d3"}));
       command="";
   break;
   case "CMD=GET_PANORAMA_STATUS":
       res.end(JSON.stringify({"rval":0, "msg_id":"397","all_pic":"8","taken_pic":"0","take_action":"0" }));
       command="";
   break;
   case "CMD=GET_FW_VERSION":
       res.end(JSON.stringify({"rval":0,"msg_id":"11","brand":"YUNEEC","model":"CGO3+","YUNEEC_ver":"3.2.34(A)","api_ver":"2.8.00","fw_ver":"Jan 11 2017 11:47:55","app_type":"sport","logo":"/tmp/fuse_z/app_logo.jpg",
"chip":"S2E(A9S)","http":"disable","Lens":"LianChuang2","soft_ver":"30234"}));
       command="";
   break;

   default:
        //prev = url.parse(req.url).search;
       res.end();
     command="";
     break;
   }
}
}).listen(8080);
 
  • Like
Reactions: Vaklin
I found 3reasons why ST16 reports "Failed to initialize camera", one regarding SYNC_TIME and the other two with INDEX_PAGE. I do not really understand the code but this may be a hint. Did you made time synchronization?

BTW: My CGO3 (w/o +) connects to ST16 as CGO3. It only say "Camera firmware is too old, Please upgrade it first!" but it can be ignored. With CGO3PRO the CGO3 will be rejected.

br HE
 
I found 3reasons why ST16 reports "Failed to initialize camera", one regarding SYNC_TIME and the other two with INDEX_PAGE. I do not really understand the code but this may be a hint. Did you made time synchronization?

BTW: My CGO3 (w/o +) connects to ST16 as CGO3. It only say "Camera firmware is too old, Please upgrade it first!" but it can be ignored. With CGO3PRO the CGO3 will be rejected.

br HE

I'm not getting the "Failed to initialize camera" messages at all anymore with the code I posted. I'm just not getting any video to display. The reply to the "SET_TIME" command is just a generic response, so right now my code just ignores the value of the time the ST16 sends and replies {"rval":0,"msg_id":"336", "type":"camera_clock" }. I'm not sure what could be wrong in the "INDEX_PAGE" response but it seems to be working for me. So far as the "Camera firmware is too old.." message, I was getting that with my code until I added the response to the "GET_FW_VERSION" command now i'm not getting it anymore ( on the "About Controller" menu it shows the firmware version of the camera now, where before it said "NULL").

As far as I can tell, the ST16 seems to mostly tell the difference between the CGO3 and CGO3+ by the WIFI name. If I name my access point CGO3P_xxxxx, then I get the wrong camera selected message when I select the CGO3, and when I name it CGO3_xxxxxx then I get that error message when I select the CGO3Pro camera. The GET_FW_VERSION also reports the type of camera, but I was getting the wrong camera type selected message even before replying to that command.
 
Forget to say. You'll need to have v4l2loopback to connect the FFmpeg output with the v4l2rtspserver. There is no way to use it precompiled. This is very highly dependent from the kernel version module. Only copmilation. FFMpeg is not good enough for RTSP.

I'm googling all of this but I'm finding this to be really confusing.

I have installed v4l2rtspserver and 4l2loopback, but their usage is confusing. It seems like I can stream using only v4l2rtspserver so I don't know what why I need v4l2loopback or ffmpeg at all. Some instructions I have found make it seems like I need to use v4l2compress, which is part of v4l2tools, in conjunction with v4l2loopback, but I can't get v4l2tools to compile.

I have also tried this method of setting up a low latency stream:

but that also seems to have a ~2sec lag.
 
v4l2loopback is a middle point where you will put/get the stream. v4l2rtspserver is the final point, from where you'll broadcast.

Sample chain:

Camera YUYV pixel format -> FFmpeg input - some FFmpeg filters and so on -> FFmpeg output H.264 -> to loopback !!! -> RTSP server from loopback.

In the point between FFmpeg input and FFmpeg output you can do something useful (logo, subtitles, time, some text...)

Without a loopback device, you can't stream from FFmpeg output to server input.

Simple example
 
The software for Raspberry Pi to control a car or boat by ST10 or ST16 is ready and it works.....
Would you like to save some of my time? What is the path for the "Gimbal calibration" command from the ST16 to the H? Via SR or Wifi?
I'm preparing a GB203 bracket mounted on a CGO3+ gimbal. The last situation is tilted and overcompensated roll. The rest looks acceptable from the start-up initialization after powering. Still not tested with a copter. I have no spare upper top mount with a connector.
 
The Menuitem on the ST16 will be activ if only drone is connected, no camera. You can start gimbal cali and there is no error message. That's why I think the gimbal will be controlled by drone over serial connection, not WiFi.

br HE
 
  • Like
Reactions: Vaklin
Via the SR. Confirmed. Unfortunately, the calibration starts but doesn't complete. All the commands work (pan, tilt) but the camera holder stays tilted (roll axis) on one of the final positions. Not exactly to the hard stop, but near. If I try to move it with my hand, it tilts on the other side. On the middle point (horizontal) it tends to swing. The IMU is placed in the best position from the mechanical approach, so should find a solution to calibrate it with the gimbal. Encoders are OK, for the main PCB and the IMU I have no idea. They're salvaged from the trash bin.

I'll seat to read 6050 pdf...

Any recommendations and ideas about the tilted bracket are welcome. I'll don't discuss is right or not, but will take it into account.
 
  • Like
Reactions: Gabriel Santana
The problem was solved. Will be explained later about all the things.

Someone discovered the communication protocol between the gimbal and the camera body (CGO3+)? To not discover the hot water one more time...

This link.

FromHere.jpg
 
The software for Raspberry Pi to control a car or boat by ST10 or ST16 is ready and it works. I'm still working on some mechanical things to lift the camera out of the car for FPV. It was grown up from the SR24 test tool (which is still working and useful for me to understand the UART connection of the SR24).

As building block there are 4 units:
SR24_dec: Provides data and methods to handle UART SR24 and decode the messages.
SR24_chsets: This reads the configuration which controls the assignment between channels and HW ports. It is the mediator between decoded messages and GPIO ports.
SR24_ctrl: This unit handles the GPIO ports of the Raspberry Pi (by sysfs).
SR24_log: Provides basic logging function (just for curiosity, not really needed). But all of you know, I like log files.

The project is still here:

br HE


I'm trying to implement sending telemetry back from my RC car to an ST10 using the same microcontroller I'm using to translate the SR24 serial output to servo commands.

In your documentation you show the telemetry packet as looking like this:
1653604851944.png

Do you know if that packet format works with the ST10? Is the CRC calculated using the Len through GPS-Acro bytes?
 
Yes, this is also valid for ST10/12. CRC8 made for all bytes exclude Header and CRC byte itself. Len and GPS accuracy are in, CRC not.

Edit:
For ST10 I would send Vehicle Type 2 (for Q500) and Motorstatus 15 as default.
Other defaults for Q500 are (all decimal):
IMU status 97 when ST10 has not yet GPS fix; 255 if ST10 has GPS fix
Pressure Compass status is usually 21.
 
Last edited:
Yes, this is also valid for ST10/12. CRC8 made for all bytes exclude Header and CRC byte itself. Len and GPS accuracy are in, CRC not.

Edit:
For ST10 I would send Vehicle Type 2 (for Q500) and Motorstatus 15 as default.
Other defaults for Q500 are (all decimal):
IMU status 97 when ST10 has not yet GPS fix; 255 if ST10 has GPS fix
Pressure Compass status is usually 21.

Thank you for the info. I figured out what the problem was. I had copied your example telemetry packet and was only trying to modify a few of the values (the voltage and CRC mostly). What I hadn't noticed is that in your example packet the "len" value (38) is in decimal and needed to be converted to hex (26) like the rest of the values in the example.

Dylan
 
  • Like
Reactions: Gabriel Santana

New Posts

Members online

No members online now.

Forum statistics

Threads
20,983
Messages
241,866
Members
27,412
Latest member
Yuneecfan49