Rover: avoid nullptr dereference on bad rcmap value entry

This commit is contained in:
Peter Barker 2024-09-08 00:22:49 +10:00 committed by Peter Barker
parent a868fb8861
commit f2604f2f34
1 changed files with 4 additions and 3 deletions

View File

@ -6,9 +6,10 @@
void Rover::set_control_channels(void)
{
// check change on RCMAP
channel_steer = rc().channel(rcmap.roll()-1);
channel_throttle = rc().channel(rcmap.throttle()-1);
channel_lateral = rc().channel(rcmap.yaw()-1);
// the library gaurantees that these are non-nullptr:
channel_steer = &rc().get_roll_channel();
channel_throttle = &rc().get_throttle_channel();
channel_lateral = &rc().get_yaw_channel();
// set rc channel ranges
channel_steer->set_angle(SERVO_MAX);