Skip to content
Open
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
22 changes: 11 additions & 11 deletions Assets/RosMessages/Auv/msg/ThrusterForcesMsg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public ThrusterForcesMsg()
this.HEAVE_BACK_RIGHT = 0.0;
}

public ThrusterForcesMsg(double FRONT_LEFT, double FRONT_RIGHT, double BACK_LEFT, double BACK_RIGHT, double HEAVE_FRONT_LEFT, double HEAVE_FRONT_RIGHT, double HEAVE_BACK_LEFT, double HEAVE_BACK_RIGHT)
public ThrusterForcesMsg(double BACK_RIGHT, double HEAVE_BACK_RIGHT, double HEAVE_FRONT_RIGHT, double FRONT_RIGHT, double FRONT_LEFT, double HEAVE_FRONT_LEFT, double HEAVE_BACK_LEFT, double BACK_LEFT)
{
this.FRONT_LEFT = FRONT_LEFT;
this.FRONT_RIGHT = FRONT_RIGHT;
Expand All @@ -51,26 +51,26 @@ public ThrusterForcesMsg(double FRONT_LEFT, double FRONT_RIGHT, double BACK_LEFT

private ThrusterForcesMsg(MessageDeserializer deserializer)
{
deserializer.Read(out this.FRONT_LEFT);
deserializer.Read(out this.FRONT_RIGHT);
deserializer.Read(out this.BACK_LEFT);
deserializer.Read(out this.BACK_RIGHT);
deserializer.Read(out this.HEAVE_FRONT_LEFT);
deserializer.Read(out this.HEAVE_BACK_RIGHT);
deserializer.Read(out this.HEAVE_FRONT_RIGHT);
deserializer.Read(out this.FRONT_RIGHT);
deserializer.Read(out this.FRONT_LEFT);
deserializer.Read(out this.HEAVE_FRONT_LEFT);
deserializer.Read(out this.HEAVE_BACK_LEFT);
deserializer.Read(out this.HEAVE_BACK_RIGHT);
deserializer.Read(out this.BACK_LEFT);
}

public override void SerializeTo(MessageSerializer serializer)
{
serializer.Write(this.FRONT_LEFT);
serializer.Write(this.FRONT_RIGHT);
serializer.Write(this.BACK_LEFT);
serializer.Write(this.BACK_RIGHT);
serializer.Write(this.HEAVE_FRONT_LEFT);
serializer.Write(this.HEAVE_BACK_RIGHT);
serializer.Write(this.HEAVE_FRONT_RIGHT);
serializer.Write(this.FRONT_RIGHT);
serializer.Write(this.FRONT_LEFT);
serializer.Write(this.HEAVE_FRONT_LEFT);
serializer.Write(this.HEAVE_BACK_LEFT);
serializer.Write(this.HEAVE_BACK_RIGHT);
serializer.Write(this.BACK_LEFT);
}

public override string ToString()
Expand Down
14 changes: 7 additions & 7 deletions Assets/RosMessages/Auv/msg/ThrusterMicrosecondsMsg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ public class ThrusterMicrosecondsMsg : Message
public override string RosMessageName => k_RosMessageName;

// Thruster definitions
public const byte FRONT_LEFT = 0;
public const byte FRONT_RIGHT = 1;
public const byte BACK_LEFT = 2;
public const byte BACK_RIGHT = 3;
public const byte HEAVE_FRONT_LEFT = 4;
public const byte HEAVE_FRONT_RIGHT = 5;
public const byte BACK_RIGHT = 0;
public const byte HEAVE_BACK_RIGHT = 1;
public const byte HEAVE_FRONT_RIGHT = 2;
public const byte FRONT_RIGHT = 3;
public const byte FRONT_LEFT = 4;
public const byte HEAVE_FRONT_LEFT = 5;
public const byte HEAVE_BACK_LEFT = 6;
public const byte HEAVE_BACK_RIGHT = 7;
public const byte BACK_LEFT = 7;
public ushort[] microseconds;

public ThrusterMicrosecondsMsg()
Expand Down
106 changes: 53 additions & 53 deletions Assets/RosMessages/Auv/msg/UnityStateMsg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ public class UnityStateMsg : Message
public Geometry.Vector3Msg angular_velocity;
public Geometry.Vector3Msg linear_acceleration;
public int[] frequencies;
public uint[] times_pinger_1;
public uint[] times_pinger_2;
public uint[] times_pinger_3;
public uint[] times_pinger_4;
public int isDVLActive;
public int isDepthSensorActive;
public int isIMUActive;
public int isHydrophonesActive;
public uint[] hydrophone_one_freqs;
public uint[] hydrophone_two_freqs;
public uint[] hydrophone_three_freqs;
public uint[] hydrophone_four_freqs;
public int is_dvl_active;
public int is_depth_sensor_active;
public int is_imu_active;
public int is_hydrophones_active;

public UnityStateMsg()
{
Expand All @@ -36,32 +36,32 @@ public UnityStateMsg()
this.angular_velocity = new Geometry.Vector3Msg();
this.linear_acceleration = new Geometry.Vector3Msg();
this.frequencies = new int[0];
this.times_pinger_1 = new uint[0];
this.times_pinger_2 = new uint[0];
this.times_pinger_3 = new uint[0];
this.times_pinger_4 = new uint[0];
this.isDVLActive = 0;
this.isDepthSensorActive = 0;
this.isIMUActive = 0;
this.isHydrophonesActive = 0;
this.hydrophone_one_freqs = new uint[0];
this.hydrophone_two_freqs = new uint[0];
this.hydrophone_three_freqs = new uint[0];
this.hydrophone_four_freqs = new uint[0];
this.is_dvl_active = 0;
this.is_depth_sensor_active = 0;
this.is_imu_active = 0;
this.is_hydrophones_active = 0;
}

public UnityStateMsg(Geometry.Vector3Msg position, Geometry.QuaternionMsg orientation, Geometry.Vector3Msg velocity, Geometry.Vector3Msg angular_velocity, Geometry.Vector3Msg linear_acceleration, int[] frequencies, uint[] times_pinger_1, uint[] times_pinger_2, uint[] times_pinger_3, uint[] times_pinger_4, int isDVLActive, int isDepthSensorActive, int isIMUActive, int isHydrophonesActive)
public UnityStateMsg(Geometry.Vector3Msg position, Geometry.QuaternionMsg orientation, Geometry.Vector3Msg velocity, Geometry.Vector3Msg angular_velocity, Geometry.Vector3Msg linear_acceleration, int[] frequencies, uint[] hydrophone_one_freqs, uint[] hydrophone_two_freqs, uint[] hydrophone_three_freqs, uint[] hydrophone_four_freqs, int is_dvl_active, int is_depth_sensor_active, int is_imu_active, int is_hydrophones_active)
{
this.position = position;
this.orientation = orientation;
this.velocity = velocity;
this.angular_velocity = angular_velocity;
this.linear_acceleration = linear_acceleration;
this.frequencies = frequencies;
this.times_pinger_1 = times_pinger_1;
this.times_pinger_2 = times_pinger_2;
this.times_pinger_3 = times_pinger_3;
this.times_pinger_4 = times_pinger_4;
this.isDVLActive = isDVLActive;
this.isDepthSensorActive = isDepthSensorActive;
this.isIMUActive = isIMUActive;
this.isHydrophonesActive = isHydrophonesActive;
this.hydrophone_one_freqs = hydrophone_one_freqs;
this.hydrophone_two_freqs = hydrophone_two_freqs;
this.hydrophone_three_freqs = hydrophone_three_freqs;
this.hydrophone_four_freqs = hydrophone_four_freqs;
this.is_dvl_active = is_dvl_active;
this.is_depth_sensor_active = is_depth_sensor_active;
this.is_imu_active = is_imu_active;
this.is_hydrophones_active = is_hydrophones_active;
}

public static UnityStateMsg Deserialize(MessageDeserializer deserializer) => new UnityStateMsg(deserializer);
Expand All @@ -74,14 +74,14 @@ private UnityStateMsg(MessageDeserializer deserializer)
this.angular_velocity = Geometry.Vector3Msg.Deserialize(deserializer);
this.linear_acceleration = Geometry.Vector3Msg.Deserialize(deserializer);
deserializer.Read(out this.frequencies, sizeof(int), deserializer.ReadLength());
deserializer.Read(out this.times_pinger_1, sizeof(uint), deserializer.ReadLength());
deserializer.Read(out this.times_pinger_2, sizeof(uint), deserializer.ReadLength());
deserializer.Read(out this.times_pinger_3, sizeof(uint), deserializer.ReadLength());
deserializer.Read(out this.times_pinger_4, sizeof(uint), deserializer.ReadLength());
deserializer.Read(out this.isDVLActive);
deserializer.Read(out this.isDepthSensorActive);
deserializer.Read(out this.isIMUActive);
deserializer.Read(out this.isHydrophonesActive);
deserializer.Read(out this.hydrophone_one_freqs, sizeof(uint), deserializer.ReadLength());
deserializer.Read(out this.hydrophone_two_freqs, sizeof(uint), deserializer.ReadLength());
deserializer.Read(out this.hydrophone_three_freqs, sizeof(uint), deserializer.ReadLength());
deserializer.Read(out this.hydrophone_four_freqs, sizeof(uint), deserializer.ReadLength());
deserializer.Read(out this.is_dvl_active);
deserializer.Read(out this.is_depth_sensor_active);
deserializer.Read(out this.is_imu_active);
deserializer.Read(out this.is_hydrophones_active);
}

public override void SerializeTo(MessageSerializer serializer)
Expand All @@ -93,18 +93,18 @@ public override void SerializeTo(MessageSerializer serializer)
serializer.Write(this.linear_acceleration);
serializer.WriteLength(this.frequencies);
serializer.Write(this.frequencies);
serializer.WriteLength(this.times_pinger_1);
serializer.Write(this.times_pinger_1);
serializer.WriteLength(this.times_pinger_2);
serializer.Write(this.times_pinger_2);
serializer.WriteLength(this.times_pinger_3);
serializer.Write(this.times_pinger_3);
serializer.WriteLength(this.times_pinger_4);
serializer.Write(this.times_pinger_4);
serializer.Write(this.isDVLActive);
serializer.Write(this.isDepthSensorActive);
serializer.Write(this.isIMUActive);
serializer.Write(this.isHydrophonesActive);
serializer.WriteLength(this.hydrophone_one_freqs);
serializer.Write(this.hydrophone_one_freqs);
serializer.WriteLength(this.hydrophone_two_freqs);
serializer.Write(this.hydrophone_two_freqs);
serializer.WriteLength(this.hydrophone_three_freqs);
serializer.Write(this.hydrophone_three_freqs);
serializer.WriteLength(this.hydrophone_four_freqs);
serializer.Write(this.hydrophone_four_freqs);
serializer.Write(this.is_dvl_active);
serializer.Write(this.is_depth_sensor_active);
serializer.Write(this.is_imu_active);
serializer.Write(this.is_hydrophones_active);
}

