mavproxy_rc: support rc override in SITL for multiple vehicles#1642
mavproxy_rc: support rc override in SITL for multiple vehicles#1642srmainwaring wants to merge 3 commits intoArduPilot:masterfrom
Conversation
| chan16 = self.override[:16] | ||
| buf = struct.pack('<HHHHHHHHHHHHHHHH', *chan16) | ||
| self.sitl_output.write(buf) | ||
| self.sitl_outputs[self.master.linknum].write(buf) |
There was a problem hiding this comment.
This looks like it is conflating link numbers and sitl-output-port numbers.
That probably means you could elicit a runtime exception with link add - or simply starting with a different number of links to sitl-rc-outputs.
There isn't a 1:1 correspondence between link numbers and SITL outputs - you could have a connection to the same simulation process on 2 of its mavliunk ports, for example.
There was a problem hiding this comment.
Good point. Would the combination of sysid, cmpid constitute a unique key for the sitl output? I'll need to maintain a map between a key that can be retrieved from the link and the sitl output in order to assign the correct output in the rc module.
There was a problem hiding this comment.
@peterbarker - I've reworked this to use the SITL instance as an index for the sitl_outputs and added logic to determine the active instance in the rc module. The vehicle system and component id's are not discovered at the point sitl_outputs is initialised, so they can't be used as a key.
The approach assumes that the base port numbers for master (5760) and sitl output (5501) are always used.
The lookup in the rc module seems a bit clunky, any suggestions to streamline it are welcome. It should be safe re. runtime exceptions now as if no instance is found, or the instance is not in the dictionary the send_rc method switches to use rc_channels_override_send. This should cover the case where there is a mixture of sim on HW and a SITL instance running (but I have not tested that combination).
- Index sitl_outputs by the sitl instance. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
- Make plural to indicate type is a list. Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
27694e0 to
5516826
Compare
Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
5516826 to
8d54e83
Compare
Ensure
rcoverrides are applied to the vehicle on the current link, or all vehicles ifalllinksis used.Current behaviour is that the
rcoverride is always applied to the vehicle with the highest link number, regardless of whichsysidis active.Single vehicle behaviour is unchanged.
Example
Start a multi-vehicle session:
Arm all the vehicles
Ensure vehicle 1 (link 0) is active
Set the throttle
Before this change vehicle 3 will move forward, after this change vehicle 1 will move forward.
Also tested in Gazebo flying two Zephyr's.