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

Launch Control Palmer #23

Open
wants to merge 16 commits into
base: roman
Choose a base branch
from
Open

Launch Control Palmer #23

wants to merge 16 commits into from

Conversation

nistath
Copy link
Member

@nistath nistath commented Sep 8, 2018

This pull request updates the VCU code to include launch control for testing at palmer on Sunday Sept. 9.

Copy link
Contributor

@sebLopezCot sebLopezCot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some stylistic things

@@ -14,6 +14,15 @@
#define MAX_ACCEL_VAL 1000
#define MIN_ACCEL_VAL 0

// Launch control contants
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error

#define LC_cGR 347 // Gear ratio times 100
#define LC_ACCEL_BEGIN 950 // 95%
#define LC_ACCEL_RELEASE 50 // 5%
#define LC_BRAKE_BEGIN 100 // We want a lower threshold
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still want this comment?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this comment was to indicate that we want lower threshold than normal. I can fix it to make it clearer

} else { // Only use limits and launch control when we're not doing regen
// Even if we are doing launch control, calculate limits for loggind also so that we are not doing
// launch control when we're supposed to be limiting

int32_t voltage_limited_torque = get_voltage_limited_torque(torque_command);
// static uint32_t last_vt = 0;
// if (HAL_GetTick() - last_vt > 10) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just remove this commented code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also there is a typo here "loggind"

@@ -90,13 +103,14 @@ void execute_controls(void) {
// }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here: remove commented code

src/vcu/src/controls.c Show resolved Hide resolved
position: 0
length: 1
c_type: bool
launch_ctrl_slip_ratio: # Ranges from 105 to 115
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it range between these values? Will this ever change?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I talk about this is confluence docs. This number was something that Luis suggested but could use some more backing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, might be good to at least show how you might come up with this on confluence.

@@ -22,12 +28,16 @@ void init_controls_defaults(void) {
control_settings.volt_lim_min_gain = 0;
control_settings.volt_lim_min_voltage = 300;
control_settings.torque_temp_limited = false;

lc_settings.using_launch_ctrl = false;
lc_settings.slip_ratio = 112;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would recommend bringing 112 out to a DEFAULT_SLIP_RATIO constant

src/vcu/src/controls.c Outdated Show resolved Hide resolved
if (pedalbox_min(accel) < LC_ACCEL_BEGIN) {
printf("[LAUNCH CONTROL ERROR] Accel min (%d) too low\r\n", pedalbox_min(accel));
return true;
} else if (pedalbox.brake_2 > LC_BRAKE_BEGIN) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why only brake_2? Don't we want the max of the 2 brakes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have learned the reason, but would still like a comment here explaining why we only need to check brake 2

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually don't remember the reason myself...should definitely go in a comment

return false;
}

void set_lc_state_before() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this function ever used? Can we delete it?

src/vcu/src/controls.c Outdated Show resolved Hide resolved
}
break;
case SPEEDING_UP:
if (torque_command < 1000) sendSpeedCmdMsg(500, torque_command);
Copy link
Contributor

@sebLopezCot sebLopezCot Sep 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In confluence, we have "LC_SPEEDING_UP_TORQUE", but here it is not a constant. Can we fix this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also can we make 300 and 500 some sort of constants too and add them to the documentation in confluence?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also technically the if statement here with < 1000 should probably be reflected in the state machine somehow. I think you intended to back off on the torque command if we start to exceed 1000, right?

Copy link
Collaborator

@daniwhite daniwhite Sep 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah I realized I had made it a constant and forgot to push it. I'll fix the others

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And yeah my intention we to command max(commanded torque, 1000)

@sebLopezCot
Copy link
Contributor

sebLopezCot commented Sep 8, 2018

Hey Dani, I think in terms of state machine logic, this looks good. Nick and I both went through the diagrams in confluence and it seems to match. Some stylistic things are in order. Also make sure to pull our changes before resolving issues. Also, nice work on the diagrams! Super easy to read.

@nistath
Copy link
Member Author

nistath commented Sep 26, 2018

This PR has been open for too long, @daniwhite .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants