Lee Cockburn is about to have a very tough day.

Horses will charge at her. Dogs will snap at her legs and arms. Men will throw rocks and bricks. She will spend the whole day like this, being constantly attacked like a woman trapped in a violent computer game, because it's what she has to do, twice a year, every year, to remain an officer in Police Scotland's riot squad.

She is due to attend the riot-cop refresher course the day after we meet at her home in Edinburgh and she shows me the gear she'll be wearing: stab vest, a padded suit, a Death-Star helmet, and a belt loaded down with the paraphernalia of violence. Cockburn is already a big presence - she's 6ft 1in tall and weighs 15 stone - but the riot gear adds another three stone and turns her into someone else.

It's not the only transformation that happens when she's in police mode. For most of the time, Cockburn, 46, is a sergeant based at Drylaw in Edinburgh and has to work in some of the tougher areas of the city, which sometimes means appearing more confident and calmer than she's feeling inside. Over the years, she has also picked up the copper's radar. "I'm perceptive," she says. "I can spot trouble, I can feel trouble. Even if I'm just out having a drink, I'll think 'look over there, watch that'. You can feel it."

She has put some of these experiences, good and bad, into her first novel, Devil's Demise, a crime thriller about Taylor Nicks, a 34-year-old detective sergeant in the major crimes unit in Edinburgh. The book opens with a violent rape and as the hunt for a serial killer and rapist unfolds, DS Nicks has to attend some pretty grisly crime scenes and, as much as possible, the detail is accurate and based on Cockburn's experiences.

"The scenes examination branch and so on in the novel, that's how it's done," she says. "The worse thing is the smell - the smell of death is something you will never, ever forget. But the hardest thing is the human emotion. If someone's dying and you're trying to save them - and you try your best - I can feel the pain. I can take death, there's nothing you can do, but when the family comes in, that's when your heart's breaking and there's one or two cases that have stuck in my heart and will always be there."

One of the coping mechanisms the police use in these situations is black humour and Cockburn is no exception. There's plenty of it in her book, along with lots of epic Scottish swearing. In fact, that's one of the novel's strengths: the police characters are presented as honestly as possible, which means that as well as the commitment and work, there is the cynicism, bad language, anger and the black humour. Cockburn is trying to show us the kind of people who are in the police, and what being in the police does to people.

"I think there's a certain type of person that will join the police," she says. "You have to be bold in certain ways, you have to have a sense of humour and you can see it in my book: the dark humour that gets you through. You're not being horrible, or trying to be insulting, you're trying to get over how you're feeling."

Cockburn also wanted to be realistic in her novel about the kind of potentially violent situations officers face. In all, she has been in the force for 14 years (six as a constable, three full-time in the riot squad and five in her current position as sergeant in charge of a team of 11) and in all that time, she has frequently faced often tense, difficult situations and learned how to cope with them: kicking a door in, for example, with no idea how many people might be on the other side; facing up to a gang of young men who could go either way, an experience which she fictionalises in her novel.

These situations have actually led to her being seriously injured only once, when she was knocked unconscious by a punch, and she has suffered many more injuries taking part in her favourite sport of rugby. She has played a lot of the game in her time, including in the first women's international in 1993 and went on to win more than 80 caps for the Scotland's women's team. "It's a bit like being in the riot squad," she says, "I love the physicality of it."

She still plays now for her local club and has seen a lot of change in the women's game. In the early days, when she started out, the members of the women's Scotland team had to pay to take part; now women players can earn some money and some are semi-professional. Cockburn has witnessed a change in attitudes among spectators too.

"Some men slagged us off at first," she says, "but by 1994 we were drawing crowds of 6-8,000. There's still an imbalance on television with how much time you get for different sports, but women's rugby is a very fast growing sport and it's doing well. I would love to have played rugby for a living but that wasn't on offer."

Cockburn says the modern police force is also a welcoming place for women. She has never been a victim of sexism, she says, and says that her sexuality - Cockburn is gay and is in a civil partnership with her partner Emily - has not been a problem. We're talking in her living room and she shows me pictures of her civil partnership ceremony five years ago; at the time, both she and Emily were pregnant through donor conception and there are lots of pics of their two sons, Harry and Jamie, who are now four years old.

"I was five months pregnant and Emily was three months at the time of our civil ceremony," she says, "we thought that would give us automatic rights to our children but it didn't so we've since adopted them."

Cockburn's partner is a policewoman too, which means they have to juggle their shifts to care for the boys and ensure someone is always there for school-gate duty. Cockburn says a gay family with children is still relatively unusual and open to comment, and the radar she uses as a policewoman can also pick up prejudice where it still exists.

"I have heard of people saying of us in our outer circle 'it's not a real family, it's just two women'. People have asked do they not need a man in their life? and I say they do have men in their lives. There's my father, friends, but it's the fact we love our kids and do everything we can for them that matters."

Cockburn says she has also seen a change in attitudes at school. "I can see now that things have changed at school and you can hear children say 'they've got two mummies'. The kids don't care. If the kids learn to think 'so what' then the person who wants to bully or persecute has nothing to do. I've been called all sorts of things in the street but I don't care. I'm proudly gay and don't bother."

Cockburn, who grew up in Edinburgh, has been out as a gay woman since she was 17 years old and says homophobia is less of a problem than it was 30 years ago. "When I came out at 17, you had to ring the doorbell to get into a club," she says. "And when I was 18, I was attacked along with two gay men on Princes Street. Homophobic attacks still do happen because there are people who are narrow minded but there is a theory about the person who hits the hardest. Why are you so anti-gay? Is it because you're gay yourself?"

Cockburn has put some of her experiences as a gay woman into her novel - DS Nicks is gay - but it's not a book that's full of issues; mostly she just wants to produce a readable novel in the style of Val McDermid, say, or the thrillers of Tess Gerritsen. She tells me she is already about 20,000 words into the second book and plans a third one after that, all of it fitted between shifts as a police officer, shifts as a mother and the occasional shift as a rugby player. But first there is the refresher course for the riot police. Tomorrow, she faces the dogs and the horses.

Devil's Demise is published by Clink Street at £7.99.

CAREER HIGH

Career highs in my line of work are always when you have managed to save someone's life and have actually made a real difference.

CAREER LOW

The opposite of the first. When you can't save someone as a police officer, it's very sad for all involved.

FAVOURITE MUSIC

Eighties high-energy music.

BEST ADVICE RECEIVED

Don't judge people, treat everyone how you'd like to be treated yourself. Oh and tell people you love them whenever you can.

BIGGEST INFLUENCE

My parents, because they gave me such a loving start in life and still support me unconditionally now.