public override string ToString()
Expand All @@ -116,14 +116,14 @@ public override string ToString()
"\nangular_velocity: " + angular_velocity.ToString() +
"\nlinear_acceleration: " + linear_acceleration.ToString() +
"\nfrequencies: " + System.String.Join(", ", frequencies.ToList()) +
"\ntimes_pinger_1: " + System.String.Join(", ", times_pinger_1.ToList()) +
"\ntimes_pinger_2: " + System.String.Join(", ", times_pinger_2.ToList()) +
"\ntimes_pinger_3: " + System.String.Join(", ", times_pinger_3.ToList()) +
"\ntimes_pinger_4: " + System.String.Join(", ", times_pinger_4.ToList()) +
"\nisDVLActive: " + isDVLActive.ToString() +
"\nisDepthSensorActive: " + isDepthSensorActive.ToString() +
"\nisIMUActive: " + isIMUActive.ToString() +
"\nisHydrophonesActive: " + isHydrophonesActive.ToString();
"\nhydrophone_one_freqs: " + System.String.Join(", ", hydrophone_one_freqs.ToList()) +
"\nhydrophone_two_freqs: " + System.String.Join(", ", hydrophone_two_freqs.ToList()) +
"\nhydrophone_three_freqs: " + System.String.Join(", ", hydrophone_three_freqs.ToList()) +
"\nhydrophone_four_freqs: " + System.String.Join(", ", hydrophone_four_freqs.ToList()) +
"\nis_dvl_active: " + is_dvl_active.ToString() +
"\nis_depth_sensor_active: " + is_depth_sensor_active.ToString() +
"\nis_imu_active: " + is_imu_active.ToString() +
"\nis_hydrophones_active: " + is_hydrophones_active.ToString();
}

#if UNITY_EDITOR
Expand Down
56 changes: 28 additions & 28 deletions Assets/Scripts/StatePublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public class StatePublisher : MonoBehaviour

private RosMessageTypes.Auv.UnityStateMsg stateMsg = new RosMessageTypes.Auv.UnityStateMsg();
private float timeSinceLastPublish;
private bool isDVLActive;
private bool isDepthSensorActive;
private bool isIMUActive;
private bool isHydrophonesActive;
private bool is_dvl_active;
private bool is_depth_sensor_active;
private bool is_imu_active;
private bool is_hydrophones_active;
private bool publishToRos;
private float timeBetweenPublishes = 0.1f;

Expand Down Expand Up @@ -62,10 +62,10 @@ private void Initialize()
classLogicManager = FindObjectOfType<LogicManager1>();
if (classLogicManager != null)
{
SubscribeToggle(classLogicManager.PublishDVLToggle, SetisDVLActive);
SubscribeToggle(classLogicManager.PublishDepthToggle, SetisDepthSensorActive);
SubscribeToggle(classLogicManager.PublishIMUToggle, SetisIMUActive);
SubscribeToggle(classLogicManager.PublishHydrophonesToggle, SetisHydrophonesActive);
SubscribeToggle(classLogicManager.PublishDVLToggle, Setis_dvl_active);
SubscribeToggle(classLogicManager.PublishDepthToggle, Setis_depth_sensor_active);
SubscribeToggle(classLogicManager.PublishIMUToggle, Setis_imu_active);
SubscribeToggle(classLogicManager.PublishHydrophonesToggle, Setis_hydrophones_active);
SubscribeToggle(classLogicManager.PublishROSToggle, SetPublishToRos);
}
else
Expand Down Expand Up @@ -93,11 +93,11 @@ private void FixedUpdate()
private void OnDestroy()
{
// Unsubscribe from the events to prevent memory leaks.
UnsubscribeToggle(classLogicManager.PublishDVLToggle, SetisDVLActive);
UnsubscribeToggle(classLogicManager.PublishDVLToggle, Setis_dvl_active);
UnsubscribeToggle(classLogicManager.PublishROSToggle, SetPublishToRos);
UnsubscribeToggle(classLogicManager.PublishDepthToggle, SetisDepthSensorActive);
UnsubscribeToggle(classLogicManager.PublishIMUToggle, SetisIMUActive);
UnsubscribeToggle(classLogicManager.PublishHydrophonesToggle, SetisHydrophonesActive);
UnsubscribeToggle(classLogicManager.PublishDepthToggle, Setis_depth_sensor_active);
UnsubscribeToggle(classLogicManager.PublishIMUToggle, Setis_imu_active);
UnsubscribeToggle(classLogicManager.PublishHydrophonesToggle, Setis_hydrophones_active);
}

