From f442b3b40c7fc4fd6f26eef3427e0605c9f172d9 Mon Sep 17 00:00:00 2001 From: Jotaro Date: Sun, 15 May 2022 18:40:04 +0200 Subject: [PATCH 1/2] added assignment-version of godObject.cpp --- firmware/src/physics/godObject.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/firmware/src/physics/godObject.cpp b/firmware/src/physics/godObject.cpp index 27329b5..3fd78b7 100644 --- a/firmware/src/physics/godObject.cpp +++ b/firmware/src/physics/godObject.cpp @@ -190,11 +190,25 @@ bool GodObject::move(bool isTweening, bool isForceRendering, bool isFrozen) } Vector2D GodObject::getCollisionForce(Vector2D godObjectPosition, Vector2D handlePosition){ - // the PID error is the difference between the virtual object and the handle position - // the virtual object can either be a) the godobject or b) the tether - auto error = godObjectPosition - handlePosition; - auto force = error * forcePidFactor[0][0] + (error - m_lastError) * forcePidFactor[0][2]; - m_lastError = error; + + // TODO: + // Given a position of god-object and the position of the handle, + // calculate rendering force. + + // Variables given: + // Vector2D godObjectPosition, handlePosition : position of god-object and handle. + // float K : proportional gain for force used in the god-object rendering. + + // Returns: + // Vector2D force, rendering force that you will apply to the device. + + const float K = forcePidFactor[0][0]; + Vector2D force = new Vector2D(0,0); + + // YOUR CODE STARTS + + + // YOUR CODE ENDS return force; } From 3ee5c843db1e2a4c6472137a5fe42e683b5d32d1 Mon Sep 17 00:00:00 2001 From: Jotaro Date: Sun, 15 May 2022 18:44:50 +0200 Subject: [PATCH 2/2] fixed code. --- firmware/src/physics/godObject.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firmware/src/physics/godObject.cpp b/firmware/src/physics/godObject.cpp index 3fd78b7..35e00a8 100644 --- a/firmware/src/physics/godObject.cpp +++ b/firmware/src/physics/godObject.cpp @@ -203,8 +203,8 @@ Vector2D GodObject::getCollisionForce(Vector2D godObjectPosition, Vector2D handl // Vector2D force, rendering force that you will apply to the device. const float K = forcePidFactor[0][0]; - Vector2D force = new Vector2D(0,0); - + Vector2D force = Vector2D(0,0); + // YOUR CODE STARTS