"We don't want you to interfere with the affairs of Somalia. Your work is to teach," he told the soldiers, who are due to arrive in Somalia next week.
Unconfirmed media reports in Somalia said an advance unit of Ugandan troops had already arrived there.
A tank battalion is expected to leave by rail for the Kenyan port city of Mombasa from where they will travel by sea to Mogadishu, the Somali capital, according to the Ugandan army spokesman, Captain Paddy Ankunda. The Ugandan force will be commanded by Col Peter Elwelu.
The 1,500 Ugandan soldiers will be part of an 8,000-strong force that the AU and the Intergovernmental Authority on Development (IGAD) are expected to deploy in Somalia to help the fledgling Transitional Federal Government (TFG) restore law and order.
The AU force is expected to replace Ethiopian troops, who went into Somalia in December 2006 and helped the TFG defeat the Union of Islamic Courts (UIC), whose forces had seized control of most of the country and were undermining the limited authority of the interim government set up in 2004.
"We are not going to Somalia to impose peace on the Somali people, but to help empower them to rebuild their state and help them to rebuild their army. That is our line of responsibility," said Museveni.
The Chief of Staff, Gen Aronda Nyakairima, cautioned the troops on the kinds of danger they were likely to encounter in Somalia.
"Remnants of Islamic fundamentalists are still out there; warlords who are yet to integrate in the government are still there and freelance militias are still there," said Nyakairima. "Maintain good relations with other contingents that are coming in. Maintain a good relationship with the people of Somalia," he told the soldiers.
Somalia has had no effective national government since the overthrow in 1991 of the regime headed by Muhammad Siyad Barre. The country plunged into factional bloodletting soon after the government was toppled as rival armed groups and warlords fought for power, resources and territory.