private void SendState()
Expand All @@ -122,16 +122,16 @@ private void SendState()
stateMsg.angular_velocity = auvRb.angularVelocity.To<RUF>();
stateMsg.velocity = currentVelocity.To<RUF>();
stateMsg.frequencies = frequencies;
stateMsg.times_pinger_1 = times[0];
stateMsg.times_pinger_2 = times[1];
stateMsg.times_pinger_3 = times[2];
stateMsg.times_pinger_4 = times[3];
stateMsg.hydrophone_one_freqs = times[0];
stateMsg.hydrophone_two_freqs = times[1];
stateMsg.hydrophone_three_freqs = times[2];
stateMsg.hydrophone_four_freqs = times[3];
stateMsg.linear_acceleration = acceleration.To<RUF>();

stateMsg.isDVLActive = Convert.ToInt32(isDVLActive);
stateMsg.isDepthSensorActive = Convert.ToInt32(isDepthSensorActive);
stateMsg.isIMUActive = Convert.ToInt32(isIMUActive);
stateMsg.isHydrophonesActive = Convert.ToInt32(isHydrophonesActive);
stateMsg.is_dvl_active = Convert.ToInt32(is_dvl_active);
stateMsg.is_depth_sensor_active = Convert.ToInt32(is_depth_sensor_active);
stateMsg.is_imu_active = Convert.ToInt32(is_imu_active);
stateMsg.is_hydrophones_active = Convert.ToInt32(is_hydrophones_active);

