Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new conflict? #41

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
ea86f34
Fixed feed-forward to consider steer_offset
Gernby Nov 6, 2018
0bbc4fc
fixed a small oops on types
Gernby Nov 7, 2018
f6e5830
Testing strategies for zero-crossing
Gernby Nov 8, 2018
f720034
Moved angle stat collection to latcontrol.py
Gernby Nov 8, 2018
ebbfd0b
First version that runs
Gernby Nov 8, 2018
f543fe9
added outbound interface for feed-forward table
Gernby Nov 8, 2018
f475160
First working
Gernby Nov 8, 2018
b6a5180
Added more metrics
Gernby Nov 8, 2018
8f0effd
Adjusted parameter timing
Gernby Nov 8, 2018
d9c8dff
performance tweaks
Gernby Nov 9, 2018
8087e81
Cleanup
Gernby Nov 9, 2018
78095f4
untested tweaks
Gernby Nov 10, 2018
855684c
minor tweaks
Gernby Nov 10, 2018
a8fabe2
many untested changes
Gernby Nov 11, 2018
347d1d1
going the other way with some things...
Gernby Nov 11, 2018
4b4767c
Best yet
Gernby Nov 11, 2018
b12aaf3
cleaned up personalized "stuff"
Gernby Nov 12, 2018
1251809
more cleanup for general use
Gernby Nov 12, 2018
66ec2bc
untested: minor adjustment to further reduce noise
Gernby Nov 12, 2018
f26785e
Fixed defect in desired angle interpolation
Gernby Nov 13, 2018
856f2b1
some cleanup
Gernby Nov 13, 2018
a0c9b2d
reverted change to Ki
Gernby Nov 13, 2018
900b9cd
Reverted changes to manager.py
Gernby Nov 13, 2018
34e239f
Added steering rate consideration to latcontrol
Gernby Nov 13, 2018
52094ba
cleaned up for PR
Gernby Nov 13, 2018
3134bce
Merge remote-tracking branch 'origin' into Feed-Forward_Steer_Offset
Gernby Nov 17, 2018
07bbadc
Fixed merge
Gernby Nov 17, 2018
d04f868
Testing approach when desired angle close to actual
Gernby Nov 17, 2018
cec70b7
trying rate-based feed-forward
geohot Nov 24, 2018
33e44f6
added self-tuning parms for rate and angle FF
geohot Nov 25, 2018
3f9b21e
fixed trim logic, and persisted to flash
geohot Nov 25, 2018
60f9e85
working amazingly well
geohot Nov 25, 2018
527788b
decreased time lapse for angle-based FF adjust
geohot Nov 25, 2018
c70e60e
many tweaks, self-tuning is a bitch
Gernby Nov 27, 2018
aa2bc77
simulteneous dual mode feedforward working very well
Gernby Nov 27, 2018
72ed9ef
added angular accelleration limit
Gernby Nov 27, 2018
fcc3c3e
added super awesome angular accel limit
Gernby Nov 28, 2018
1a839ba
non-specific save
Gernby Nov 28, 2018
4ead166
switching directions again
Gernby Nov 28, 2018
9f89e4d
oops
Gernby Nov 28, 2018
b658484
ugly code with amazing results
Gernby Nov 29, 2018
d4acc24
awesome, but untested after some cleanup
Gernby Nov 30, 2018
dbe6835
more cleanup
Gernby Nov 30, 2018
c186f5c
cleanup of the cleanup? Need to test
Gernby Nov 30, 2018
5ed48fd
works amazingly well ... big O face
Gernby Nov 30, 2018
d820de2
cleanup
Gernby Nov 30, 2018
1aa2b75
I wish git was batter for cleanup
Gernby Nov 30, 2018
559593b
hopefully proper merge of merged fixes of merge
Gernby Dec 2, 2018
8837355
fixed an oops for non-bosch hondas
Gernby Dec 2, 2018
68c9a0a
added steer rate to future state calculation
Gernby Dec 2, 2018
2d988b9
added actual acceleration to future projected state
Gernby Dec 3, 2018
46bf0aa
fixed projected angle error for PIF
Gernby Dec 4, 2018
dbdc422
untested ...
Gernby Dec 4, 2018
a559a7d
added comments
Gernby Dec 5, 2018
e222d48
completely UNtested
Gernby Dec 6, 2018
044bd29
untested merge
Gernby Dec 12, 2018
be6bc31
battling shitty git
Gernby Dec 12, 2018
7cb32e9
git is sucking giant monkey balls
Gernby Dec 12, 2018
89418e4
Trying to figure out what git did...
Gernby Dec 12, 2018
37c7196
still trying to un-git myself
Gernby Dec 12, 2018
982c7e0
Finally got it fixed, works awesome!
Gernby Dec 12, 2018
53bdee4
Hopefully not corrupted by git
Gernby Dec 13, 2018
05eae19
hopefully fixed white space corruption
Gernby Dec 13, 2018
f2b706c
working again, hopefully resolved git issue
Gernby Dec 13, 2018
5b9708c
removed hard-coded actuator delay
Gernby Dec 16, 2018
0579016
Fixed steer_actuator_delay for pathplanner
Gernby Dec 16, 2018
343d946
Wiggle vision + resonant FF and error cancellation
Gernby Dec 23, 2018
0b24b41
increased projection factor and decreased accel_limit
Gernby Dec 24, 2018
96dbc51
enhanced torque logic to use accelerated rate
Gernby Dec 25, 2018
19db4fe
added smoothing of mpc delta values
Gernby Dec 26, 2018
b204acd
trying different interpolation logic
Gernby Dec 26, 2018
68836c1
added update to cur_state.delta
Gernby Dec 27, 2018
057289b
very smooth interpolation between delayed MPC updates
Gernby Dec 27, 2018
a0266f6
increased Kf for Pilot
Gernby Dec 27, 2018
8982228
much better interpolation plus Civic tweaks
Gernby Dec 27, 2018
9dd050f
tiny meaningless changes
Gernby Dec 27, 2018
776d853
Fixed honda interface values
Gernby Dec 28, 2018
ebad223
removed steer_offset from pilot
Gernby Dec 28, 2018
d5c2202
Tweaked steer_offset list
Gernby Dec 28, 2018
45ef704
Reverted a couple resonant parameters
Gernby Dec 28, 2018
218d69c
Enabled error correction
Gernby Dec 28, 2018
0dd9339
changed Kp for some
Gernby Dec 28, 2018
e2ece4b
Merge 0.5.7 into testing-mpc-interp
Gernby Dec 28, 2018
f6c2d0e
Works great... time to clean it up
Gernby Dec 29, 2018
989e888
reverted accelerated_angle_rate for pid updates
Gernby Dec 30, 2018
e42d081
reverted visiond
Gernby Dec 30, 2018
99460c1
Increased error correction
Gernby Dec 31, 2018
b92a2f4
Reverted projection_factor
Gernby Dec 31, 2018
b307f70
fixed projected_angle_steers for future statefixed projected_angle_st…
Gernby Dec 31, 2018
bf6c44d
Added simplified tuning parameters
Gernby Jan 1, 2019
1a36d19
last commit didn't have saved values
Gernby Jan 1, 2019
2789c2a
not working ... lane filtering
Gernby Jan 3, 2019
fc4629c
added calculated steer rate
Gernby Jan 6, 2019
a163a3b
updated toyota carstate
Gernby Jan 6, 2019
784c4d4
add dual-mode steer-rate alternating
Gernby Jan 7, 2019
62a941a
reverted toyota carstate change
Gernby Jan 7, 2019
40713b5
enabled auto-selection of steer_rate
Gernby Jan 7, 2019
7652a56
removed extra variable
Gernby Jan 7, 2019
452968d
enabled 1.0 x error cancellation
Gernby Jan 8, 2019
41de2f6
reverted curstate
Gernby Jan 9, 2019
c113cb8
more like FF-res plus longitudinal camera offset
Gernby Jan 10, 2019
39a44c8
updated max torque valueupdated max torque value
Gernby Jan 10, 2019
5a2e981
good breakthroughs for max_steer and steer noise
Gernby Jan 10, 2019
d176d9e
fixed torque for accords
Gernby Jan 10, 2019
2458133
Fixed typo
Gernby Jan 10, 2019
b371c10
not as good
Gernby Jan 10, 2019
3024e59
removed vibrate
Gernby Jan 10, 2019
8c64240
enabled long camera offset
Gernby Jan 10, 2019
4895768
added new steering parameters
Gernby Jan 10, 2019
30d5006
added new steering parameters
Gernby Jan 10, 2019
73e0aa1
added new steering parameters
Gernby Jan 10, 2019
5f03e03
mall cleanup
Gernby Jan 10, 2019
8d4ffb4
merge
Gernby Jan 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cereal/car.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ struct CarParams {
centerToFront @9 :Float32; # [m] GC distance to front axle
steerRatio @10 :Float32; # [] ratio between front wheels and steering wheel angles
steerRatioRear @11 :Float32; # [] rear steering ratio wrt front steering (usually 0)
eonToFront @54 :Float32; # [m] distance from EON to front wheels

# things we can derive
rotationalInertia @12 :Float32; # [kg*m2] body rotational inertia
Expand All @@ -337,6 +338,10 @@ struct CarParams {
steerKpDEPRECATED @15 :Float32;
steerKiDEPRECATED @16 :Float32;
steerKf @25 :Float32;
steerReactance @51 :Float32;
steerInductance @52 :Float32;
steerResistance @53 :Float32;


# Kp and Ki for the longitudinal control
longitudinalKpBP @36 :List(Float32);
Expand Down
10 changes: 5 additions & 5 deletions launch_chffrplus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ fi

function launch {
# apply update
if [ "$(git rev-parse HEAD)" != "$(git rev-parse @{u})" ]; then
git reset --hard @{u} &&
git clean -xdf &&
exec "${BASH_SOURCE[0]}"
fi
#if [ "$(git rev-parse HEAD)" != "$(git rev-parse @{u})" ]; then
# git reset --hard @{u} &&
# git clean -xdf &&
# exec "${BASH_SOURCE[0]}"
#fi

# no cpu rationing for now
echo 0-3 > /dev/cpuset/background/cpus
Expand Down
44 changes: 37 additions & 7 deletions selfdrive/can/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ class CANParser {
subscriber = zmq_socket(context, ZMQ_SUB);
zmq_setsockopt(subscriber, ZMQ_SUBSCRIBE, "", 0);

forwarder = zmq_socket(context, ZMQ_PUB);
zmq_bind(forwarder, "tcp://*:8592");

std::string tcp_addr_str;

if (sendcan) {
Expand Down Expand Up @@ -244,8 +247,17 @@ class CANParser {
// parse the messages
for (int i = 0; i < msg_count; i++) {
auto cmsg = cans[i];

if (cmsg.getDat().size() > 8) continue; //shouldnt ever happen
uint8_t dat[8] = {0};
memcpy(dat, cmsg.getDat().begin(), cmsg.getDat().size());

if (can_forward_period_ns > 0) raw_can_values[cmsg.getSrc()][cmsg.getAddress()] = read_u64_be(dat);

//if (((cmsg.getAddress() == 0xe4 or cmsg.getAddress() == 0x33d) and cmsg.getSrc() == bus) or \
// (cmsg.getSrc() != bus and cmsg.getAddress() != 0x33d and cmsg.getAddress() != 0xe4 and \
// (cmsg.getAddress() < 0x240 or cmsg.getAddress() > 0x24A))) {
if (cmsg.getSrc() != bus) {
// DEBUG("skip %d: wrong bus\n", cmsg.getAddress());
continue;
}
auto state_it = message_states.find(cmsg.getAddress());
Expand All @@ -254,27 +266,38 @@ class CANParser {
continue;
}

if (cmsg.getDat().size() > 8) continue; //shouldnt ever happen
uint8_t dat[8] = {0};
memcpy(dat, cmsg.getDat().begin(), cmsg.getDat().size());

// Assumes all signals in the message are of the same type (little or big endian)
// TODO: allow signals within the same message to have different endianess
auto& sig = message_states[cmsg.getAddress()].parse_sigs[0];
if (sig.is_little_endian) {
p = read_u64_le(dat);
} else {
p = read_u64_be(dat);
}
}

DEBUG(" proc %X: %llx\n", cmsg.getAddress(), p);

state_it->second.parse(sec, cmsg.getBusTime(), p);
}
}

void ForwardCANData(uint64_t sec) {
if (sec > next_can_forward_ns) {
next_can_forward_ns += can_forward_period_ns;
// next_can_forward_ns starts at 0, so it needs to be reset. Also handle delays.
if (sec > next_can_forward_ns) next_can_forward_ns = sec + can_forward_period_ns;
std::string canOut = "";
for (auto src : raw_can_values) {
for (auto pid : src.second) {
canOut = canOut + std::to_string(src.first) + " " + std::to_string(pid.first) + " " + std::to_string(pid.second) + "|";
}
}
zmq_send(forwarder, canOut.data(), canOut.size(), 0);
}
}

void UpdateValid(uint64_t sec) {
can_valid = true;
can_valid = true;
for (const auto& kv : message_states) {
const auto& state = kv.second;
if (state.check_threshold > 0 && (sec - state.seen) > state.check_threshold) {
Expand Down Expand Up @@ -317,6 +340,8 @@ class CANParser {
UpdateCans(sec, cans);
}

if (can_forward_period_ns > 0) ForwardCANData(sec);

UpdateValid(sec);

zmq_msg_close(&msg);
Expand Down Expand Up @@ -351,6 +376,11 @@ class CANParser {
void *context = NULL;
void *subscriber = NULL;

void *forwarder = NULL;
uint64_t can_forward_period_ns = 100000000;
uint64_t next_can_forward_ns = 0;
std::unordered_map<uint32_t, std::unordered_map<uint32_t, uint64_t>> raw_can_values;

const DBC *dbc = NULL;
std::unordered_map<uint32_t, MessageState> message_states;
};
Expand Down
5 changes: 5 additions & 0 deletions selfdrive/car/gm/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ def get_params(candidate, fingerprint):

std_cargo = 136

ret.steerReactance = 1.0
ret.steerInductance = 1.0
ret.steerResistance = 1.0
ret.eonToFront = 0.5

if candidate == CAR.VOLT:
# supports stop and go, but initial engage must be above 18mph (which include conservatism)
ret.minEnableSpeed = 18 * CV.MPH_TO_MS
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/honda/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def update(self, sendcan, enabled, CS, frame, actuators, \

# *** compute control surfaces ***
BRAKE_MAX = 1024/4
if CS.CP.carFingerprint in (CAR.ACURA_ILX):
if CS.CP.carFingerprint in (CAR.ACCORD, CAR.ACCORD_15, CAR.ACCORDH, CAR.ACURA_ILX):
STEER_MAX = 0xF00
elif CS.CP.carFingerprint in (CAR.CRV, CAR.ACURA_RDX):
STEER_MAX = 0x3e8 # CR-V only uses 12-bits and requires a lower value (max value from energee)
Expand Down
7 changes: 6 additions & 1 deletion selfdrive/car/honda/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def get_can_signals(CP):
("WHEEL_SPEED_RR", "WHEEL_SPEEDS", 0),
("STEER_ANGLE", "STEERING_SENSORS", 0),
("STEER_ANGLE_RATE", "STEERING_SENSORS", 0),
("STEER_ANGLE_OFFSET", "STEERING_SENSORS", 0),
("STEER_TORQUE_SENSOR", "STEER_STATUS", 0),
("LEFT_BLINKER", "SCM_FEEDBACK", 0),
("RIGHT_BLINKER", "SCM_FEEDBACK", 0),
Expand Down Expand Up @@ -239,7 +240,11 @@ def update(self, cp, cp_cam):
self.user_gas_pressed = self.user_gas > 0 # this works because interceptor read < 0 when pedal position is 0. Once calibrated, this will change

self.gear = 0 if self.CP.carFingerprint == CAR.CIVIC else cp.vl["GEARBOX"]['GEAR']
self.angle_steers = cp.vl["STEERING_SENSORS"]['STEER_ANGLE']
if self.CP.carFingerprint in (CAR.CIVIC, CAR.ODYSSEY, CAR.CRV_5G, CAR.ACCORD, CAR.ACCORD_15, CAR.ACCORDH, CAR.CIVIC_HATCH):
self.angle_steers = cp.vl["STEERING_SENSORS"]['STEER_ANGLE'] + cp.vl["STEERING_SENSORS"]['STEER_ANGLE_OFFSET']
else:
self.angle_steers = cp.vl["STEERING_SENSORS"]['STEER_ANGLE']

self.angle_steers_rate = cp.vl["STEERING_SENSORS"]['STEER_ANGLE_RATE']

self.cruise_setting = cp.vl["SCM_BUTTONS"]['CRUISE_SETTING']
Expand Down
11 changes: 10 additions & 1 deletion selfdrive/car/honda/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ def get_params(candidate, fingerprint):
ret.steerKiBP, ret.steerKpBP = [[0.], [0.]]

ret.steerKf = 0.00006 # conservative feed-forward
ret.steerReactance = 1.0
ret.steerInductance = 1.0
ret.steerResistance = 1.0
ret.eonToFront = 0.5

if candidate == CAR.CIVIC:
stop_and_go = True
Expand Down Expand Up @@ -226,7 +230,12 @@ def get_params(candidate, fingerprint):
ret.centerToFront = ret.wheelbase * 0.39
ret.steerRatio = 15.96 # 11.82 is spec end-to-end
tire_stiffness_factor = 0.8467
ret.steerKpV, ret.steerKiV = [[0.6], [0.18]]
ret.steerReactance = 1.0
ret.steerInductance = 1.0
ret.steerResistance = 1.0
ret.eonToFront = 1.0
ret.steerKpV, ret.steerKiV = [[0.64], [0.192]]
ret.steerKf = 0.000064
ret.longitudinalKpBP = [0., 5., 35.]
ret.longitudinalKpV = [1.2, 0.8, 0.5]
ret.longitudinalKiBP = [0., 35.]
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/hyundai/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def update(self, cp, cp_cam):
self.standstill = not self.v_wheel > 0.1

self.angle_steers = cp.vl["SAS11"]['SAS_Angle']
self.angle_steers_rate = cp.vl["SAS11"]['SAS_Speed']
self.angle_steers_rate = 0.0 #cp.vl["SAS11"]['SAS_Speed']
self.yaw_rate = cp.vl["ESP12"]['YAW_RATE']
self.main_on = True
self.left_blinker_on = cp.vl["CGW1"]['CF_Gway_TSigLHSw']
Expand Down
5 changes: 5 additions & 0 deletions selfdrive/car/hyundai/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ def get_params(candidate, fingerprint):
ret.steerActuatorDelay = 0.1 # Default delay
tire_stiffness_factor = 1.

ret.steerReactance = 1.0
ret.steerInductance = 1.0
ret.steerResistance = 1.0
ret.eonToFront = 0.5

if candidate == CAR.SANTA_FE:
ret.steerKf = 0.00005
ret.steerRateCost = 0.5
Expand Down
5 changes: 5 additions & 0 deletions selfdrive/car/mock/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ def get_params(candidate, fingerprint):
ret.safetyModel = car.CarParams.SafetyModels.noOutput
ret.openpilotLongitudinalControl = False

ret.steerReactance = 1.0
ret.steerInductance = 1.0
ret.steerResistance = 1.0
ret.eonToFront = 0.5

# FIXME: hardcoding honda civic 2016 touring params so they can be used to
# scale unknown params for other cars
ret.mass = 1700.
Expand Down
7 changes: 6 additions & 1 deletion selfdrive/car/toyota/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,12 @@ def update(self, cp, cp_cam):
self.standstill = not self.v_wheel > 0.001

self.angle_steers = cp.vl["STEER_ANGLE_SENSOR"]['STEER_ANGLE'] + cp.vl["STEER_ANGLE_SENSOR"]['STEER_FRACTION']
self.angle_steers_rate = cp.vl["STEER_ANGLE_SENSOR"]['STEER_RATE']

if self.CP.carFingerprint in (CAR.RAV4, CAR.RAV4H, CAR.COROLLA):
self.angle_steers_rate = cp.vl["STEER_ANGLE_SENSOR"]['STEER_RATE']
else:
self.angle_steers_rate = 0.0

can_gear = int(cp.vl["GEAR_PACKET"]['GEAR'])
self.gear_shifter = parse_gear_shifter(can_gear, self.shifter_values)
self.main_on = cp.vl["PCM_CRUISE_2"]['MAIN_ON']
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/controls/controlsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def state_control(plan, CS, CP, state, events, v_cruise_kph, v_cruise_kph_last,
v_cruise_kph, plan.vTarget, plan.vTargetFuture, plan.aTarget,
CP, PL.lead_1)
# Steering PID loop and lateral MPC
actuators.steer, actuators.steerAngle = LaC.update(active, CS.vEgo, CS.steeringAngle,
actuators.steer, actuators.steerAngle = LaC.update(active, CS.vEgo, CS.steeringAngle, CS.steeringRate,
CS.steeringPressed, plan.dPoly, angle_offset, CP, VM, PL)

# Send a "steering required alert" if saturation count has reached the limit
Expand Down
Loading