Most courts will permit a habeas petition to be filed by the petitioner himself, without a lawyer. This is referred ot a filing a petition pro se (that is, on your own behalf). If the petition is well written, then a pro se petition is not a bad idea. However, if the petition is poorly written, that will diminish the chances of getting any relief.
A writ of mandamus is a formal motion filed with a higher court (usually an appellate court) asking that higher court to require (or "mandate") a lower court to do something. For example, if a lower court has had a case before it for a long period of time, a writ of mandamus might be filed in the appellate court seeking to ahve the appellate court issue a writ of mandamus to the lower court ordering the lower court to rule on the case.