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

Buggy State Converter Rewrite #4

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

saransh323
Copy link

@saransh323 saransh323 commented Nov 6, 2024

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Rewrote/wrote a state converter node to convert raw_state to clean state for both SC and NAND. Benefits: unit and format conversion not done in arbitrary files anymore.

Related Tickets & Documents

  • Related Issue #
  • Closes #

QA Instructions, Screenshots, Recordings

Test this node by checking if the node converts raw values exactly as they were converted in pre-refactor code.

Added/updated tests?

We encourage you to keep the code coverage percentage at 80% and above.

  • Yes: tested with simulation and rosbag data, checked if conversion/copying is correctly executed for NAND/self, SC/self, and SC/other
  • No, and this is why: please replace this line with details on why tests
    have not been included
  • I need help with writing tests

[optional] Are there any post deployment tasks we need to perform?

raw_state topics have to be created and published to

[optional] What gif best describes this PR or how it makes you feel?

alt_text

def other_raw_state_callback(self, msg):
""" Callback for processing other/raw_state messages and publishing to other/state """
# Convert the /SC message and publish to other/state
converted_msg = self.convert_SC_state(msg)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other_raw_state wouldn't be of type SC, it would be a separate type, (take a look at ros2bnyahaj and host2comm from original repo, specifically for the Odometry class, that is what you are converting to.

ecef_z = msg.pose.pose.position.z

# Convert ECEF to UTM
utm_x, utm_y, _ = self.ecef_to_utm_transformer.transform(ecef_x, ecef_y, ecef_z)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might as well take utm_z and use that (doesn't hurt, and no point removing data)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okayy sounds good


# Use euler_from_quaternion to get roll, pitch, yaw
_, _, yaw = euler_from_quaternion([qx, qy, qz, qw])
yaw_aligned_east = yaw - np.pi / 2 # TODO: check if 0 is East

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quaternion and our internal heading should have the same heading, I wouldn't worry about this.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, take the other variables and it put into the function

_, _, yaw = euler_from_quaternion([qx, qy, qz, qw])
yaw_aligned_east = yaw - np.pi / 2 # TODO: check if 0 is East
# Store the heading in the x component of the orientation
converted_msg.pose.pose.orientation.x = yaw_aligned_east

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yaw is typically orientation.z, orientation.x, and orientation.y will be roll, pitch

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the wiki said x so I just followed that, do we want to use z everywhere instead?

converted_msg.pose.pose.orientation.w = 0.0

# ---- 3. Copy Covariances (Unchanged) ----
# TODO: check whether covariances should be copied over or not sent at all

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct, just uncomment it


# ---- 5. Copy Angular Velocities ----
converted_msg.twist.twist.angular.x = msg.twist.twist.angular.z # rad/s for heading change rate (using yaw from twist.angular)
converted_msg.twist.twist.angular.y = 0.0 # ignored

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to ignore it, just copy it on over. more data, isn't a problem necessarily

converted_msg.pose.pose.position.z = 0.0 # ignored

# ---- 2. Orientation in Radians with 0 at East ----
converted_msg.pose.pose.orientation.x = msg.pose.pose.orientation.x

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again oreitnation.z but correct idea

converted_msg.pose.pose.orientation.w = 0.0

# ---- 3. Copy Covariances (Unchanged) ----
# TODO: check whether covariances should be copied over or not sent at all

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We dont' get covariancs, so they will be initialized to whatever, don't comment it

return converted_msg

# replaced custom function with tf_transformations library function
def quaternion_to_yaw(self, qx, qy, qz, qw):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appreciate you using your own function, but I'm unsure if it's correct. Can you instead use the function in this library from tf.transformations import euler_from_quaternion

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it’s using the library, that’s just some old code from earlier, I’ll remove it

converted_msg.twist.twist.linear.z = msg.twist.twist.linear.z # Keep original Z velocity (??)

# ---- 5. Copy Angular Velocities ----
converted_msg.twist.twist.angular.x = msg.twist.twist.angular.z # rad/s for heading change rate (using yaw from twist.angular)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

swap

# converted_msg.twist.covariance = msg.twist.covariance

# ---- 4. Copy Linear Velocities ----
# TODO: check that ROS serial translator node changes scalar speed to velocity x/y components before pushing to raw_state

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thsi is done on our side

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants