setVariable() not having an effect

조회 수: 1 (최근 30일)
green_ananas
green_ananas 2021년 3월 2일
댓글: green_ananas 2021년 3월 5일
Hey everyone
I am trying to set up a reinforcement learning setup, where the initial conditions should be randomized after every episode. In my reset function, I have the following code:
ball.x0 = -0.04 + 0.08*rand; % m, ball initial x distance from center of plate
ball.y0 = -0.04 + 0.08*rand; % m, ball initial height from the top surface of plate
ball.z0 = 0;
ball.x0
ball.y0
in = setVariable(in,'ball',ball);
In my Simulink model, I have specified the input variable in the 6-DOF Joint primitive. But now, the ball starts at the same position every time, altough it should be randomized. Do you have any ideas?
Thanks a lot!

채택된 답변

Shadaab Siddiqie
Shadaab Siddiqie 2021년 3월 5일
편집: Shadaab Siddiqie 2021년 3월 5일
From my understanding setvariable is not having any effect. This might be due to :
  1. One of the possible reason is the parameter is compile-time rather run-time. It usually happens when working with simscape blocks. As a workaround, change preferences -> simscape and enable "show run-time parameter settings". Then open the block, find the option and switch it to "run-time".
  2. Another possible reason might be cache. Althought you change the model and save, .exe still use the old version of model. In this case, delete slprj folder and .slxc file. Then compiler / package it again.
  댓글 수: 1
green_ananas
green_ananas 2021년 3월 5일
Hey Shadaab,
thank you for your reply, the first one did it!
A follow up: When training using the reinforcement-learning environment, the first few episodes are simulated very quickly, and then the simulation slows down significantly. Do you have an idea why this happens? From a physical standpoint, nothing changed (It is a ball on a plate actuated by three motors).
Cheers, Dani

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multibody Dynamics에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by