def on_enter(self, userdata): # When entering this state, we send the action goal once to let the robot start its work. # As documented above, we get the specification of which dishwasher to use as input key. # This enables a previous state to make this decision during runtime and provide the ID as its own output key. # Create the goal. tweet = SendTweetGoal() tweet.text = userdata.tweet_text if len(userdata.tweet_text) > 140: tweet.text = '#LAMoR15 #ECMR15 I just told a too looong joke, stupid tweet length!' tweet.with_photo = True img = cv2.imread(userdata.picture_path) bridge = CvBridge() image_message = bridge.cv2_to_imgmsg(img, encoding="bgr8") tweet.photo = image_message try: self._client.send_goal(self._topic, tweet) except Exception as e: # Since a state failure not necessarily causes a behavior failure, it is recommended to only print warnings, not errors. # Using a linebreak before appending the error log enables the operator to collapse details in the GUI. Logger.logwarn( 'Failed to send the TweetPictureState command:\n%s' % str(e)) self._error = True
def on_enter(self, userdata): # When entering this state, we send the action goal once to let the robot start its work. # As documented above, we get the specification of which dishwasher to use as input key. # This enables a previous state to make this decision during runtime and provide the ID as its own output key. # Create the goal. tweet = SendTweetGoal() tweet.text = userdata.tweet_text if len(userdata.tweet_text) > 140: tweet.text = '#LAMoR15 #ECMR15 I just told a too looong joke, stupid tweet length!' tweet.with_photo = True img = cv2.imread(userdata.picture_path) bridge = CvBridge() image_message = bridge.cv2_to_imgmsg(img, encoding="bgr8") tweet.photo = image_message try: self._client.send_goal(self._topic, tweet) except Exception as e: # Since a state failure not necessarily causes a behavior failure, it is recommended to only print warnings, not errors. # Using a linebreak before appending the error log enables the operator to collapse details in the GUI. Logger.logwarn('Failed to send the TweetPictureState command:\n%s' % str(e)) self._error = True