Skip to content

Commit

Permalink
Initialize Odom message when motorcontrol is set
Browse files Browse the repository at this point in the history
  • Loading branch information
hyunseok-yang committed Dec 2, 2024
1 parent 7089847 commit 909ba8e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions Assets/Scripts/Devices/MicomSensor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,20 @@ protected override void InitializeMessages()
{
micomSensorData = new messages.Micom();
micomSensorData.Time = new messages.Time();
micomSensorData.Odom = null;
micomSensorData.uss = new messages.Micom.Uss();
micomSensorData.ir = new messages.Micom.Ir();
micomSensorData.bumper = new messages.Micom.Bumper();
}

private void InitializeOdometryMessage()
{
micomSensorData.Odom = new messages.Micom.Odometry();
micomSensorData.Odom.AngularVelocity = new messages.Micom.Odometry.Wheel();
micomSensorData.Odom.LinearVelocity = new messages.Micom.Odometry.Wheel();
micomSensorData.Odom.Pose = new messages.Vector3d();
micomSensorData.Odom.TwistLinear = new messages.Vector3d();
micomSensorData.Odom.TwistAngular = new messages.Vector3d();
micomSensorData.uss = new messages.Micom.Uss();
micomSensorData.ir = new messages.Micom.Ir();
micomSensorData.bumper = new messages.Micom.Bumper();
}

protected override void GenerateMessage()
Expand All @@ -188,6 +193,11 @@ void FixedUpdate()

if (_motorControl != null)
{
if (micomSensorData.Odom == null)
{
InitializeOdometryMessage();
}

if (_motorControl.Update(micomSensorData.Odom, deltaTime, _imuSensor) == false)
{
Debug.LogWarning("Update failed in MotorControl");
Expand Down

0 comments on commit 909ba8e

Please sign in to comment.