diff --git a/Matlab/AirSimClient.m b/Matlab/AirSimClient.m index f3ea777d3..be594a9df 100644 --- a/Matlab/AirSimClient.m +++ b/Matlab/AirSimClient.m @@ -1126,6 +1126,32 @@ function simSetKinematics(obj, position, orientation, linear_velocity, angular_v CarState.handbrake = vehicleStateAirSim{"handbrake"}; end + function [ComputerVisionState] = getComputerVisionState(obj) + % GETCOMPUTERVISIONSTATE Get the current state of a computerVision vehicle + % + % Description: + % Retrieves and parses the current state of a computer vision vehicle from the AirSim API. + % + % Outputs: + % ComputerVisionState - Struct containing various state information: + % - kinematics_estimated: Estimated kinematic state including position, orientation, velocities, + % and accelerations. + % - timestamp: Timestamp of the state. + + vehicleStateAirSim = obj.rpc_client.call("getComputerVisionState", obj.vehicle_name); + + kinematicData = vehicleStateAirSim{"kinematics_estimated"}; + kinematicsState.position = obj.nedToRightHandCoordinates(struct2array(struct(kinematicData{"position"}))); + kinematicsState.orientation = quatinv(struct2array(struct(kinematicData{"orientation"}))); + kinematicsState.linear_velocity = obj.nedToRightHandCoordinates(struct2array(struct(kinematicData{"linear_velocity"}))); + kinematicsState.angular_velocity = obj.nedToRightHandCoordinates(struct2array(struct(kinematicData{"angular_velocity"}))); + kinematicsState.linear_acceleration = obj.nedToRightHandCoordinates(struct2array(struct(kinematicData{"linear_acceleration"}))); + kinematicsState.angular_acceleration = obj.nedToRightHandCoordinates(struct2array(struct(kinematicData{"angular_acceleration"}))); + ComputerVisionState.kinematics_estimated = kinematicsState; + + ComputerVisionState.timestamp = double(double(vehicleStateAirSim{"timestamp"}))/1e9; + end + function reset(obj) % RESET Reset the simulation environment diff --git a/Matlab/Cosys-AirSim Matlab API Client.mltbx b/Matlab/Cosys-AirSim Matlab API Client.mltbx index 967f54f28..22714c4bb 100644 Binary files a/Matlab/Cosys-AirSim Matlab API Client.mltbx and b/Matlab/Cosys-AirSim Matlab API Client.mltbx differ diff --git a/Matlab/Cosys-AirSim Matlab API Client.prj b/Matlab/Cosys-AirSim Matlab API Client.prj index 0454e954a..f4110c515 100644 --- a/Matlab/Cosys-AirSim Matlab API Client.prj +++ b/Matlab/Cosys-AirSim Matlab API Client.prj @@ -8,7 +8,7 @@ This a client implementation of the RPC API for Matlab for the Cosys-AirSim simulation framework. A main class AirSimClient is available which implements all API calls. Do note that at this point not all functions have been tested and most function documentation was auto-generated. This is still a WIP client. - 3.0.0.2 + 3.0.1.0 ${PROJECT_ROOT}\Cosys-AirSim Matlab API Client.mltbx Aerospace Toolbox @@ -105,7 +105,6 @@ Do note that at this point not all functions have been tested and most function ${PROJECT_ROOT}\AirSimCameraTypes.m - ${PROJECT_ROOT}\AirSimClient.asv ${PROJECT_ROOT}\AirSimClient.m ${PROJECT_ROOT}\AirSimDrivetrainTypes.m ${PROJECT_ROOT}\AirSimGenerateColorMap.m diff --git a/PythonClient/cosysairsim/__init__.py b/PythonClient/cosysairsim/__init__.py index fd4decf39..9110ef4b1 100644 --- a/PythonClient/cosysairsim/__init__.py +++ b/PythonClient/cosysairsim/__init__.py @@ -2,4 +2,4 @@ from .utils import * from .types import * -__version__ = "3.0.0" +__version__ = "3.0.1" diff --git a/PythonClient/cosysairsim/client.py b/PythonClient/cosysairsim/client.py index 805e12636..b485dd7a9 100644 --- a/PythonClient/cosysairsim/client.py +++ b/PythonClient/cosysairsim/client.py @@ -2268,7 +2268,7 @@ def getMultirotorState(self, vehicle_name=''): vehicle_name (str, optional): Vehicle to get the state of Returns: - MultirotorState: + MultirotorState: Struct containing multirotor state values """ return MultirotorState.from_msgpack(self.client.call('getMultirotorState', vehicle_name)) @@ -2313,7 +2313,7 @@ def getCarState(self, vehicle_name=''): vehicle_name (str, optional): Name of vehicle Returns: - CarState: + CarState: Struct containing car state values """ state_raw = self.client.call('getCarState', vehicle_name) return CarState.from_msgpack(state_raw) @@ -2324,7 +2324,26 @@ def getCarControls(self, vehicle_name=''): vehicle_name (str, optional): Name of vehicle Returns: - CarControls: + CarControls: Struct containing control values """ controls_raw = self.client.call('getCarControls', vehicle_name) return CarControls.from_msgpack(controls_raw) + + +#------------------------------ ComputerVision APIs --------------------------------------- +class ComputerVisionClient(VehicleClient, object): + def __init__(self, ip="", port=41451, timeout_value=3600): + super(ComputerVisionClient, self).__init__(ip, port, timeout_value) + + def getComputerVisionState(self, vehicle_name=''): + """ + The position inside the returned ComputerVisionState is in the frame of the vehicle's starting point + + Args: + vehicle_name (str, optional): Name of vehicle + + Returns: + ComputerVisionState: Struct containing computer vision state values + """ + state_raw = self.client.call('getComputerVisionState', vehicle_name) + return ComputerVisionState.from_msgpack(state_raw) \ No newline at end of file diff --git a/PythonClient/cosysairsim/types.py b/PythonClient/cosysairsim/types.py index e6dec8f6c..a33c21b40 100644 --- a/PythonClient/cosysairsim/types.py +++ b/PythonClient/cosysairsim/types.py @@ -407,6 +407,10 @@ class EnvironmentState(MsgpackMixin): temperature = 0.0 air_density = 0.0 +class ComputerVisionState(MsgpackMixin): + kinematics_estimated = KinematicsState() + timestamp = np.uint64(0) + class CarState(MsgpackMixin): speed = 0.0 gear = 0 diff --git a/PythonClient/pyproject.toml b/PythonClient/pyproject.toml index c64539f36..974dec520 100644 --- a/PythonClient/pyproject.toml +++ b/PythonClient/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "cosysairsim" -version = "3.0.0" +version = "3.0.1" description = "This package contains simple Python client for Cosys-AirSim. This integrates most API functions over RPC." readme = {file = "README.md", content-type = "text/markdown"} authors = [{ name = "Shital Shah", email = "shitals@microsoft.com" },