How to update root translation using python script in bge?

I am trying to change root translation of armature (loaded by using bvh) using python script in bge but not able to update values.
I tried following

bpy.context.scene.frame_set(3)
bpy.data.objects[‘walk_turn_180’].pose.bones[0].location = [0, -10, 0]

Its not working for me. When I change frame the values are reset to original values.

Another try…

scene = bge.logic.getCurrentScene()
source = scene.objects
main_arm = source.get(‘walk_turn_180’)
bpy.context.scene.frame_set(3)
main_arm.channels[0].location = [0, -10, 0]
main_arm.update()

but still no luck.

Is there any best way to do it or am I doing something wrong?

Don’t use bpy. The BGE uses different API from Blender. Get the object as usual (i.e. cont = logic.getCurrentController(), obj = cont.owner), but the object that you’re getting will be a BL_ArmatureObject, which inherits from KX_GameObject. It has the usual object properties, but also has a channels list that allows you to grab channels (or bones) to move about as necessary.

I tried as follows,

i=0
scene = bge.logic.getCurrentScene()
source = scene.objects
while(i<10):
main_arm = source.get(‘walk_turn_180’) #armature
#bpy.context.scene.frame_set(i)
bpy.context.scene.frame_current = i ###here i used bpy, is there any simmilar function to change current frame in bge?
main_arm.channels[0].location = [float(1.0),float(i),float(1.0)] #root location
main_arm.update()
i = i + 1

i=0
while(i&lt;10):
    main_arm = source.get('walk_turn_180')
    #bpy.context.scene.frame_set(i)
    bpy.context.scene.frame_current = i
     print(main_arm.channels[0].location)
    i = i + 1

This gives o/p as :
<Vector (1.0000, 9.0000, 1.0000)>
<Vector (1.0000, 9.0000, 1.0000)>
<Vector (1.0000, 9.0000, 1.0000)>
<Vector (1.0000, 9.0000, 1.0000)>
<Vector (1.0000, 9.0000, 1.0000)>
<Vector (1.0000, 9.0000, 1.0000)>
<Vector (1.0000, 9.0000, 1.0000)>
<Vector (1.0000, 9.0000, 1.0000)>
<Vector (1.0000, 9.0000, 1.0000)>
<Vector (1.0000, 9.0000, 1.0000)>

So, this code updates same value or last value for each frame. But I want to access bone for each animation frame and update location of root with different value. How can I access root bone location for each frame and update it?