roscon.Publish(stateTopicName, stateMsg);

Expand Down Expand Up @@ -163,24 +163,24 @@ private void UnsubscribeToggle(Toggle toggle, Action<bool> updateAction)
}
}

private void SetisDVLActive(bool active)
private void Setis_dvl_active(bool active)
{
isDVLActive = active;
is_hydrophones_active = active;
}

private void SetisDepthSensorActive(bool active)
private void Setis_depth_sensor_active(bool active)
{
isDepthSensorActive = active;
is_depth_sensor_active = active;
}

private void SetisIMUActive(bool active)
private void Setis_imu_active(bool active)
{
isIMUActive = active;
is_imu_active = active;
}

private void SetisHydrophonesActive(bool active)
private void Setis_hydrophones_active(bool active)
{
isHydrophonesActive = active;
is_hydrophones_active = active;
}

private void SetPublishToRos(bool active)
Expand Down
14 changes: 7 additions & 7 deletions Assets/Scripts/Thrusters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@ private void HandleMovementInput()

private void SetThrusterForces(RosMessageTypes.Auv.ThrusterForcesMsg msg)
{
rosThrusterForces[0] = msg.FRONT_LEFT;
rosThrusterForces[1] = msg.FRONT_RIGHT;
rosThrusterForces[2] = msg.BACK_LEFT;
rosThrusterForces[3] = msg.BACK_RIGHT;
rosThrusterForces[4] = msg.HEAVE_FRONT_LEFT;
rosThrusterForces[5] = msg.HEAVE_FRONT_RIGHT;
rosThrusterForces[0] = msg.BACK_RIGHT;
rosThrusterForces[1] = msg.HEAVE_BACK_RIGHT;
rosThrusterForces[2] = msg.HEAVE_FRONT_RIGHT;
rosThrusterForces[3] = msg.FRONT_RIGHT;
rosThrusterForces[4] = msg.FRONT_LEFT;
rosThrusterForces[5] = msg.HEAVE_FRONT_LEFT;
rosThrusterForces[6] = msg.HEAVE_BACK_LEFT;
rosThrusterForces[7] = msg.HEAVE_BACK_RIGHT;
rosThrusterForces[7] = msg.BACK_LEFT;
}
}