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

henthorn/sim pblog #44

Merged
merged 25 commits into from
May 29, 2023
Merged

henthorn/sim pblog #44

merged 25 commits into from
May 29, 2023

Conversation

rhenthorn
Copy link
Collaborator

I believe all changes are contained in the sim_pblog folder in buoy_msgs.

@mabelzhang mabelzhang linked an issue Apr 3, 2023 that may be closed by this pull request
@quarkytale
Copy link
Contributor

Any specific reason the logger's named sim_pblog? I was wondering if it could be consistent with pbcmd and just be plain pblog?

sim_pblog/.gitignore Outdated Show resolved Hide resolved
@hamilton8415
Copy link
Collaborator

I am running this feature and it looks great, I do have a few comments, and I will try to get them appropriately spread between this PR, #47 in mbari_wec_utils, and #140 in mbari_wec_gz, but we may have to review all of these together...

For this PR,

  • inside the directory such as 2023-05-02.000, maybe we can have the link be called "latest" to match the buoy behaviors. I understand a level up it's called latest_csv to differentiate it from the name latest that is used/created by colcon. I have a note about this default in Add pblog args #47 too.
  • There is no controller Setup CI #5 in the buoy, so I'm not sure where the line beginning with 5 in the log files is coming from. Possibly from a defunct rudder controller. In any event, the numbers are 0 = Battery controller, 1 = Spring Controller, 2 = Power Converter, 3 = buoy based AHRS (NAV440), and 4 = HeaveConeController.
  • It's a neat trick to gzip the latest file when the program closes, but we may want to only zip files at the end of each hour. This then matches the buoy behavior, and also, an hour is a very long sim time so multi-hour sims will be rare, by not zipping, it's a bit quicker to look at any given output.

I'm running a 10's of minute sim now and will run the logfile output through the matlab processing next to see how that looks.

@hamilton8415
Copy link
Collaborator

Looking more closely, the data isn't quite being placed in the .csv file quite correctly. Here's what I see in my example.

Line with first character = "0", should have battery data, and does in the correct places. :)
Line with first character = "1", should have spring data, and does seem to based on the values, but the data is in the wrong columns.
Line with first character = "2", Should have power converter data, and does in the correct places. :)
Line with first character = "3", Should have data from the NAV440 AHRS, but no lines starting with "3" exist
Line with first character = "4", should have data for the Heave cone, and does seem to based on the values, but the data is in the wrong columns.
Line with first character = "5", there is no controller 5 in this system, I can't quite tell what the data in these rows is but for sure it shouldn't be starting with a "5".

So, some issues, seemingly largely to do the the wrong number of commas. Want me to sing the song??

@rhenthorn
Copy link
Collaborator Author

I mixed-up the controller ids that go in the first column. That also causes the wrong number of empty columns (commas) to show up. This ought to be a one-line fix (CrossbowId = 3, not 5). I regret the error.

@hamilton8415
Copy link
Collaborator

hamilton8415 commented May 3, 2023 via email

@andermi andermi mentioned this pull request May 3, 2023
@rhenthorn
Copy link
Collaborator Author

Pushed. The zipped file behavior is an artifact of the gzip class from the gzip package.

andermi and others added 2 commits May 3, 2023 15:43
* add launch args for log paths; add ros2 param for interval; fix symlinks; add rosdeps

Signed-off-by: Michael Anderson <[email protected]>

* Update package.xml

fix rosdep

* fix atexit gzip

Signed-off-by: Michael Anderson <[email protected]>

* linter

Signed-off-by: Michael Anderson <[email protected]>

* update default pblog root; stop gzipping at exit; fix gzipping at start

Signed-off-by: Michael Anderson <[email protected]>

* remove unused import

Signed-off-by: Michael Anderson <[email protected]>

* Correct faulty CrossbowID value from 5 to 3

---------

Signed-off-by: Michael Anderson <[email protected]>
Co-authored-by: Rich Henthorn <[email protected]>
@hamilton8415
Copy link
Collaborator

Although controller number five is gone and there is data in controller number three, things are still not landing in the correct columns for some of the controllers. I find a good way to check this is to open the .csv in excel, that separates all the values (based on the commas) underneath the named column. I suppose this way of checking isn't correct and introducing a mis-understanding, but I think excel is reliable for this and some of the controllers are putting things in the correct place,

…record when xb_header, bc_header, and sc_header should have been used
@mabelzhang
Copy link
Collaborator

How are you getting the sim time?

If you are writing a Gazebo plugin, it would be free, as it comes in the parameter to the update function.
I see that you aren't writing a Gazebo plugin here.

In the Gazebo world, it is published as a topic

$ gz topic -e -t /world/world_demo/stats
sim_time {
  sec: 2
  nsec: 864000000
}
real_time {
  sec: 12
  nsec: 993655180
}
iterations: 2864
real_time_factor: 0.2707

Does ros_gz_bridge not let you get the Gazebo topic over to ROS 2? For example 14:42 in the talk here that Michael Carroll and Dharini gave https://vimeo.com/showcase/9954564/video/767127300

@andermi
Copy link
Collaborator

andermi commented May 11, 2023

