benelot / pybullet-gym

Open-source implementations of OpenAI Gym MuJoCo environments for use with the OpenAI Gym Reinforcement Learning Research Platform.
https://pybullet.org/
Other
814 stars 124 forks source link

How to change the color of the robots? #29

Open GPaolo opened 4 years ago

GPaolo commented 4 years ago

Hi, I tried to change the colors of the Ant model by modifying the xml file rgba parameters, but with no luck. How can I change its colors?

benelot commented 4 years ago

Hi,

Unfortunately, that is not working yet in pybullet. Go to their repo and ask if there is a way to change the colors, this will push the issue.

On Sat, Jul 27, 2019, 12:47 Giuseppe Paolo notifications@github.com wrote:

Hi, I tried to change the colors of the Ant model by modifying the xml file rgba parameters, but with no luck. How can I change its colors?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/benelot/pybullet-gym/issues/29?email_source=notifications&email_token=AAXXXK7QXZXGZQZESI7ATE3QBQRTXA5CNFSM4IHI722KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HB26Y6Q, or mute the thread https://github.com/notifications/unsubscribe-auth/AAXXXK5XIKCE5DDVG3ACG63QBQRTXANCNFSM4IHI722A .

GPaolo commented 4 years ago

Ok, thanks!

GPaolo commented 4 years ago

So, after quite sometime going through the code and thanks to the suggestions gotten on the pybullet repo, I found out how to do that.

I added this lines to the reset method in the walker_base_env and it works

for link in range(-1, 20): #Changes the color of the robot Ant p.changeVisualShape(1, link, rgbaColor=[0.8, 0.6, 0.4, 1]) Still cannot read the color from the xml file, but this is a "nice" workaround. If I end up managing to read and set the color link by link from the xml file, I will do pull request.

benelot commented 4 years ago

Ok, yes that can be done. It is very sad that pybullet does not provide all information from the xml to us as a custom_fields dict or so. That would be very helpful to easily read the color data from it for example. Maybe we should suggest it to be implemented?

On Fri, Aug 16, 2019, 15:20 Giuseppe Paolo notifications@github.com wrote:

So, after quite sometime going through the code and thanks to the suggestions gotten on the pybullet repo, I found out how to do that.

I added this lines to the reset method in the walker_base_env and it works

for link in range(-1, 20): #Changes the color of the robot Ant p.changeVisualShape(1, link, rgbaColor=[0.8, 0.6, 0.4, 1]) Still cannot read the color from the xml file, but this is a "nice" workaround. If I end up managing to read and set the color link by link from the xml file, I will do pull request.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/benelot/pybullet-gym/issues/29?email_source=notifications&email_token=AAXXXK4G73SNON63W72DDVLQE2SRBA5CNFSM4IHI722KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4OS5ZA#issuecomment-522006244, or mute the thread https://github.com/notifications/unsubscribe-auth/AAXXXK3DQLIS7ZVFYUAXKLLQE2SRBANCNFSM4IHI722A .

GPaolo commented 4 years ago

I actually just found out this pull request that they had in pybullet : #1506 that looks like would implement something like this on version >=1.8.1, but for me it does not work on version 2.5.3.

I asked them about it, maybe I am doing something wrong ^^'

CharlesXu1124 commented 2 years ago

So, after quite sometime going through the code and thanks to the suggestions gotten on the pybullet repo, I found out how to do that.

I added this lines to the reset method in the walker_base_env and it works

for link in range(-1, 20): #Changes the color of the robot Ant p.changeVisualShape(1, link, rgbaColor=[0.8, 0.6, 0.4, 1]) Still cannot read the color from the xml file, but this is a "nice" workaround. If I end up managing to read and set the color link by link from the xml file, I will do pull request.

the first argument should be the robot UID, and then the link index