A black bear cub was caught on film while rubbing against a tree in Montana. Though solitary animals, black bear moms and cubs stick together.

Grizzly bears are getting their groove on, and new hidden cameras are giving scientists a window into the secret lives of these dancing bears.

This is no circus act. Between 2005 and 2007, Kate Kendall of the U.S. Geological Survey and her colleagues took video footage of black and grizzly bears doing what looks like the go-go at their favorite "rub trees." They also got film of bears lumbering beneath stretches of barbed wire used to snag hair samples.

The research is part of a larger study to estimate the population size and distribution of bears in northwestern Montana using genetic analyses of the bears' hair samples.

Scientists think bears shimmy their backs against trees in a kind of bump-and-grind to scratch hard-to-reach spots and to communicate their presence to other Ursus kin.

"It's probably primarily a form of chemical communication," Kendall said. "Often bears will sniff the trees before and after they rub on them."

Though Kendall has yet to pinpoint exactly what makes for a bear-loving rub tree, both grizzlies and black bears seem to agree on the specs. "Multiple bears are using the same trees, including within the same day black bears and grizzly bears," Kendall told LiveScience.

Evidence also suggested the bear cubs took part in tree-rubbing. But momma bears avoided rub trees during the mating season between May and June. By steering clear of rub trees during those months, Kendall says, the female bears who already have cubs can avoid interested males and protect their young.

"Adult males are most likely to attack the cubs of females that they're interested in breeding with [during the mating season]," Kendall said.