pybullet-gym icon indicating copy to clipboard operation
pybullet-gym copied to clipboard

How to change the color of the robots?

Open GPaolo opened this issue 5 years ago • 6 comments

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?

GPaolo avatar Jul 27 '19 10:07 GPaolo

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 [email protected] 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 .

benelot avatar Jul 27 '19 12:07 benelot

Ok, thanks!

GPaolo avatar Jul 30 '19 13:07 GPaolo

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.

GPaolo avatar Aug 16 '19 13:08 GPaolo

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 [email protected] 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 .

benelot avatar Aug 16 '19 16:08 benelot

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 ^^'

GPaolo avatar Aug 17 '19 08:08 GPaolo

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

CharlesXu1124 avatar Aug 26 '21 00:08 CharlesXu1124