diff --git a/plugin/actuator/pid.cc b/plugin/actuator/pid.cc index e73c769e..88959d4d 100644 --- a/plugin/actuator/pid.cc +++ b/plugin/actuator/pid.cc @@ -103,7 +103,7 @@ std::unique_ptr Pid::Create(const mjModel* m, int instance) { } if (config.slew_max.value_or(0.0) < 0) { - mju_warning("maxslew must be non-negative"); + mju_warning("slewmax must be non-negative"); return nullptr; } diff --git a/src/user/user_model.cc b/src/user/user_model.cc index 3eac695b..04ce63a4 100644 --- a/src/user/user_model.cc +++ b/src/user/user_model.cc @@ -3257,7 +3257,14 @@ mjModel* mjCModel::Compile(const mjVFS* vfs, mjModel** m) { try { if (setjmp(error_jmp_buf) != 0) { // TryCompile resulted in an mju_error which was converted to a longjmp. - throw mjCError(0, "engine error: %s", errortext); + std::string error_msg = errortext; + // also include the last warning that was issued. this is useful for + // warnings that came out of plugin implementations. + if (warningtext[0]) { + error_msg += "\n"; + error_msg += warningtext; + } + throw mjCError(0, "engine error: %s", error_msg.c_str()); } TryCompile(*const_cast(&model), *const_cast(&data), vfs); } catch (mjCError err) { diff --git a/test/plugin/actuator/pid_test.cc b/test/plugin/actuator/pid_test.cc index 1eec513d..a993a9ce 100644 --- a/test/plugin/actuator/pid_test.cc +++ b/test/plugin/actuator/pid_test.cc @@ -648,8 +648,8 @@ TEST_F(PidTest, InvalidClamp) { mjModel* m = LoadModelFromString(kModelXml, error, sizeof(error)); EXPECT_THAT(m, IsNull()); - // TODO: b/303654852 - ensure that the compilation error includes "imax" EXPECT_THAT(std::string_view(error), HasSubstr("plugin")); + EXPECT_THAT(std::string_view(error), HasSubstr("imax")); } TEST_F(PidTest, InvalidSlew) { @@ -679,8 +679,8 @@ TEST_F(PidTest, InvalidSlew) { mjModel* m = LoadModelFromString(kModelXml, error, sizeof(error)); ASSERT_THAT(m, IsNull()); - // TODO: b/303654852 - ensure that the compilation error includes "slewmax" EXPECT_THAT(std::string_view(error), HasSubstr("plugin")); + EXPECT_THAT(std::string_view(error), HasSubstr("slewmax")); } } // namespace } // namespace mujoco