Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roll angle control in CV mode/manual camera mode #2610

Merged
merged 1 commit into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions Unreal/Plugins/AirSim/Source/ManualPoseController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ void UManualPoseController::initializeForPlay()
left_mapping_ = FInputAxisKeyMapping("inputManualArrowLeft", EKeys::Left); right_mapping_ = FInputAxisKeyMapping("inputManualArrowRight", EKeys::Right);
forward_mapping_= FInputAxisKeyMapping("inputManualForward", EKeys::Up); backward_mapping_ = FInputAxisKeyMapping("inputManualBackward", EKeys::Down);
up_mapping_ = FInputAxisKeyMapping("inputManualArrowUp", EKeys::PageUp); down_mapping_ = FInputAxisKeyMapping("inputManualArrowDown", EKeys::PageDown);
left_yaw_mapping_ = FInputAxisKeyMapping("inputManualLeftYaw", EKeys::A); up_pitch_mapping_ = FInputAxisKeyMapping("inputManualUpPitch", EKeys::W);
right_yaw_mapping_ = FInputAxisKeyMapping("inputManualRightYaw", EKeys::D); down_pitch_mapping_ = FInputAxisKeyMapping("inputManualDownPitch", EKeys::S);
left_yaw_mapping_ = FInputAxisKeyMapping("inputManualLeftYaw", EKeys::A); right_yaw_mapping_ = FInputAxisKeyMapping("inputManualRightYaw", EKeys::D);
left_roll_mapping_ = FInputAxisKeyMapping("inputManualLefRoll", EKeys::Q); right_roll_mapping_ = FInputAxisKeyMapping("inputManualRightRoll", EKeys::E);
up_pitch_mapping_ = FInputAxisKeyMapping("inputManualUpPitch", EKeys::W); down_pitch_mapping_ = FInputAxisKeyMapping("inputManualDownPitch", EKeys::S);

input_positive_ = inpute_negative_ = last_velocity_ = FVector::ZeroVector;
}
Expand All @@ -20,7 +21,7 @@ void UManualPoseController::clearBindings()
{
left_binding_ = right_binding_ = up_binding_ = down_binding_ = nullptr;
forward_binding_ = backward_binding_ = left_yaw_binding_ = up_pitch_binding_ = nullptr;
right_yaw_binding_ = down_pitch_binding_ = nullptr;
right_yaw_binding_ = down_pitch_binding_ = left_roll_binding_ = right_roll_binding_ = nullptr;
}

void UManualPoseController::setActor(AActor* actor)
Expand Down Expand Up @@ -86,10 +87,14 @@ void UManualPoseController::removeInputBindings()
UAirBlueprintLib::RemoveAxisBinding(down_mapping_, down_binding_, actor_);
if (left_yaw_binding_)
UAirBlueprintLib::RemoveAxisBinding(left_yaw_mapping_, left_yaw_binding_, actor_);
if (up_pitch_binding_)
UAirBlueprintLib::RemoveAxisBinding(up_pitch_mapping_, up_pitch_binding_, actor_);
if (right_yaw_binding_)
UAirBlueprintLib::RemoveAxisBinding(right_yaw_mapping_, right_yaw_binding_, actor_);
if (left_roll_binding_)
UAirBlueprintLib::RemoveAxisBinding(left_roll_mapping_, left_roll_binding_, actor_);
if (right_roll_binding_)
UAirBlueprintLib::RemoveAxisBinding(right_roll_mapping_, right_roll_binding_, actor_);
if (up_pitch_binding_)
UAirBlueprintLib::RemoveAxisBinding(up_pitch_mapping_, up_pitch_binding_, actor_);
if (down_pitch_binding_)
UAirBlueprintLib::RemoveAxisBinding(down_pitch_mapping_, down_pitch_binding_, actor_);

Expand All @@ -107,8 +112,10 @@ void UManualPoseController::setupInputBindings()
up_binding_ = & UAirBlueprintLib::BindAxisToKey(up_mapping_, actor_, this, &UManualPoseController::inputManualMoveUp);
down_binding_ = & UAirBlueprintLib::BindAxisToKey(down_mapping_, actor_, this, &UManualPoseController::inputManualDown);
left_yaw_binding_ = & UAirBlueprintLib::BindAxisToKey(left_yaw_mapping_, actor_, this, &UManualPoseController::inputManualLeftYaw);
up_pitch_binding_ = & UAirBlueprintLib::BindAxisToKey(up_pitch_mapping_, actor_, this, &UManualPoseController::inputManualUpPitch);
right_yaw_binding_ = & UAirBlueprintLib::BindAxisToKey(right_yaw_mapping_, actor_, this, &UManualPoseController::inputManualRightYaw);
left_roll_binding_ = & UAirBlueprintLib::BindAxisToKey(left_roll_mapping_, actor_, this, &UManualPoseController::inputManualLeftRoll);
right_roll_binding_ = & UAirBlueprintLib::BindAxisToKey(right_roll_mapping_, actor_, this, &UManualPoseController::inputManualRightRoll);
up_pitch_binding_ = & UAirBlueprintLib::BindAxisToKey(up_pitch_mapping_, actor_, this, &UManualPoseController::inputManualUpPitch);
down_pitch_binding_ = & UAirBlueprintLib::BindAxisToKey(down_pitch_mapping_, actor_, this, &UManualPoseController::inputManualDownPitch);
}

Expand Down Expand Up @@ -155,15 +162,25 @@ void UManualPoseController::inputManualLeftYaw(float val)
if (!FMath::IsNearlyEqual(val, 0.f))
delta_rotation_.Add(0, -val, 0);
}
void UManualPoseController::inputManualUpPitch(float val)
void UManualPoseController::inputManualRightYaw(float val)
{
if (!FMath::IsNearlyEqual(val, 0.f))
delta_rotation_.Add(val, 0, 0);
delta_rotation_.Add(0, val, 0);
}
void UManualPoseController::inputManualRightYaw(float val)
void UManualPoseController::inputManualLeftRoll(float val)
{
if (!FMath::IsNearlyEqual(val, 0.f))
delta_rotation_.Add(0, val, 0);
delta_rotation_.Add(0, 0, -val);
}
void UManualPoseController::inputManualRightRoll(float val)
{
if (!FMath::IsNearlyEqual(val, 0.f))
delta_rotation_.Add(0, 0, val);
}
void UManualPoseController::inputManualUpPitch(float val)
{
if (!FMath::IsNearlyEqual(val, 0.f))
delta_rotation_.Add(val, 0, 0);
}
void UManualPoseController::inputManualDownPitch(float val)
{
Expand Down
12 changes: 7 additions & 5 deletions Unreal/Plugins/AirSim/Source/ManualPoseController.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ class AIRSIM_API UManualPoseController : public UObject {
void inputManualMoveUp(float val);
void inputManualDown(float val);
void inputManualLeftYaw(float val);
void inputManualUpPitch(float val);
void inputManualRightYaw(float val);
void inputManualLeftRoll(float val);
void inputManualRightRoll(float val);
void inputManualUpPitch(float val);
void inputManualDownPitch(float val);

void setupInputBindings();
Expand All @@ -37,12 +39,12 @@ class AIRSIM_API UManualPoseController : public UObject {

private:
FInputAxisBinding *left_binding_, *right_binding_, *up_binding_, *down_binding_;
FInputAxisBinding *forward_binding_, *backward_binding_, *left_yaw_binding_, *up_pitch_binding_;
FInputAxisBinding *right_yaw_binding_, *down_pitch_binding_;
FInputAxisBinding *forward_binding_, *backward_binding_, *left_yaw_binding_, *right_yaw_binding_;
FInputAxisBinding *up_pitch_binding_, *down_pitch_binding_, *left_roll_binding_, *right_roll_binding_;

FInputAxisKeyMapping left_mapping_, right_mapping_, up_mapping_, down_mapping_;
FInputAxisKeyMapping forward_mapping_, backward_mapping_, left_yaw_mapping_, up_pitch_mapping_;
FInputAxisKeyMapping right_yaw_mapping_, down_pitch_mapping_;
FInputAxisKeyMapping forward_mapping_, backward_mapping_, left_yaw_mapping_, right_yaw_mapping_;
FInputAxisKeyMapping up_pitch_mapping_, down_pitch_mapping_, left_roll_mapping_, right_roll_mapping_;


FVector delta_position_;
Expand Down