Funny, optimistic and compassionate, “Floyd’s” feels like a play we need right now.

In fact, Lynn Nottage’s comedy, which had its world premiere Friday night at the Guthrie Theater, is set right now — incorporating a song from Rihanna’s most recent album, as well as references to the disturbing influence of white supremacists and even Cardi B’s trademarked “Okurrr.”

No specific political events or figures are cited, but the play’s five characters are products of a world where desperate people turn to crime. Recently released from prison, they work in the kitchen of a truck stop called Floyd’s, owned by an ex-felon (Johanna Day) who makes her employees feel like they’re still in jail. Set designer Laura Jellinek even emphasizes the cramped purgatory of that kitchen by giving it a low ceiling.

“Cramped purgatory” doesn’t sound hilarious, but “Floyd’s” is very funny, with humor that comes from the specifics of character rather than jokes. The line that earned the biggest laugh on opening night doesn’t even seem like it belongs in a comedy: “specializing in pediatric trauma surgery.” (It helps that this particular line is delivered by the gravely funny John Earl Jelks and reacted to by the ferocious Dame Jasmine Hughes, who also turns the phrase, “I don’t think so,” into a layered comic monologue.)

Nottage and the gifted ensemble get us up to speed so quickly on these people — brash Tish (Hughes), secretive Jason (Andrew Veenstra), buoyant Rafael (Reza Salazar), thoughtful Montrellous (Jelks) and manipulative Floyd — that it’s their attitudes and unexpected observations that make us laugh. Dialogue reveals who these people are in this classically constructed play, which achieves its effects through Nottage and director Kate Whoriskey’s command of tension and release: A small conflict that is resolved with a laugh giving way to a bigger conflict that is resolved with a bigger belly laugh, rising and rising and rising until we’re ready for something decisive to happen at the end.

Part of what’s so hopeful about “Floyd’s” is Nottage’s insistence that we see, really see, people we might be inclined to turn away from. The two-time Pulitzer Prize winner wants us to appreciate the complicated humanity of these characters as we watch them do ordinary things like mincing celery or cleaning a grill. They are stuck at Floyd’s because nobody else will hire them and, even knowing what they know, they sometimes rush to judge each other’s wrongs. They make the best of Floyd’s, though, gradually reaching out to one another as they tell their stories, bust out impromptu dance parties and fantasize about what the perfect sandwich tastes like.

The play finds the employees getting closer and closer to creating that sandwich even as Floyd steps on their imaginations by refusing to let them put it on the menu.

That setup functions as both the limited-options reality of people who have been incarcerated and as a metaphor for the rest of us, who have never been jailed but may still feel like we’re stuck in an awful situation where we are constrained by a boss whose senseless proclamations are designed to rob us of our humanity and our hope.

A couple of small things in this Guthrie commission don’t quite come off — a climactic set reveal doesn’t have the impact it’s meant to, for instance. But it’s a powerful and hopeful work because, by the end, it’s clear that the events we’re seeing reach far beyond this tiny kitchen.

That’s because “Floyd’s” doesn’t just want us to recognize the humanity of these characters, which is something we should be doing, anyway. It wants the characters themselves to recognize that they are worthwhile people, that they deserve another chance and that, as Montrellous tells them, “There’s always a way out.”