rviz is just providing a GUI for publishing a geometry_msgs/PoseWithCovarianceStamped to the (per default) "/initialpose" topic. You can just as well publish to that using your own code, rqt_publisher or rostopic pub from the command line. If you run rviz and use "2D Pose Estimate" while doing a "rostopic echo /initialpose", you should get something like the following:
kohlbrecher@sk-i7:~$ rostopic echo /initialpose
header:
seq: 0
stamp:
secs: 0
nsecs: 0
frame_id: world
pose:
pose:
position:
x: -0.00588150462136
y: 0.947909832001
z: 0.0
orientation:
x: 0.0
y: 0.0
z: -0.707230093335
w: 0.70698344753
covariance: [0.25, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.06853891945200942]
---
Just use whatever tool suits you best to create such a message and publish to "/intialpose" (provided you didn´t remap/change that topic) and your AMCL node should react accordingly.