How to Log Velocity and acceleration when record button is pressed
I have the latest commit of airsim running on UE4 4.18 and on linux 16.04. I am trying to get the twist and accelerations initialized from the kinematics.hpp and the references to https://github.com/Microsoft/AirSim/issues/487. Dont seem valid to the present recording file.cpp.Is there a simpler way to log the angular velocity and the accelerations.
Could you please clarify what exactly are you doing and what you want. Try giving sample code, expected output, actual output etc.
@sytelus want to edit the code so that I can get acceleration and angular velocity etc ,,, into /Documents/Airsim/Date/airsim_rec.txt Right now airsim_rec.txt gives the X,Y,Z,Q_X,Q_Y,Q_Z etc but I want to print the angular velocity and acceleration etc when I press the record button.
@sytelus want to edit the code so that I can get acceleration and angular velocity etc ,,, into /Documents/Airsim/Date/airsim_rec.txt Right now airsim_rec.txt gives the X,Y,Z,Q_X,Q_Y,Q_Z etc but I want to print the angular velocity and acceleration etc when I press the record button.
+1 can we set the output file format in settings.json?
+1 But since the IMU output is at a higher frequency than that of the images, it would be better to have it saved in a separate file. This would mean that the record button should launch another recording thread for the IMU data.
I have a python script (see below) that I launch separately when I start recording. @sytelus Could you comment on this implementation - it would be nice if something like this is integrated into the record button with adjustable settings in the settings.json file.
Edit: The answer below is incorrect. Please refer to #1909
from threading import Thread
import setup_path
import airsim
import numpy as np
KEEP_SAVING=True
def save_imu(client, filename, hz):
with open(filename, 'ab') as imu_file:
while KEEP_SAVING:
t = client.getMultirotorState().timestamp / 1e6
lv = client.getMultirotorState().kinematics_estimated.linear_velocity
la = client.getMultirotorState().kinematics_estimated.linear_acceleration
aa = client.getMultirotorState().kinematics_estimated.angular_acceleration
av = client.getMultirotorState().kinematics_estimated.angular_velocity
imu = np.array([t, la.x_val, la.y_val, la.z_val, av.x_val, av.y_val, av.z_val])
np.savetxt(imu_file, imu)
# sleep to maintain required frequency
time.sleep(1.0/hz)
# connect to the AirSim simulator
client = airsim.MultirotorClient()
client.confirmConnection()
thread = Thread(target=save_imu, args=(client,"output.dat", 100))
thread.start()
airsim.wait_key("Press any key to stop recording.")
KEEP_SAVING = False
+1 Want to see them in airsim_rec.txt
@madratman Since in real-world autonomous driving, the IMU frequency is usually much higher than camera's frequency. If IMU or GPS data can be outputted based on its own frequency, that would be so great. Hope to see this kind of APIs appear in future version.
Hey @geevargs, @pengjili, I've added the IMU API in https://github.com/Microsoft/AirSim/pull/1920, however it's not in the recording / separate thread . If using it via the C++ / python API suits your needs, please close this.
Closed due to age. Please feel free to open a new issue (referring to this one) if you still have this problem. Thanks!