We are using the ros_gz_bridge to get sim time to the ros node in the plugin to publish the controller messages. The problem is rclcpp::Rate doesn't have any implementation yet that uses sim time and we are using the Rate to control publish rates... so if you check my PR over in _gz, I made one :)

osrf/mbari_wec_gz#146

@andermi
Copy link
Collaborator

andermi commented May 11, 2023

@hamilton8415 @rhenthorn I believe the logs are working correctly now. The way the timestamps are set up in the csv logs is that it looks as if the logs are written in real time from the time the log started. So the logs will still show 10Hz timestamps even though in wall-time it's churning out data at 20Hz for RTF 2 for example.

I believe this is all working as intended now.

Signed-off-by: Michael Anderson <[email protected]>
* add async proxy to await future for pack rate calls

Signed-off-by: Michael Anderson <[email protected]>

* typo

Signed-off-by: Michael Anderson <[email protected]>

---------

Signed-off-by: Michael Anderson <[email protected]>
Signed-off-by: Michael Anderson <[email protected]>
@andermi
Copy link
Collaborator

andermi commented May 16, 2023

@hamilton8415 Latest patch uses line buffering for csv files :) nicer looking tail -f

@hamilton8415
Copy link
Collaborator

For sure. Thanks. Has the same buffering behavior as the buoy now. Much better.

Signed-off-by: Michael Anderson <[email protected]>
@andermi
Copy link
Collaborator

andermi commented May 16, 2023

The IMU sensor quaternions look fine all along the chain from the sensor to the csv. The IMU in the sim is located at the link origin where the tether meets the heave cone and is in ENU orientation.

@hamilton8415
Copy link
Collaborator

The IMU sensor quaternions look fine all along the chain from the sensor to the csv. The IMU in the sim is located at the link origin where the tether meets the heave cone and is in ENU orientation.

Thanks for checking this. I am able to resolve the pitch/roll/yaw of the heave-cone from this data, but things are rotated by 90 degrees from what the buoy outputs. On the buoy those items come directly off the VectorNav VN-100, so we may need to look into the orientation of that sensor relative to the heave-cone orientation. Or, just make a rotation until the sim data matches the buoy data with regard to which axis points up. The horizontal axes aren't really distinguishable. I think I may be able to say which way things need to be rotated to match...

@andermi
Copy link
Collaborator

andermi commented May 16, 2023

orientation of that sensor relative to the heave-cone orientation

We can certainly rotate the sensor frame wrt the link

sim_pblog/sim_pblog/sim_pblog.py Show resolved Hide resolved
sim_pblog/sim_pblog/sim_pblog.py Outdated Show resolved Hide resolved
@andermi
Copy link
Collaborator

andermi commented May 16, 2023

@hamilton8415 latest patch fixes the data loss when log rolling

tail of previous log

4, 1684274770.983, ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,60, 48.000, 48.000, -42.169, -0.012, -0.005, -0.064, 0.998, 0.000, 0.000, -0.000, 0, -0.002, -0.032, 0.125, 0, -0.072, -0.228, 9.595, 60, 0, 0, 0,

head of new log

1, 1684274771.073, ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,10493, 0.47, 46.71, 158.31, 8192, 0, 0.000000, 0.000, ,,,,,,,,,,,,,,,,,,,,,,,

Signed-off-by: Michael Anderson <[email protected]>
Signed-off-by: Michael Anderson <[email protected]>
Signed-off-by: Michael Anderson <[email protected]>
@hamilton8415
Copy link
Collaborator

With respect to the IMU mounted in the heave cone. x-y-z axis of the device itself is mounted on the heave cone with it's y and z-azis pointing horizontally. I am not yet sure of the x-axis is pointing towards the top or the bottom of the heave cone, the quaternion multiplication I use to make z point upwards for subsequent computation of heave/pitch/yaw Euler angles is below, so there's a hint in that...

qmult(TC_Qtn,[sqrt(.5) 0 -sqrt(.5) 0]); %Rotate sensor 90 degrees about y-axis to make z point up.

@andermi
Copy link
Collaborator

andermi commented May 17, 2023

Strange, because I checked the mesh origin yesterday, and the Z axis was pointing up. The IMU should be coincident with this with Z up as well. I'll keep digging

@hamilton8415
Copy link
Collaborator

I think it makes some sense, the physical IMU is mounted with z horizontal (when the heave-cone is in the rest position) and therefore the simulated IMU needs to be mounted the same. Or, the output rotated...

@andermi
Copy link
Collaborator

andermi commented May 17, 2023

Oh oops, I just re-read your previous comment, and yes I understand now.

@hamilton8415
Copy link
Collaborator

Testing newtons/lbs meters/inches now...

@hamilton8415
Copy link
Collaborator

Looks to me as if everything is correct with this and the analog related to logging in _gz, I am not sure if the tests are all running correctly, so maybe some attention needed there. I will keep testing and hope this can be merged very soon.

Copy link
Collaborator

@hamilton8415 hamilton8415 left a comment

Choose a reason for hiding this comment

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

I have done further testing for this and believe it is ready to be merged into main, along with mbari_wec_gz #140

@andermi andermi merged commit 12276ac into main May 29, 2023
@andermi andermi deleted the henthorn/sim_pblog branch May 29, 2023 22:04
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.

Log files
5 participants