bcflight icon indicating copy to clipboard operation
bcflight copied to clipboard

Running into issues with running `flight`

Open smarkoco opened this issue 1 year ago • 1 comments

Right now, my primary goals are:

  1. better understand how to configure flight so I can adjust which modules are used, and how to disable ones I'm not currently trying to test (because right now I am still running everything on an Raspberry CM4 IO board, with no components communicating except the camera)
  2. get flight to send the video feed to a pc_controller on another computer at 192.168.1.111

I've had a number of errors I'm trying to better understand. First, when running directly after compilation (just to see what errors I would get), I saw a "bad mount" error related to this line, so I was wondering what is the intention of mounting /var? I ended up commenting out the mount line and addressing a different "file not exist: /var/flight/config.lua" error by running mkdir /var/flight and cp config.lua /var/flight.

Next, I am having issues related to No DPI CRTC/Connector found. Do you know how I could just disable certain modules so I can just focus on the video feed for now? image

Finally, would you mind letting me know how I can configure the socket IP address to test the video transmission to a running controller_pc process on another local PC (such as 192.168.1.111)? I see at this line where the variable is declared, but am not sure where the value of SOCKADDR gets set. I looked through all the "config"-related files but ran into a dead end, sadly.

Thanks in advance!

smarkoco avatar May 08 '23 03:05 smarkoco

I did not finish it yet, but you could take a look at the Configuration wiki. This is more than just a configuration file, the LUA engine actually spawn class (by allocating and calling constructors)) instances by itself. If you are not afraid of automatically-generated C++ code, you can take a look at flight/build/lua_init.cpp:lua_init()

Take a look to /flight/config.lua as an example.

Some variables are mandatory, but most of their values should be ok if left empty :

frame = Multicopter {
	maxspeed = 1.0,
	motors = {},
	matrix = {}
}

imu = IMU {
	gyroscopes = {},
	accelerometers = {},
	magnetometers = {},
	altimeters = {},
	gpses = {},
}

-- same scales as betaflight
PID.pscale = 0.032029
PID.iscale = 0.244381
PID.dscale = 0.000529
stabilizer = Stabilizer {
	loop_time = 500, -- 500 µs => 2000Hz stabilizer update
	rate_speed = 1000, -- deg/sec
	pid_roll = PID( 45, 70, 40 ),
	pid_pitch = PID( 46, 70, 40 ),
	pid_yaw = PID( 45, 90, 2 ),
	horizon_angles = Vector( 20.0, 20.0 ),
	pid_horizon = PID( 150, 0, 0 )
}

controller = Controller {
	expo = Vector(4, 4, 3.5, 2.25),
	link = Socket {
		type = Socket.UDP,
		port = 2020,
		read_timeout = 500
	}
}

For the camera, something like this should be what you are asking for :

camera_link = Socket {
	type = Socket.UDPLite,
	port = 2021,
	broadcast = false
}

camera = LinuxCamera {
	vflip = false,
	hflip = false,
	hdr = true, -- this forces framerate down to 30 (HW limitation)
	width = 1920,
	height = 1080,
	framerate = 50,
	sharpness = 0.5,
	preview_output = LiveOutput(), -- this live outputs to HDMI / DPI / CRT / etc, can be removed
	video_output = V4L2Encoder {
		video_device = "/dev/video11",
		bitrate = 8 * 1024 * 1024,
		width = 1920,
		height = 1080,
		framerate = 30,
		link = camera_link
	}
}

In the controller_pc app, go to File → Settings, Connection tab, then :

  • select TCP/IP mode
  • enter your PI4's IP adress
  • choose UDP port 2020 for controller
  • choose UDPLite port 2021 for video

You don't have to start video recording, the live stream should show up by itself without any action

dridri avatar May 08 '23 08:05 dridri