-
Notifications
You must be signed in to change notification settings - Fork 0
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
Added a PoseBundle to SimpleCarState_V system. #497
Added a PoseBundle to SimpleCarState_V system. #497
Conversation
afccc2e
to
5bf6afe
Compare
Whether we go ahead with this PR, we might want to fix that. Someone using a vector ... will be inevitable. I can imagine that there are some difficulties around time-varying lengths when it comes to displaying them though - let alone handling dragging the topics to a plotter. Ask in an issue to the appropriate ignition forum. A side question - do they handle this for plotting or viewing ROS topics? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apojomovsky First pass, I left a couple comments.
src/backend/automotive_simulator.cc
Outdated
const delphyne::AgentBase<T>& | ||
AutomotiveSimulator<T>::GetAgentById(int agent_id) const { | ||
const delphyne::AgentBase<T>& AutomotiveSimulator<T>::GetAgentById( | ||
int agent_id) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apojomovsky why the change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, seems like clang-format
has been doing his thing here, which is weird since this code should have been already compliant. Just returned to its original state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, seems like clang-format has been doing his thing here, which is weird since this code should have been already compliant. Just returned to its original state.
Yeah, it seems to keep changing its mind; very often when I run it, it comes up with new differences. Not quite sure what is going on with it.
const drake::Isometry3<double>& pose = pose_bundle.get_pose(i); | ||
// Translates pose from quaternion to euler. | ||
const Eigen::Vector3d& euler_rotation = | ||
pose.rotation().eulerAngles(0, 1, 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apojomovsky Hmm, eulerAngles()
seems to be returning by-value. I wouldn't tie that temporary to a reference. Consider removing that extra &
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks!
const drake::multibody::SpatialVelocity<double>& spatial_velocity = | ||
velocity.get_velocity(); | ||
const double& velocity_norm = | ||
static_cast<double>(spatial_velocity.translational().norm()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apojomovsky Same as above for the last two statements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks!
static_cast<double>(spatial_velocity.translational().norm()); | ||
|
||
// Appends a new state to the vector. | ||
auto* current_state = output->add_states(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apojomovsky Does auto*
infer SimpleCarState*
? If so, it'd be great if you could be explicit about the type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks!
|
||
/// @brief A system that takes a PoseBundle and generates an array of | ||
/// SimpleCarStates (SimpleCarState_V). | ||
class PoseBundleToSimpleCarState_V : public drake::systems::LeafSystem<double> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apojomovsky meta: why can't PoseBundleToSimpleCarState_V
be a DrakeToIgn
subclass?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm you're right! Just did that. Thanks!
ign_monitor.get_last_message(); | ||
ign_monitor.get_last_message().states(0); | ||
|
||
// A very minimal loss of accuracy is produced during the conversion from the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apojomovsky consider Computations of SimpleCarState from a PoseBundle incur minimal numerical precision loss. Hence...
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks for the suggestion! Sounds a lot better!
|
||
// Shortly after starting, we should have not have moved much. | ||
const int kStateMessagesCount{1}; | ||
EXPECT_TRUE(ign_monitor.do_until( | ||
kStateMessagesCount, kTimeoutMs, | ||
[this, &simulator]() { simulator->StepBy(kSmallTimeStep); })); | ||
|
||
ignition::msgs::SimpleCarState state_message = ign_monitor.get_last_message(); | ||
ignition::msgs::SimpleCarState state_message = | ||
ign_monitor.get_last_message().states(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apojomovsky should we be checking that there's at least one state in the array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks!
5bf6afe
to
63a4029
Compare
63a4029
to
1b4f971
Compare
Thanks for the review @hidmic , I just finished addressing your first round of comments. PTAL. |
Fixes #485
PoseBundleToSimpleCarState_V
system that, as its name suggests, feeds from thePoseBundle
message published by thePoseAggregator
(which includes the poses of all the agents in the simulation) and generates an array ofSimpleCarState
.Solved issues:
Current issues:
Topic Viewer
cannot display the content ofrepeated
(vector) elements from an ignition message. This can be appreciated in the/visualizer/scene_update
topic, as well as in the just added/agents/state
topic, both shown in the figure below:Open to discussion: